diff options
Diffstat (limited to '')
-rw-r--r-- | cwd/assets/altcraft/shaders/frag/face.fs | 19 | ||||
-rw-r--r-- | cwd/assets/altcraft/shaders/frag/light.fs | 16 | ||||
-rw-r--r-- | cwd/assets/altcraft/shaders/frag/sky.fs | 14 |
3 files changed, 35 insertions, 14 deletions
diff --git a/cwd/assets/altcraft/shaders/frag/face.fs b/cwd/assets/altcraft/shaders/frag/face.fs index 2120697..57ea0ec 100644 --- a/cwd/assets/altcraft/shaders/frag/face.fs +++ b/cwd/assets/altcraft/shaders/frag/face.fs @@ -1,21 +1,24 @@ #version 330 core -in VS_OUT { - vec3 Texture; - vec3 Color; - vec3 faceNormal; -} fs_in; +in vec3 faceTexture; +in vec3 faceAddColor; +in vec3 faceNormal; +in vec2 faceLight; 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; void main() { - vec4 col = texture(textureAtlas, fs_in.Texture); + vec4 col = texture(textureAtlas, faceTexture); if (col.a < 0.3) discard; - color = vec4(col.rgb * fs_in.Color, 1.0f); - normal = vec4(fs_in.faceNormal, 1.0f); + color = vec4(col.rgb, 1.0f); + normal = vec4(faceNormal, 1.0f); + addColor = vec4(faceAddColor, 1.0f); + light = vec4(faceLight / 15.0f, 0.0f, 1.0f); } diff --git a/cwd/assets/altcraft/shaders/frag/light.fs b/cwd/assets/altcraft/shaders/frag/light.fs index 73686cc..12ab841 100644 --- a/cwd/assets/altcraft/shaders/frag/light.fs +++ b/cwd/assets/altcraft/shaders/frag/light.fs @@ -6,11 +6,23 @@ in vec2 uv; uniform sampler2D color; uniform sampler2D normal; +uniform sampler2D addColor; +uniform sampler2D light; uniform sampler2D depthStencil; +uniform float dayTime; + void main() { vec4 c = texture(color, uv); vec4 n = texture(normal, uv); - float d = texture(depthStencil, uv).r; - fragColor = n; + vec4 ac = texture(addColor, uv); + vec4 an = texture(light, uv); + float d = 1.0f - texture(depthStencil, uv).r; + + float faceLight = an.r; + float skyLight = an.g; + float lightLevel = clamp(faceLight + skyLight * dayTime, 0.2f, 1.0f); + vec3 faceColor = mix(ac.rgb * lightLevel, vec3(1,1,1) * lightLevel, float(ac.rgb == vec3(0,0,0))); + + fragColor = vec4(c.rgb * faceColor, 1.0f); } 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); } |