diff options
author | LaG1924 <lag1924@gmail.com> | 2021-11-28 12:16:29 +0100 |
---|---|---|
committer | LaG1924 <lag1924@gmail.com> | 2021-11-28 12:16:29 +0100 |
commit | 8286ddda96a5f2925d342d0ce115aa00ae5d94ec (patch) | |
tree | aa46a01fb6230a5c994046c7b4823ae1b35c2c37 /cwd/assets/altcraft/shaders/frag/sky.fs | |
parent | Changed shaders to use SPB (diff) | |
download | AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar.gz AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar.bz2 AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar.lz AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar.xz AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.tar.zst AltCraft-8286ddda96a5f2925d342d0ce115aa00ae5d94ec.zip |
Diffstat (limited to 'cwd/assets/altcraft/shaders/frag/sky.fs')
-rw-r--r-- | cwd/assets/altcraft/shaders/frag/sky.fs | 14 |
1 files changed, 8 insertions, 6 deletions
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); |