From f16c897522b6418c399b5699f8378a25c2e5de4f Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 21 Nov 2021 14:57:57 +0500 Subject: Added normals to faces --- cwd/assets/altcraft/shaders/frag/face.fs | 3 ++- cwd/assets/altcraft/shaders/frag/light.fs | 2 +- cwd/assets/altcraft/shaders/vert/face.vs | 15 +++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'cwd') diff --git a/cwd/assets/altcraft/shaders/frag/face.fs b/cwd/assets/altcraft/shaders/frag/face.fs index 0eb5a21..2120697 100644 --- a/cwd/assets/altcraft/shaders/frag/face.fs +++ b/cwd/assets/altcraft/shaders/frag/face.fs @@ -3,6 +3,7 @@ in VS_OUT { vec3 Texture; vec3 Color; + vec3 faceNormal; } fs_in; layout (location = 0) out vec4 color; @@ -16,5 +17,5 @@ void main() { discard; color = vec4(col.rgb * fs_in.Color, 1.0f); - normal = vec4(1.0f - color.r, 1.0f - color.b, 1.0f, 1.0f); + normal = vec4(fs_in.faceNormal, 1.0f); } diff --git a/cwd/assets/altcraft/shaders/frag/light.fs b/cwd/assets/altcraft/shaders/frag/light.fs index 480e265..73686cc 100644 --- a/cwd/assets/altcraft/shaders/frag/light.fs +++ b/cwd/assets/altcraft/shaders/frag/light.fs @@ -12,5 +12,5 @@ void main() { vec4 c = texture(color, uv); vec4 n = texture(normal, uv); float d = texture(depthStencil, uv).r; - fragColor = vec4(c.r, n.r, d - 0.3f, 1.0f); + fragColor = n; } diff --git a/cwd/assets/altcraft/shaders/vert/face.vs b/cwd/assets/altcraft/shaders/vert/face.vs index 93e623d..21f7110 100644 --- a/cwd/assets/altcraft/shaders/vert/face.vs +++ b/cwd/assets/altcraft/shaders/vert/face.vs @@ -1,15 +1,17 @@ #version 330 core -layout (location = 0) in vec3 position[4]; -layout (location = 4) in vec2 uv[4]; -layout (location = 8) in float uvLayer; -layout (location = 9) in float animation; -layout (location = 10) in vec3 color; -layout (location = 11) in vec2 light; +in vec3 position[4]; +in vec3 normal; +in vec2 uv[4]; +in float uvLayer; +in float animation; +in vec3 color; +in vec2 light; out VS_OUT { vec3 Texture; vec3 Color; + vec3 faceNormal; } vs_out; uniform float GlobalTime; @@ -24,4 +26,5 @@ void main() { float faceLight = clamp(light.x / 15.0 + (light.y / 15.0) * DayTime, MinLightLevel, 1.0); vs_out.Color = mix(color.rgb * faceLight, vec3(1,1,1) * faceLight, float(color == vec3(0,0,0))); + vs_out.faceNormal = normal; } -- cgit v1.2.3