armory/Shaders/translucent_resolve/translucent_resolve.frag.glsl

29 lines
692 B
Plaintext
Raw Normal View History

2016-05-27 01:12:21 +02:00
// Weighted blended OIT by McGuire and Bavoil
#version 450
uniform sampler2D gbufferD;
uniform sampler2D gbuffer0; // saccum
uniform sampler2D gbuffer1; // srevealage
2016-05-27 01:12:21 +02:00
in vec2 texCoord;
2016-10-12 17:52:27 +02:00
out vec4 fragColor;
2016-05-27 01:12:21 +02:00
void main() {
vec4 accum = texture(gbuffer0, texCoord);
2016-05-27 09:46:35 +02:00
float revealage = accum.a;
2016-05-27 01:12:21 +02:00
if (revealage == 1.0) {
2016-10-17 17:39:40 +02:00
// Save the blending and color texture fetch cost
discard;
}
2016-05-27 01:12:21 +02:00
2016-11-24 17:35:12 +01:00
accum.a = texture(gbuffer1, texCoord).r;
2016-05-27 01:12:21 +02:00
2016-10-12 17:52:27 +02:00
// fragColor = vec4(accum.rgb / clamp(accum.a, 1e-4, 5e4), revealage);
2016-05-27 01:12:21 +02:00
2016-11-24 17:35:12 +01:00
// const float epsilon = 0.00001;
// fragColor = vec4(accum.rgb / max(accum.a, epsilon), 1.0 - revealage);
fragColor = vec4(accum.rgb / clamp(accum.a, 1e-4, 5e4), 1.0 - revealage);
2016-05-27 01:12:21 +02:00
}