diff --git a/doc/en/scripting/builtins/libnetwork.md b/doc/en/scripting/builtins/libnetwork.md index c4e61837d..0ce5c1b0e 100644 --- a/doc/en/scripting/builtins/libnetwork.md +++ b/doc/en/scripting/builtins/libnetwork.md @@ -105,8 +105,6 @@ socket:peek_async( [optional] usetable: boolean=false ) -> nil|table|Bytearray -Translated with DeepL.com (free version) - -- Closes the connection socket:close() diff --git a/doc/en/vcm.md b/doc/en/vcm.md index d384bb7d4..116d9a1d6 100644 --- a/doc/en/vcm.md +++ b/doc/en/vcm.md @@ -41,6 +41,7 @@ This primitive describes a triangle. - `region` - UV region within the selected texture, defined by the positions of opposite corners of a square of normalized texture coordinates. Example: `region (0,0,1,1)` - `region-scale` - multiplier vector for the UV region. Example: `region-scale (0.5,1)` - `shading` - determines whether shading is enabled on the primitive. Example: `shading off` +- `normal` - overrides normal vector. Example: `normal (0,1,0)` By default, texture coordinates are not affected by shape or size, unlike other primitives. @@ -56,6 +57,7 @@ This primitive describes a parallelogram using the right and up vectors. - `region-scale` - the multiplier vector for the automatically selected UV region. Example: `region-scale (0.5,1)` - `shading` - determines whether shading is enabled on the primitive. Example: `shading off` - `flip` - flips the UV region horizontally or vertically. Example: `flip v` +- `normal` - overrides normal vector. Example: `normal (0,1,0)` ### `box` Properties @@ -66,8 +68,8 @@ This primitive describes a rectangular parallelepiped. - `origin` - the point relative to which the rotation will be applied. Default: the center of the primitive. Example: `origin (0.5,0.5,0.5)` - `rotate` - rotation around the (x,y,z) axes in degrees, or a quaternion (x,y,z,w). Example: `rotate (45,0,0)` or `rotate (0.3826834, 0, 0, 0.9238795)` - `texture` - the default texture to display for all sides. -- `shading` determines whether shading is enabled on the primitive. Example: `shading off` -- `delete` deletes sides by name (top, bottom, east, west, north, south) +- `shading` - determines whether shading is enabled on the primitive. Example: `shading off` +- `delete` - deletes sides by name (top, bottom, east, west, north, south) ### `part` properties (nested in `box`) @@ -76,7 +78,7 @@ This primitive describes the properties of the sides of a rectangular parallelep - `tags` - determines which side the properties will be applied to. Example: `tags (top,bottom)` - `texture` - the texture to display. Default: `$side_index`. - `region` - the UV region within the selected texture, defined by the positions of opposite corners. Example: `region (0,0,1,1)` -- `region-scale` is a multiplier vector for the automatically selected UV region. Example: `region-scale (0.5,1)` +- `region-scale` - multiplier vector for the automatically selected UV region. Example: `region-scale (0.5,1)` ## Skeleton diff --git a/doc/ru/vcm.md b/doc/ru/vcm.md index a1b72ca48..335f6a7a7 100644 --- a/doc/ru/vcm.md +++ b/doc/ru/vcm.md @@ -41,6 +41,7 @@ - `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов квадрата нормализованных текстурных координат. Пример: `region (0,0,1,1)` - `region-scale` вектор-множитель для UV региона. Пример: `region-scale (0.5,1)` - `shading` определяет возможность затенения на примитиве. Пример: `shading off` +- `normal` переопределяет вектор нормали. Пример: `normal (0,1,0)` Текстурные координаты по-умолчанию не зависят от формы из размера, в отличие от других примитивов. @@ -53,9 +54,10 @@ - `up` - вектор Y, также определяющий высоту примитива. Пример: `up (0,1,0)` - `texture` - отображаемая текстура. По-умолчанию: `$0`. Пример: `texture "blocks:sand"` - `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов. Пример: `region (0,0,1,1)` -- `region-scale` вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)` -- `shading` определяет возможность затенения на примитиве. Пример: `shading off` -- `flip` отражает UV регион по горизонтали или вертикали. Пример: `flip v` +- `region-scale` - вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)` +- `shading` - определяет возможность затенения на примитиве. Пример: `shading off` +- `flip` - отражает UV регион по горизонтали или вертикали. Пример: `flip v` +- `normal` - переопределяет вектор нормали. Пример: `normal (0,1,0)` ### Свойства `box` @@ -66,8 +68,8 @@ - `origin` - точка, относительно которой будет применено вращение. По-умолчанию: центр примитива. Пример: `origin (0.5,0.5,0.5)` - `rotate` - вращение вокруг осей (x,y,z) в градусах, или кватернион (x,y,z,w). Пример: `rotate (45,0,0)` или `rotate (0.3826834, 0, 0, 0.9238795)` - `texture` - отображаемая текстура для всех сторон по-умолчанию. -- `shading` определяет возможность затенения на примитиве. Пример: `shading off` -- `delete` удаляет стороны по именам (top, bottom, east, west, north, south) +- `shading` - определяет возможность затенения на примитиве. Пример: `shading off` +- `delete` - удаляет стороны по именам (top, bottom, east, west, north, south) ### Свойства `part` (вложен в `box`) @@ -76,7 +78,7 @@ - `tags` - определяет то, на какаие из сторон будут применены свойства. Пример: `tags (top,bottom)` - `texture` - отображаемая текстура. По-умолчанию: `$индекс_стороны`. - `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов. Пример: `region (0,0,1,1)` -- `region-scale` вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)` +- `region-scale` - вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)` ## Скелет diff --git a/res/shaders/entity.glslf b/res/shaders/entity.glslf index a817d963a..47883c327 100644 --- a/res/shaders/entity.glslf +++ b/res/shaders/entity.glslf @@ -13,6 +13,7 @@ uniform vec3 u_fogColor; uniform float u_fogFactor; uniform float u_fogCurve; uniform bool u_alphaClip; +uniform bool u_dithering; uniform vec3 u_sunDir; const float BAYER_MATRIX[64] = float[]( @@ -35,13 +36,17 @@ void main() { vec4 texColor = texture(u_texture0, a_texCoord); float alpha = a_color.a * texColor.a; // anyway it's any alpha-test alternative required - if (u_alphaClip) { - float bayer = calc_bayer(gl_FragCoord.xy); - if (alpha - bayer < 0.01f) { + if (u_dithering) { + if (u_alphaClip) { + float bayer = calc_bayer(gl_FragCoord.xy); + if (alpha - bayer < 0.01f) { + discard; + } + alpha = 1.0; + } else if (alpha < 0.05f) { discard; } - alpha = 1.0; - } else if (alpha < 0.05f) { + } else if (alpha < (u_alphaClip ? 0.5f : 0.15f)) { discard; } f_color = a_color * texColor; diff --git a/src/coders/vcm.cpp b/src/coders/vcm.cpp index 260657338..42a503477 100644 --- a/src/coders/vcm.cpp +++ b/src/coders/vcm.cpp @@ -192,7 +192,12 @@ static void perform_rect(const xmlelement& root, ModelBuilder& builder) { } std::string texture = root.attr("texture", "$0").getText(); - auto normal = glm::cross(glm::normalize(right), glm::normalize(up)); + glm::vec3 normal; + if (root.has("normal")) { + normal = root.attr("normal").asVec3(); + } else { + normal = glm::cross(glm::normalize(right), glm::normalize(up)); + } builder.addRect( texture, shading, @@ -218,7 +223,12 @@ static void perform_triangle(const xmlelement& root, ModelBuilder& builder) { glm::vec3 ba = pointB - pointA; glm::vec3 ca = pointC - pointA; - glm::vec3 normal = glm::normalize(glm::cross(ba, ca)); + glm::vec3 normal; + if (root.has("normal")) { + normal = root.attr("normal").asVec3(); + } else { + normal = glm::normalize(glm::cross(ba, ca)); + } if (root.has("uv")) { root.attr("uv").asNumbers(glm::value_ptr(uvs[0]), 6); diff --git a/src/graphics/render/BlockWrapsRenderer.cpp b/src/graphics/render/BlockWrapsRenderer.cpp index fb72d3347..168ad14a2 100644 --- a/src/graphics/render/BlockWrapsRenderer.cpp +++ b/src/graphics/render/BlockWrapsRenderer.cpp @@ -144,6 +144,7 @@ void BlockWrapsRenderer::draw(const DrawContext& pctx) { auto& shader = assets.require("entity"); shader.use(); shader.uniform1i("u_alphaClip", false); + shader.uniform1i("u_dithering", 0); for (const auto& [_, wrapper] : wrappers) { if (wrapper->dirtySides) { @@ -198,4 +199,4 @@ void BlockWrapsRenderer::clearOrder(const BlockWrapper* const wrapper) { ++it; } } -} \ No newline at end of file +} diff --git a/src/graphics/render/WorldRenderer.cpp b/src/graphics/render/WorldRenderer.cpp index 5c5616fc2..f3b793c0a 100644 --- a/src/graphics/render/WorldRenderer.cpp +++ b/src/graphics/render/WorldRenderer.cpp @@ -244,6 +244,7 @@ void WorldRenderer::renderOpaque( } entityShader.uniform1i("u_alphaClip", true); + entityShader.uniform1i("u_dithering", 1); entityShader.uniform1f("u_opacity", 1.0f); level.entities->render( assets, @@ -512,6 +513,7 @@ void WorldRenderer::renderWeatherEffects(Camera& camera) { float one = weather->fall.maxOpacity; float t = (weather->intensity * (one - zero)) * maxIntensity + zero; entityShader.uniform1i("u_alphaClip", weather->fall.opaque); + entityShader.uniform1i("u_dithering", 0); entityShader.uniform1f( "u_opacity", weather->fall.opaque ? t * t : t );