summaryrefslogtreecommitdiffstats
path: root/src/demos/dualDepthPeeling/shader/wavg_final.fp
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/dualDepthPeeling/shader/wavg_final.fp')
-rw-r--r--src/demos/dualDepthPeeling/shader/wavg_final.fp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/demos/dualDepthPeeling/shader/wavg_final.fp b/src/demos/dualDepthPeeling/shader/wavg_final.fp
new file mode 100644
index 0000000..034491c
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shader/wavg_final.fp
@@ -0,0 +1,29 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Average Color
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+uniform samplerRECT ColorTex0;
+uniform samplerRECT ColorTex1;
+uniform vec3 BackgroundColor;
+
+void main(void)
+{
+ vec4 SumColor = textureRect(ColorTex0, gl_FragCoord.xy);
+ float n = textureRect(ColorTex1, gl_FragCoord.xy).r;
+
+ if (n == 0.0) {
+ gl_FragColor.rgb = BackgroundColor;
+ return;
+ }
+
+ vec3 AvgColor = SumColor.rgb / SumColor.a;
+ float AvgAlpha = SumColor.a / n;
+
+ float T = pow(1.0-AvgAlpha, n);
+ gl_FragColor.rgb = AvgColor * (1 - T) + BackgroundColor * T;
+}