From 3f14653e536c6c4b4bb9e4d0a6b2ec0dfeadc665 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 21 Nov 2021 19:49:04 +0500 Subject: Added gbuffer visualization --- cwd/assets/altcraft/shaders/frag/light.fs | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'cwd') diff --git a/cwd/assets/altcraft/shaders/frag/light.fs b/cwd/assets/altcraft/shaders/frag/light.fs index 12ab841..6d05884 100644 --- a/cwd/assets/altcraft/shaders/frag/light.fs +++ b/cwd/assets/altcraft/shaders/frag/light.fs @@ -11,18 +11,40 @@ uniform sampler2D light; uniform sampler2D depthStencil; uniform float dayTime; +uniform int renderBuff; void main() { vec4 c = texture(color, uv); vec4 n = texture(normal, uv); vec4 ac = texture(addColor, uv); - vec4 an = texture(light, uv); + vec4 l = texture(light, uv); float d = 1.0f - texture(depthStencil, uv).r; - float faceLight = an.r; - float skyLight = an.g; + float faceLight = l.r; + float skyLight = l.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); + vec4 finalColor = vec4(c.rgb * faceColor, 1.0f); + + switch(renderBuff) { + case 0: + fragColor = finalColor; + break; + case 1: + fragColor = c; + break; + case 2: + fragColor = n; + break; + case 3: + fragColor = ac; + break; + case 4: + fragColor = l; + break; + case 5: + fragColor = vec4(d, d, d, 1.0f); + break; + } } -- cgit v1.2.3