From 0ca11f9bee1cd918acf6ce8247a495442009fec9 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 21 Nov 2021 17:49:23 +0500 Subject: Moved face lighting to lighting pass --- cwd/assets/altcraft/shaders/frag/sky.fs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'cwd/assets/altcraft/shaders/frag/sky.fs') diff --git a/cwd/assets/altcraft/shaders/frag/sky.fs b/cwd/assets/altcraft/shaders/frag/sky.fs index 53e0cf4..3763bdb 100644 --- a/cwd/assets/altcraft/shaders/frag/sky.fs +++ b/cwd/assets/altcraft/shaders/frag/sky.fs @@ -2,7 +2,10 @@ in vec3 pos; -out vec4 fragColor; +layout (location = 0) out vec4 color; +layout (location = 1) out vec4 normal; +layout (location = 2) out vec4 addColor; +layout (location = 3) out vec4 light; uniform sampler2DArray textureAtlas; uniform float DayTime; @@ -46,7 +49,10 @@ vec4 Moon() { void main() { vec4 starColor = vec4(0.0f, 0.04f, 0.06f, 1.0f); - fragColor = mix(starColor, DaySkyColor, DayTime); - fragColor += Sun(); - fragColor += Moon(); + color = vec4(mix(starColor, DaySkyColor, DayTime).rgb, 1.0f); + color += vec4(Sun().rgb, 1.0f); + color += vec4(Moon().rgb, 1.0f); + normal = vec4(0.0f, 0.0f, 0.0f, 1.0f); + addColor = vec4(0.0f, 0.0f, 0.0f, 1.0f); + light = vec4(1.0f, 1.0f, 0.0f, 1.0f); } -- cgit v1.2.3 From c905ede556c892d39fd69d3945026ba244567ce9 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 27 Nov 2021 21:08:58 +0500 Subject: Changed shaders to use SPB --- cwd/assets/altcraft/shaders/frag/sky.fs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cwd/assets/altcraft/shaders/frag/sky.fs') diff --git a/cwd/assets/altcraft/shaders/frag/sky.fs b/cwd/assets/altcraft/shaders/frag/sky.fs index 3763bdb..32b7da0 100644 --- a/cwd/assets/altcraft/shaders/frag/sky.fs +++ b/cwd/assets/altcraft/shaders/frag/sky.fs @@ -7,8 +7,14 @@ layout (location = 1) out vec4 normal; layout (location = 2) out vec4 addColor; layout (location = 3) out vec4 light; +layout (std140) uniform Globals { + mat4 projView; + uvec2 viewportSize; + float globalTime; + float dayTime; +}; + uniform sampler2DArray textureAtlas; -uniform float DayTime; uniform vec4 sunTexture; uniform float sunTextureLayer; uniform vec4 moonTexture; @@ -49,7 +55,7 @@ vec4 Moon() { void main() { vec4 starColor = vec4(0.0f, 0.04f, 0.06f, 1.0f); - color = vec4(mix(starColor, DaySkyColor, DayTime).rgb, 1.0f); + color = vec4(mix(starColor, DaySkyColor, dayTime).rgb, 1.0f); color += vec4(Sun().rgb, 1.0f); color += vec4(Moon().rgb, 1.0f); normal = vec4(0.0f, 0.0f, 0.0f, 1.0f); -- cgit v1.2.3 From 8286ddda96a5f2925d342d0ce115aa00ae5d94ec Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 28 Nov 2021 16:16:29 +0500 Subject: Added gamma correction --- cwd/assets/altcraft/shaders/frag/sky.fs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'cwd/assets/altcraft/shaders/frag/sky.fs') diff --git a/cwd/assets/altcraft/shaders/frag/sky.fs b/cwd/assets/altcraft/shaders/frag/sky.fs index 32b7da0..1e36dd3 100644 --- a/cwd/assets/altcraft/shaders/frag/sky.fs +++ b/cwd/assets/altcraft/shaders/frag/sky.fs @@ -1,6 +1,6 @@ #version 330 core -in vec3 pos; +in vec3 facePos; layout (location = 0) out vec4 color; layout (location = 1) out vec4 normal; @@ -12,6 +12,7 @@ layout (std140) uniform Globals { uvec2 viewportSize; float globalTime; float dayTime; + float gamma; }; uniform sampler2DArray textureAtlas; @@ -20,12 +21,14 @@ uniform float sunTextureLayer; uniform vec4 moonTexture; uniform float moonTextureLayer; -const vec4 DaySkyColor = vec4(0.49, 0.66, 1, 1); +const vec4 DaySkyColor = vec4(0.21, 0.4, 1, 1); const vec3 SunPos = vec3(0, 0.1, 0.5); const vec3 MoonPos = vec3(0, 0.1, -0.5); +const vec4 NightSkyColor = vec4(0.0, 0.0008, 0.002, 1.0); + vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer) { float x = TextureAtlasCoords.x; float y = TextureAtlasCoords.y; @@ -38,7 +41,7 @@ vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer) } vec4 Sun() { - vec3 sunDelta = (pos - SunPos) * 3.0f; + vec3 sunDelta = (facePos - SunPos) * 3.0f; float distanceToSun = length(sunDelta); vec4 sunColor = texture(textureAtlas, TransformTextureCoord(sunTexture, (vec2(sunDelta.xy) + 0.5f), sunTextureLayer)); vec4 sun = mix(vec4(0, 0, 0, 1), sunColor, clamp(1 - distanceToSun * 2.0f, 0, 1)); @@ -46,7 +49,7 @@ vec4 Sun() { } vec4 Moon() { - vec3 moonDelta = (pos - MoonPos) * 4.5f; + vec3 moonDelta = (facePos - MoonPos) * 4.5f; float distanceToMoon = length(moonDelta); vec4 moonColor = texture(textureAtlas, TransformTextureCoord(moonTexture, (vec2(moonDelta.xy) + 0.5f), moonTextureLayer)); vec4 moon = mix(vec4(0, 0, 0, 1),moonColor, clamp(1 - distanceToMoon * 2.0f, 0, 1)); @@ -54,8 +57,7 @@ vec4 Moon() { } void main() { - vec4 starColor = vec4(0.0f, 0.04f, 0.06f, 1.0f); - color = vec4(mix(starColor, DaySkyColor, dayTime).rgb, 1.0f); + color = vec4(mix(NightSkyColor, DaySkyColor, dayTime).rgb, 1.0f); color += vec4(Sun().rgb, 1.0f); color += vec4(Moon().rgb, 1.0f); normal = vec4(0.0f, 0.0f, 0.0f, 1.0f); -- cgit v1.2.3 From 3f122e57f118db1229a4bad2c54be624f2f8f19c Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 5 Dec 2021 00:51:39 +0500 Subject: Added SSAO --- cwd/assets/altcraft/shaders/frag/sky.fs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cwd/assets/altcraft/shaders/frag/sky.fs') diff --git a/cwd/assets/altcraft/shaders/frag/sky.fs b/cwd/assets/altcraft/shaders/frag/sky.fs index 1e36dd3..65a56ad 100644 --- a/cwd/assets/altcraft/shaders/frag/sky.fs +++ b/cwd/assets/altcraft/shaders/frag/sky.fs @@ -4,12 +4,16 @@ in vec3 facePos; layout (location = 0) out vec4 color; layout (location = 1) out vec4 normal; -layout (location = 2) out vec4 addColor; -layout (location = 3) out vec4 light; +layout (location = 2) out vec4 worldPos; +layout (location = 3) out vec4 addColor; +layout (location = 4) out vec4 light; layout (std140) uniform Globals { mat4 projView; + mat4 proj; + mat4 view; uvec2 viewportSize; + vec4 ssaoKernels[64]; float globalTime; float dayTime; float gamma; @@ -61,6 +65,7 @@ void main() { color += vec4(Sun().rgb, 1.0f); color += vec4(Moon().rgb, 1.0f); normal = vec4(0.0f, 0.0f, 0.0f, 1.0f); + worldPos = vec4(0.0f, 0.0f, 0.0f, 1.0f); addColor = vec4(0.0f, 0.0f, 0.0f, 1.0f); light = vec4(1.0f, 1.0f, 0.0f, 1.0f); } -- cgit v1.2.3 From 9ffe5b9c171e01a4319e6329bb21e6c05ac3e2b4 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 5 Dec 2021 06:44:37 +0500 Subject: Minor shader optimization --- cwd/assets/altcraft/shaders/frag/sky.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cwd/assets/altcraft/shaders/frag/sky.fs') diff --git a/cwd/assets/altcraft/shaders/frag/sky.fs b/cwd/assets/altcraft/shaders/frag/sky.fs index 65a56ad..dc97440 100644 --- a/cwd/assets/altcraft/shaders/frag/sky.fs +++ b/cwd/assets/altcraft/shaders/frag/sky.fs @@ -66,6 +66,6 @@ void main() { color += vec4(Moon().rgb, 1.0f); normal = vec4(0.0f, 0.0f, 0.0f, 1.0f); worldPos = vec4(0.0f, 0.0f, 0.0f, 1.0f); - addColor = vec4(0.0f, 0.0f, 0.0f, 1.0f); + addColor = vec4(1.0f); light = vec4(1.0f, 1.0f, 0.0f, 1.0f); } -- cgit v1.2.3 From be808181b2c84358b232e4a32d1a6dd9dd6659ed Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 11 Dec 2021 20:44:40 +0500 Subject: Optimized GBuffer size --- cwd/assets/altcraft/shaders/frag/sky.fs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cwd/assets/altcraft/shaders/frag/sky.fs') diff --git a/cwd/assets/altcraft/shaders/frag/sky.fs b/cwd/assets/altcraft/shaders/frag/sky.fs index dc97440..f3830b8 100644 --- a/cwd/assets/altcraft/shaders/frag/sky.fs +++ b/cwd/assets/altcraft/shaders/frag/sky.fs @@ -4,13 +4,13 @@ in vec3 facePos; layout (location = 0) out vec4 color; layout (location = 1) out vec4 normal; -layout (location = 2) out vec4 worldPos; -layout (location = 3) out vec4 addColor; -layout (location = 4) out vec4 light; +layout (location = 2) out vec4 addColor; +layout (location = 3) out vec4 light; layout (std140) uniform Globals { mat4 projView; mat4 proj; + mat4 invProj; mat4 view; uvec2 viewportSize; vec4 ssaoKernels[64]; @@ -65,7 +65,7 @@ void main() { color += vec4(Sun().rgb, 1.0f); color += vec4(Moon().rgb, 1.0f); normal = vec4(0.0f, 0.0f, 0.0f, 1.0f); - worldPos = vec4(0.0f, 0.0f, 0.0f, 1.0f); addColor = vec4(1.0f); light = vec4(1.0f, 1.0f, 0.0f, 1.0f); + gl_FragDepth = 1.0f; } -- cgit v1.2.3 From 5721d60db866373dc5718a8af8e63e5377ffd927 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 11 Dec 2021 20:56:17 +0500 Subject: More optimization to GBuffer size --- cwd/assets/altcraft/shaders/frag/sky.fs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'cwd/assets/altcraft/shaders/frag/sky.fs') diff --git a/cwd/assets/altcraft/shaders/frag/sky.fs b/cwd/assets/altcraft/shaders/frag/sky.fs index f3830b8..731246a 100644 --- a/cwd/assets/altcraft/shaders/frag/sky.fs +++ b/cwd/assets/altcraft/shaders/frag/sky.fs @@ -4,8 +4,7 @@ in vec3 facePos; layout (location = 0) out vec4 color; layout (location = 1) out vec4 normal; -layout (location = 2) out vec4 addColor; -layout (location = 3) out vec4 light; +layout (location = 2) out vec4 light; layout (std140) uniform Globals { mat4 projView; @@ -65,7 +64,6 @@ void main() { color += vec4(Sun().rgb, 1.0f); color += vec4(Moon().rgb, 1.0f); normal = vec4(0.0f, 0.0f, 0.0f, 1.0f); - addColor = vec4(1.0f); light = vec4(1.0f, 1.0f, 0.0f, 1.0f); gl_FragDepth = 1.0f; } -- cgit v1.2.3