summaryrefslogtreecommitdiffstats
path: root/cwd/shaders/sky.fs
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-08-05 02:15:12 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-08-05 02:15:12 +0200
commitcc3096b4f4649915cf89a5bc4f6b943d667369f5 (patch)
tree4de6e88338b65f3c66c2fdea29a067ec042012d2 /cwd/shaders/sky.fs
parentReplaced usage of old texture atlas (diff)
downloadAltCraft-cc3096b4f4649915cf89a5bc4f6b943d667369f5.tar
AltCraft-cc3096b4f4649915cf89a5bc4f6b943d667369f5.tar.gz
AltCraft-cc3096b4f4649915cf89a5bc4f6b943d667369f5.tar.bz2
AltCraft-cc3096b4f4649915cf89a5bc4f6b943d667369f5.tar.lz
AltCraft-cc3096b4f4649915cf89a5bc4f6b943d667369f5.tar.xz
AltCraft-cc3096b4f4649915cf89a5bc4f6b943d667369f5.tar.zst
AltCraft-cc3096b4f4649915cf89a5bc4f6b943d667369f5.zip
Diffstat (limited to 'cwd/shaders/sky.fs')
-rw-r--r--cwd/shaders/sky.fs13
1 files changed, 8 insertions, 5 deletions
diff --git a/cwd/shaders/sky.fs b/cwd/shaders/sky.fs
index 23f6ada..36d65a5 100644
--- a/cwd/shaders/sky.fs
+++ b/cwd/shaders/sky.fs
@@ -3,10 +3,12 @@
in vec2 uvPos;
in vec3 pos;
-uniform sampler2D textureAtlas;
+uniform sampler2DArray textureAtlas;
uniform float DayTime;
uniform vec4 sunTexture;
+uniform float sunTextureLayer;
uniform vec4 moonTexture;
+uniform float moonTextureLayer;
const vec4 DaySkyColor = vec4(0.49,0.66,1, 1);
@@ -14,20 +16,21 @@ const vec3 SunPos = vec3(0,0.1,0.5);
const vec3 MoonPos = vec3(0,0.1,-0.5);
-vec2 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords) {
+vec3 TransformTextureCoord(vec4 TextureAtlasCoords, vec2 UvCoords, float Layer) {
float x = TextureAtlasCoords.x;
float y = TextureAtlasCoords.y;
float w = TextureAtlasCoords.z;
float h = TextureAtlasCoords.w;
vec2 A = vec2(x, 1 - y - h);
vec2 B = vec2(x + w, 1 - y);
- return A + UvCoords * (B - A);
+ vec2 transformed = A + UvCoords * (B - A);
+ return vec3(transformed.x, transformed.y, Layer);
}
vec4 Sun() {
vec3 sunDelta = (pos - SunPos)*3.0f;
float distanceToSun = length(sunDelta);
- vec4 sunColor = texture(textureAtlas,TransformTextureCoord(sunTexture,(vec2(sunDelta.xy)+0.5f)));
+ 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));
return sun;
}
@@ -35,7 +38,7 @@ vec4 Sun() {
vec4 Moon() {
vec3 moonDelta = (pos - MoonPos)*4.5f;
float distanceToMoon = length(moonDelta);
- vec4 moonColor = texture(textureAtlas,TransformTextureCoord(moonTexture,(vec2(moonDelta.xy)+0.5f)));
+ 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));
return moon;
}