readme
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 TexCoord;
|
||||
|
||||
uniform sampler2D gPosition;
|
||||
uniform sampler2D gNormal;
|
||||
uniform sampler2D gAlbedo;
|
||||
uniform sampler2D gMaterial;
|
||||
uniform sampler2D depthTex;
|
||||
uniform sampler2D shadowTex;
|
||||
uniform sampler2D bloomTex;
|
||||
|
||||
uniform float nearPlane;
|
||||
uniform float farPlane;
|
||||
|
||||
uniform int debugMode; // 1 = position, 2 = normal, 3 = albedo, 4 = material, 5 = depth, 6 = shadow map, 7 = bloom
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
if (debugMode == 1) {
|
||||
vec3 v = texture(gPosition, TexCoord).rgb;
|
||||
FragColor = vec4(v * 0.01 + 0.5, 1.0);
|
||||
}
|
||||
else if (debugMode == 2) {
|
||||
vec3 n = texture(gNormal, TexCoord).rgb;
|
||||
if (length(n) >= 0.1)
|
||||
FragColor = vec4(normalize(n) * 0.5 + 0.5, 1.0);
|
||||
}
|
||||
else if (debugMode == 3) {
|
||||
FragColor = vec4(pow(texture(gAlbedo, TexCoord).rgb, vec3(1.0 / 2.2)), 1.0);
|
||||
}
|
||||
else if (debugMode == 4) {
|
||||
FragColor = vec4(texture(gMaterial, TexCoord).rgb, 1.0);
|
||||
}
|
||||
else if (debugMode == 5) {
|
||||
// Perspective depth is nearly 1.0 everywhere, so linearize it and spread it out
|
||||
float z = texture(depthTex, TexCoord).r * 2.0 - 1.0;
|
||||
float linearDepth = (2.0 * nearPlane * farPlane) / (farPlane + nearPlane - z * (farPlane - nearPlane));
|
||||
float d = log(1.0 + linearDepth) / log(1.0 + farPlane);
|
||||
FragColor = vec4(vec3(d), 1.0);
|
||||
}
|
||||
else if (debugMode == 6) {
|
||||
FragColor = vec4(vec3(texture(shadowTex, TexCoord).r), 1.0);
|
||||
}
|
||||
else if (debugMode == 7) {
|
||||
FragColor = vec4(texture(bloomTex, TexCoord).rgb, 1.0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user