summaryrefslogtreecommitdiffstats
path: root/src/demos/dualDepthPeeling/shaders/front_peeling_peel.fp
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos/dualDepthPeeling/shaders/front_peeling_peel.fp')
-rw-r--r--src/demos/dualDepthPeeling/shaders/front_peeling_peel.fp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/demos/dualDepthPeeling/shaders/front_peeling_peel.fp b/src/demos/dualDepthPeeling/shaders/front_peeling_peel.fp
new file mode 100644
index 0000000..7f58b3e
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/front_peeling_peel.fp
@@ -0,0 +1,25 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+uniform samplerRECT DepthTex;
+
+vec4 ShadeFragment();
+
+void main(void)
+{
+ // Bit-exact comparison between FP32 z-buffer and fragment depth
+ float frontDepth = textureRect(DepthTex, gl_FragCoord.xy).r;
+ if (gl_FragCoord.z <= frontDepth) {
+ discard;
+ }
+
+ // Shade all the fragments behind the z-buffer
+ vec4 color = ShadeFragment();
+ gl_FragColor = vec4(color.rgb * color.a, color.a);
+}