2016-05-27 01:12:21 +02:00
|
|
|
// Weighted blended OIT by McGuire and Bavoil
|
|
|
|
#version 450
|
|
|
|
|
|
|
|
#ifdef GL_ES
|
|
|
|
precision mediump float;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// uniform sampler2D gbufferD;
|
2016-08-13 20:38:45 +02:00
|
|
|
uniform sampler2D saccum; // accumTexture
|
|
|
|
uniform sampler2D srevealage; // revealageTexture
|
2016-05-27 01:12:21 +02:00
|
|
|
|
|
|
|
in vec2 texCoord;
|
2016-08-13 20:38:45 +02:00
|
|
|
out vec4 outColor;
|
2016-05-27 01:12:21 +02:00
|
|
|
|
|
|
|
void main() {
|
2016-08-13 20:38:45 +02:00
|
|
|
vec4 accum = texture(saccum, 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) {
|
|
|
|
// Save the blending and color texture fetch cost
|
2016-08-13 20:38:45 +02:00
|
|
|
discard;
|
2016-05-27 01:12:21 +02:00
|
|
|
}
|
|
|
|
|
2016-08-13 20:38:45 +02:00
|
|
|
float accumA = texture(srevealage, texCoord).r;
|
2016-05-27 01:12:21 +02:00
|
|
|
|
2016-08-13 20:38:45 +02:00
|
|
|
// outColor = vec4(accum.rgb / clamp(accum.a, 1e-4, 5e4), revealage);
|
2016-05-27 01:12:21 +02:00
|
|
|
|
|
|
|
const float epsilon = 0.00001;
|
2016-08-13 20:38:45 +02:00
|
|
|
outColor = vec4(accum.rgb / max(accumA, epsilon), 1.0 - revealage);
|
2016-05-27 01:12:21 +02:00
|
|
|
}
|