summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2021-12-07 17:53:02 +0100
committerLaG1924 <lag1924@gmail.com>2021-12-07 17:53:02 +0100
commit91afb55a58c4b27d0c746e64305dd1d9ad816d94 (patch)
treecdf8c74b4b0aff8f0df7208b1c48f4b99f951db4
parentFixed GalOgl OglState dangling resource (diff)
downloadAltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar.gz
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar.bz2
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar.lz
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar.xz
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar.zst
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.zip
-rw-r--r--cwd/assets/altcraft/shaders/frag/blur.fs2
-rw-r--r--cwd/assets/altcraft/shaders/frag/light.fs4
-rw-r--r--cwd/assets/altcraft/shaders/frag/ssao.fs4
-rw-r--r--cwd/assets/altcraft/shaders/vert/face.vs2
-rw-r--r--src/RendererSectionData.cpp5
5 files changed, 11 insertions, 6 deletions
diff --git a/cwd/assets/altcraft/shaders/frag/blur.fs b/cwd/assets/altcraft/shaders/frag/blur.fs
index b49032f..89d4498 100644
--- a/cwd/assets/altcraft/shaders/frag/blur.fs
+++ b/cwd/assets/altcraft/shaders/frag/blur.fs
@@ -18,5 +18,5 @@ void main() {
result += texture(blurInput, uv + offset);
}
}
- fragColor = result / pow(blurScale, 3);
+ fragColor = result / pow(blurScale * 2.0f, 2);
}
diff --git a/cwd/assets/altcraft/shaders/frag/light.fs b/cwd/assets/altcraft/shaders/frag/light.fs
index d1763f9..c7e7254 100644
--- a/cwd/assets/altcraft/shaders/frag/light.fs
+++ b/cwd/assets/altcraft/shaders/frag/light.fs
@@ -43,7 +43,7 @@ void main() {
float lightLevel = clamp(faceLight + skyLight * dayTime, 0.01f, 1.0f);
lightLevel = pow(lightLevel, 3);
if (applySsao) {
- lightLevel *= (1.0f - s.r);
+ lightLevel *= pow(s.r, 2);
}
lightLevel = clamp(lightLevel, 0.005f, 1.0f);
@@ -74,7 +74,7 @@ void main() {
fragColor = vec4(vec3(d), 1.0f);
break;
case 7:
- fragColor = s;
+ fragColor = vec4(pow(s.r, 2));
break;
}
}
diff --git a/cwd/assets/altcraft/shaders/frag/ssao.fs b/cwd/assets/altcraft/shaders/frag/ssao.fs
index f4fea34..0615e8f 100644
--- a/cwd/assets/altcraft/shaders/frag/ssao.fs
+++ b/cwd/assets/altcraft/shaders/frag/ssao.fs
@@ -51,5 +51,7 @@ void main() {
occlusion += (sampleDepth >= samplePos.z + bias ? 1.0 : 0.0) * rangeCheck;
}
- fragColor = vec4(vec3(occlusion / kernelSize), 1.0f);
+ occlusion = 1.0f - (occlusion / kernelSize);
+
+ fragColor = vec4(vec3(occlusion), 1.0f);
}
diff --git a/cwd/assets/altcraft/shaders/vert/face.vs b/cwd/assets/altcraft/shaders/vert/face.vs
index e50e503..a85b2c6 100644
--- a/cwd/assets/altcraft/shaders/vert/face.vs
+++ b/cwd/assets/altcraft/shaders/vert/face.vs
@@ -33,7 +33,7 @@ void main() {
faceTextureUv = vec3(uv[gl_VertexID], uvLayer);
faceTextureUv.y -= (uv[2].y - uv[0].y) * trunc(mod(globalTime * 4.0f, animation));
- faceNormal = normal;
+ faceNormal = (view * vec4(normal, 0.0f)).xyz;
faceAddColor = color;
faceLight = light;
}
diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp
index 45d242c..94c802d 100644
--- a/src/RendererSectionData.cpp
+++ b/src/RendererSectionData.cpp
@@ -3,6 +3,7 @@
#include <array>
#include <glm/gtc/matrix_transform.hpp>
+#include <glm/gtc/matrix_inverse.hpp>
#include <optick.h>
#include "World.hpp"
@@ -25,6 +26,8 @@ glm::vec2 TransformTextureCoord(glm::vec4 TextureAtlasCoords, glm::vec2 UvCoords
}
void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, const glm::mat4 &transform, bool visibility[FaceDirection::none], BlockLightness light, BlockLightness skyLight) {
+ glm::mat3 normalMat = glm::mat3(glm::inverseTranspose(transform * model.transform));
+
for (const auto &face : model.faces) {
glm::vec3 normal = {};
glm::vec2 lightness;
@@ -58,7 +61,7 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co
vertexData.positions[2] = transformed * glm::vec4(1, 0, 1, 1);
vertexData.positions[3] = transformed * glm::vec4(1, 0, 0, 1);
- vertexData.normal = model.transform * face.transform * glm::vec4(normal, 1.0f);
+ vertexData.normal = glm::normalize(normalMat * glm::vec4(normal, 1.0f));
vertexData.uvs[0] = TransformTextureCoord(face.texture, glm::vec2(0, 0), face.frames);
vertexData.uvs[1] = TransformTextureCoord(face.texture, glm::vec2(1, 0), face.frames);