summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2021-12-19 13:00:13 +0100
committerLaG1924 <lag1924@gmail.com>2021-12-19 13:00:13 +0100
commitbac80e3514f93055daa4e743fa4f8ba177f77311 (patch)
tree1defef5e53fa99d4e5fdd2fc32cfb8bc7128c18c
parentAdded AO mask (diff)
downloadAltCraft-bac80e3514f93055daa4e743fa4f8ba177f77311.tar
AltCraft-bac80e3514f93055daa4e743fa4f8ba177f77311.tar.gz
AltCraft-bac80e3514f93055daa4e743fa4f8ba177f77311.tar.bz2
AltCraft-bac80e3514f93055daa4e743fa4f8ba177f77311.tar.lz
AltCraft-bac80e3514f93055daa4e743fa4f8ba177f77311.tar.xz
AltCraft-bac80e3514f93055daa4e743fa4f8ba177f77311.tar.zst
AltCraft-bac80e3514f93055daa4e743fa4f8ba177f77311.zip
-rw-r--r--cwd/assets/altcraft/shaders/vert/face.vs16
-rw-r--r--src/RendererSectionData.cpp11
-rw-r--r--src/RendererSectionData.hpp9
-rw-r--r--src/RendererWorld.cpp9
4 files changed, 20 insertions, 25 deletions
diff --git a/cwd/assets/altcraft/shaders/vert/face.vs b/cwd/assets/altcraft/shaders/vert/face.vs
index d3caf32..101e4d0 100644
--- a/cwd/assets/altcraft/shaders/vert/face.vs
+++ b/cwd/assets/altcraft/shaders/vert/face.vs
@@ -1,13 +1,11 @@
#version 330 core
in vec3 pos[4];
-in vec3 normal;
in vec2 uv[4];
-in float uvLayer;
-in float animation;
+in vec2 light[4];
+in vec3 normal;
in vec3 color;
-in vec2 light;
-in float ambientOcclusion;
+in vec3 layerAnimationAo;
out vec3 faceTextureUv;
out vec3 faceNormal;
@@ -30,11 +28,11 @@ layout (std140) uniform Globals {
void main() {
gl_Position = projView * vec4(pos[gl_VertexID], 1.0f);
- faceTextureUv = vec3(uv[gl_VertexID], uvLayer);
- faceTextureUv.y -= (uv[2].y - uv[0].y) * trunc(mod(globalTime * 4.0f, animation));
+ faceTextureUv = vec3(uv[gl_VertexID], layerAnimationAo.r);
+ faceTextureUv.y -= (uv[2].y - uv[0].y) * trunc(mod(globalTime * 4.0f, layerAnimationAo.g));
faceNormal = (view * vec4(normal, 0.0f)).xyz;
faceAddColor = color;
- faceLight = light;
- faceAmbientOcclusion = ambientOcclusion;
+ faceLight = light[gl_VertexID];
+ faceAmbientOcclusion = layerAnimationAo.b;
}
diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp
index c7d922e..979858e 100644
--- a/src/RendererSectionData.cpp
+++ b/src/RendererSectionData.cpp
@@ -65,11 +65,14 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co
vertexData.uvs[2] = TransformTextureCoord(face.texture, glm::vec2(1, 1), face.frames);
vertexData.uvs[3] = TransformTextureCoord(face.texture, glm::vec2(0, 1), face.frames);
- vertexData.uvLayers = face.layer;
- vertexData.animations = face.frames;
+ vertexData.layerAnimationAo.r = face.layer;
+ vertexData.layerAnimationAo.g = face.frames;
vertexData.colors = face.color;
- vertexData.lights = lightness;
- vertexData.ambientOcclusion = model.ambientOcclusion ? 1.0f : 0.0f;
+ vertexData.lights[0] = lightness;
+ vertexData.lights[1] = lightness;
+ vertexData.lights[2] = lightness;
+ vertexData.lights[3] = lightness;
+ vertexData.layerAnimationAo.b = model.ambientOcclusion ? 1.0f : 0.0f;
}
}
diff --git a/src/RendererSectionData.hpp b/src/RendererSectionData.hpp
index 390200c..efc6cad 100644
--- a/src/RendererSectionData.hpp
+++ b/src/RendererSectionData.hpp
@@ -32,14 +32,11 @@ struct SectionsData {
struct VertexData {
glm::vec3 positions[4];
- glm::vec3 normal;
glm::vec2 uvs[4];
- float uvLayers;
- float animations;
+ glm::vec2 lights[4];
+ glm::vec3 normal;
glm::vec3 colors;
- glm::vec2 lights;
- float ambientOcclusion;
- uint8_t padding[4];
+ glm::vec3 layerAnimationAo; //R - uvLayer, G - animation, B - ambientOcclusion
};
struct RendererSectionData {
diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp
index 2ffb57f..21f0db2 100644
--- a/src/RendererWorld.cpp
+++ b/src/RendererWorld.cpp
@@ -457,14 +457,11 @@ void RendererWorld::PrepareRender(std::shared_ptr<Gal::Framebuffer> target, bool
sectionsPLC->SetPrimitive(Gal::Primitive::TriangleFan);
sectionsBufferBinding = sectionsPLC->BindVertexBuffer({
{"pos", Gal::Type::Vec3, 4, 1},
- {"normal", Gal::Type::Vec3, 1, 1},
{"uv", Gal::Type::Vec2, 4, 1},
- {"uvLayer", Gal::Type::Float, 1, 1},
- {"animation", Gal::Type::Float, 1, 1},
+ {"light", Gal::Type::Vec2, 4, 1},
+ {"normal", Gal::Type::Vec3, 1, 1},
{"color", Gal::Type::Vec3, 1, 1},
- {"light", Gal::Type::Vec2, 1, 1},
- {"ambientOcclusion", Gal::Type::Float, 1, 1},
- {"", Gal::Type::Uint8, 4, 1}
+ {"layerAnimationAo", Gal::Type::Vec3, 1, 1},
});
sectionsPipeline = gal->BuildPipeline(sectionsPLC);
}