armory/Shaders/translucent_resolve/translucent_resolve.frag.glsl

26 lines
566 B
Plaintext
Raw Permalink Normal View History

2016-05-27 01:12:21 +02:00
// Weighted blended OIT by McGuire and Bavoil
#version 450
#include "compiled.inc"
2018-06-28 16:26:15 +02:00
2019-01-08 15:46:24 +01:00
uniform sampler2D gbuffer0; // accum
uniform sampler2D gbuffer1; // revealage
2016-05-27 01:12:21 +02:00
2018-05-17 22:47:00 +02:00
uniform vec2 texSize;
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() {
2018-11-27 21:34:42 +01:00
vec4 accum = texelFetch(gbuffer0, ivec2(texCoord * texSize), 0);
2018-05-17 22:47:00 +02:00
float revealage = 1.0 - accum.a;
2018-05-17 22:47:00 +02:00
// Save the blending and color texture fetch cost
2018-05-19 14:35:00 +02:00
if (revealage == 0.0) {
discard;
2018-06-28 16:26:15 +02:00
}
2016-11-24 17:35:12 +01:00
2018-11-27 21:34:42 +01:00
float f = texelFetch(gbuffer1, ivec2(texCoord * texSize), 0).r;
2019-01-24 12:47:51 +01:00
fragColor = vec4(accum.rgb / clamp(f, 0.0001, 5000), revealage);
2016-05-27 01:12:21 +02:00
}