Merge branch 'main' into animation

This commit is contained in:
MihailRis 2026-09-06 20:11:24 +03:00
commit eca7eeadee
7 changed files with 39 additions and 19 deletions

View file

@ -105,8 +105,6 @@ socket:peek_async(
[optional] usetable: boolean=false [optional] usetable: boolean=false
) -> nil|table|Bytearray ) -> nil|table|Bytearray
Translated with DeepL.com (free version)
-- Closes the connection -- Closes the connection
socket:close() socket:close()

View file

@ -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` - 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)` - `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` - `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. 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)` - `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` - `shading` - determines whether shading is enabled on the primitive. Example: `shading off`
- `flip` - flips the UV region horizontally or vertically. Example: `flip v` - `flip` - flips the UV region horizontally or vertically. Example: `flip v`
- `normal` - overrides normal vector. Example: `normal (0,1,0)`
### `box` Properties ### `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)` - `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)` - `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. - `texture` - the default texture to display for all sides.
- `shading` determines whether shading is enabled on the primitive. Example: `shading off` - `shading` - determines whether shading is enabled on the primitive. Example: `shading off`
- `delete` deletes sides by name (top, bottom, east, west, north, south) - `delete` - deletes sides by name (top, bottom, east, west, north, south)
### `part` properties (nested in `box`) ### `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)` - `tags` - determines which side the properties will be applied to. Example: `tags (top,bottom)`
- `texture` - the texture to display. Default: `$side_index`. - `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` - 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 ## Skeleton

View file

@ -41,6 +41,7 @@
- `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов квадрата нормализованных текстурных координат. Пример: `region (0,0,1,1)` - `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов квадрата нормализованных текстурных координат. Пример: `region (0,0,1,1)`
- `region-scale` вектор-множитель для UV региона. Пример: `region-scale (0.5,1)` - `region-scale` вектор-множитель для UV региона. Пример: `region-scale (0.5,1)`
- `shading` определяет возможность затенения на примитиве. Пример: `shading off` - `shading` определяет возможность затенения на примитиве. Пример: `shading off`
- `normal` переопределяет вектор нормали. Пример: `normal (0,1,0)`
Текстурные координаты по-умолчанию не зависят от формы из размера, в отличие от других примитивов. Текстурные координаты по-умолчанию не зависят от формы из размера, в отличие от других примитивов.
@ -53,9 +54,10 @@
- `up` - вектор Y, также определяющий высоту примитива. Пример: `up (0,1,0)` - `up` - вектор Y, также определяющий высоту примитива. Пример: `up (0,1,0)`
- `texture` - отображаемая текстура. По-умолчанию: `$0`. Пример: `texture "blocks:sand"` - `texture` - отображаемая текстура. По-умолчанию: `$0`. Пример: `texture "blocks:sand"`
- `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов. Пример: `region (0,0,1,1)` - `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов. Пример: `region (0,0,1,1)`
- `region-scale` вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)` - `region-scale` - вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)`
- `shading` определяет возможность затенения на примитиве. Пример: `shading off` - `shading` - определяет возможность затенения на примитиве. Пример: `shading off`
- `flip` отражает UV регион по горизонтали или вертикали. Пример: `flip v` - `flip` - отражает UV регион по горизонтали или вертикали. Пример: `flip v`
- `normal` - переопределяет вектор нормали. Пример: `normal (0,1,0)`
### Свойства `box` ### Свойства `box`
@ -66,8 +68,8 @@
- `origin` - точка, относительно которой будет применено вращение. По-умолчанию: центр примитива. Пример: `origin (0.5,0.5,0.5)` - `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)` - `rotate` - вращение вокруг осей (x,y,z) в градусах, или кватернион (x,y,z,w). Пример: `rotate (45,0,0)` или `rotate (0.3826834, 0, 0, 0.9238795)`
- `texture` - отображаемая текстура для всех сторон по-умолчанию. - `texture` - отображаемая текстура для всех сторон по-умолчанию.
- `shading` определяет возможность затенения на примитиве. Пример: `shading off` - `shading` - определяет возможность затенения на примитиве. Пример: `shading off`
- `delete` удаляет стороны по именам (top, bottom, east, west, north, south) - `delete` - удаляет стороны по именам (top, bottom, east, west, north, south)
### Свойства `part` (вложен в `box`) ### Свойства `part` (вложен в `box`)
@ -76,7 +78,7 @@
- `tags` - определяет то, на какаие из сторон будут применены свойства. Пример: `tags (top,bottom)` - `tags` - определяет то, на какаие из сторон будут применены свойства. Пример: `tags (top,bottom)`
- `texture` - отображаемая текстура. По-умолчанию: `$индекс_стороны`. - `texture` - отображаемая текстура. По-умолчанию: `$индекс_стороны`.
- `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов. Пример: `region (0,0,1,1)` - `region` - UV регион в границах выбранной текстуры, определяется позициями противоположных углов. Пример: `region (0,0,1,1)`
- `region-scale` вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)` - `region-scale` - вектор-множитель для автоматически выбранного UV региона. Пример: `region-scale (0.5,1)`
## Скелет ## Скелет

View file

@ -13,6 +13,7 @@ uniform vec3 u_fogColor;
uniform float u_fogFactor; uniform float u_fogFactor;
uniform float u_fogCurve; uniform float u_fogCurve;
uniform bool u_alphaClip; uniform bool u_alphaClip;
uniform bool u_dithering;
uniform vec3 u_sunDir; uniform vec3 u_sunDir;
const float BAYER_MATRIX[64] = float[]( const float BAYER_MATRIX[64] = float[](
@ -35,13 +36,17 @@ void main() {
vec4 texColor = texture(u_texture0, a_texCoord); vec4 texColor = texture(u_texture0, a_texCoord);
float alpha = a_color.a * texColor.a; float alpha = a_color.a * texColor.a;
// anyway it's any alpha-test alternative required // anyway it's any alpha-test alternative required
if (u_alphaClip) { if (u_dithering) {
float bayer = calc_bayer(gl_FragCoord.xy); if (u_alphaClip) {
if (alpha - bayer < 0.01f) { float bayer = calc_bayer(gl_FragCoord.xy);
if (alpha - bayer < 0.01f) {
discard;
}
alpha = 1.0;
} else if (alpha < 0.05f) {
discard; discard;
} }
alpha = 1.0; } else if (alpha < (u_alphaClip ? 0.5f : 0.15f)) {
} else if (alpha < 0.05f) {
discard; discard;
} }
f_color = a_color * texColor; f_color = a_color * texColor;

View file

@ -192,7 +192,12 @@ static void perform_rect(const xmlelement& root, ModelBuilder& builder) {
} }
std::string texture = root.attr("texture", "$0").getText(); 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( builder.addRect(
texture, texture,
shading, shading,
@ -218,7 +223,12 @@ static void perform_triangle(const xmlelement& root, ModelBuilder& builder) {
glm::vec3 ba = pointB - pointA; glm::vec3 ba = pointB - pointA;
glm::vec3 ca = pointC - 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")) { if (root.has("uv")) {
root.attr("uv").asNumbers(glm::value_ptr(uvs[0]), 6); root.attr("uv").asNumbers(glm::value_ptr(uvs[0]), 6);

View file

@ -144,6 +144,7 @@ void BlockWrapsRenderer::draw(const DrawContext& pctx) {
auto& shader = assets.require<Shader>("entity"); auto& shader = assets.require<Shader>("entity");
shader.use(); shader.use();
shader.uniform1i("u_alphaClip", false); shader.uniform1i("u_alphaClip", false);
shader.uniform1i("u_dithering", 0);
for (const auto& [_, wrapper] : wrappers) { for (const auto& [_, wrapper] : wrappers) {
if (wrapper->dirtySides) { if (wrapper->dirtySides) {
@ -198,4 +199,4 @@ void BlockWrapsRenderer::clearOrder(const BlockWrapper* const wrapper) {
++it; ++it;
} }
} }
} }

View file

@ -244,6 +244,7 @@ void WorldRenderer::renderOpaque(
} }
entityShader.uniform1i("u_alphaClip", true); entityShader.uniform1i("u_alphaClip", true);
entityShader.uniform1i("u_dithering", 1);
entityShader.uniform1f("u_opacity", 1.0f); entityShader.uniform1f("u_opacity", 1.0f);
level.entities->render( level.entities->render(
assets, assets,
@ -512,6 +513,7 @@ void WorldRenderer::renderWeatherEffects(Camera& camera) {
float one = weather->fall.maxOpacity; float one = weather->fall.maxOpacity;
float t = (weather->intensity * (one - zero)) * maxIntensity + zero; float t = (weather->intensity * (one - zero)) * maxIntensity + zero;
entityShader.uniform1i("u_alphaClip", weather->fall.opaque); entityShader.uniform1i("u_alphaClip", weather->fall.opaque);
entityShader.uniform1i("u_dithering", 0);
entityShader.uniform1f( entityShader.uniform1f(
"u_opacity", weather->fall.opaque ? t * t : t "u_opacity", weather->fall.opaque ? t * t : t
); );