summaryrefslogtreecommitdiffstats
path: root/src/demos/dualDepthPeeling/shaders
diff options
context:
space:
mode:
authorSven Gothel <sgothel at jausoft dot com>2012-02-15 17:58:41 -0800
committerSven Gothel <sgothel at jausoft dot com>2012-02-15 17:58:41 -0800
commitabe9a0f08f45513017f272d61572421b93e3231a (patch)
tree2c432606acecae867daa509ce08546e7bfc4b111 /src/demos/dualDepthPeeling/shaders
parent0bd5256af8fd791063e08cdd55a365ab4610e21c (diff)
parent9fa9793d462189d946d742f2f95cd1294297119f (diff)
Merge pull request #2 from abokinsky/master
Dual Depth Peeling Dragon Demo
Diffstat (limited to 'src/demos/dualDepthPeeling/shaders')
-rw-r--r--src/demos/dualDepthPeeling/shaders/dual_peeling_blend_fragment.glsl17
-rw-r--r--src/demos/dualDepthPeeling/shaders/dual_peeling_blend_vertex.glsl13
-rw-r--r--src/demos/dualDepthPeeling/shaders/dual_peeling_final_fragment.glsl28
-rw-r--r--src/demos/dualDepthPeeling/shaders/dual_peeling_final_vertex.glsl13
-rw-r--r--src/demos/dualDepthPeeling/shaders/dual_peeling_init_fragment.glsl13
-rw-r--r--src/demos/dualDepthPeeling/shaders/dual_peeling_init_vertex.glsl13
-rw-r--r--src/demos/dualDepthPeeling/shaders/dual_peeling_peel_fragment.glsl67
-rw-r--r--src/demos/dualDepthPeeling/shaders/dual_peeling_peel_vertex.glsl16
-rw-r--r--src/demos/dualDepthPeeling/shaders/front_peeling_blend_fragment.glsl15
-rw-r--r--src/demos/dualDepthPeeling/shaders/front_peeling_blend_vertex.glsl13
-rw-r--r--src/demos/dualDepthPeeling/shaders/front_peeling_final_fragment.glsl17
-rw-r--r--src/demos/dualDepthPeeling/shaders/front_peeling_final_vertex.glsl13
-rw-r--r--src/demos/dualDepthPeeling/shaders/front_peeling_init_fragment.glsl16
-rw-r--r--src/demos/dualDepthPeeling/shaders/front_peeling_init_vertex.glsl16
-rw-r--r--src/demos/dualDepthPeeling/shaders/front_peeling_peel_fragment.glsl25
-rw-r--r--src/demos/dualDepthPeeling/shaders/front_peeling_peel_vertex.glsl16
-rw-r--r--src/demos/dualDepthPeeling/shaders/shade_fragment.glsl40
-rw-r--r--src/demos/dualDepthPeeling/shaders/shade_vertex.glsl14
-rw-r--r--src/demos/dualDepthPeeling/shaders/wavg_final_fragment.glsl29
-rw-r--r--src/demos/dualDepthPeeling/shaders/wavg_final_vertex.glsl13
-rw-r--r--src/demos/dualDepthPeeling/shaders/wavg_init_fragment.glsl19
-rw-r--r--src/demos/dualDepthPeeling/shaders/wavg_init_vertex.glsl16
-rw-r--r--src/demos/dualDepthPeeling/shaders/wsum_final_fragment.glsl18
-rw-r--r--src/demos/dualDepthPeeling/shaders/wsum_final_vertex.glsl13
-rw-r--r--src/demos/dualDepthPeeling/shaders/wsum_init_fragment.glsl16
-rw-r--r--src/demos/dualDepthPeeling/shaders/wsum_init_vertex.glsl16
26 files changed, 505 insertions, 0 deletions
diff --git a/src/demos/dualDepthPeeling/shaders/dual_peeling_blend_fragment.glsl b/src/demos/dualDepthPeeling/shaders/dual_peeling_blend_fragment.glsl
new file mode 100644
index 0000000..3ba7cf9
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/dual_peeling_blend_fragment.glsl
@@ -0,0 +1,17 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Dual Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+uniform samplerRECT TempTex;
+
+void main(void)
+{
+ gl_FragColor = textureRect(TempTex, gl_FragCoord.xy);
+ // for occlusion query
+ if (gl_FragColor.a == 0) discard;
+}
diff --git a/src/demos/dualDepthPeeling/shaders/dual_peeling_blend_vertex.glsl b/src/demos/dualDepthPeeling/shaders/dual_peeling_blend_vertex.glsl
new file mode 100644
index 0000000..1d0edfc
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/dual_peeling_blend_vertex.glsl
@@ -0,0 +1,13 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Dual Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+void main(void)
+{
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+}
diff --git a/src/demos/dualDepthPeeling/shaders/dual_peeling_final_fragment.glsl b/src/demos/dualDepthPeeling/shaders/dual_peeling_final_fragment.glsl
new file mode 100644
index 0000000..ec57117
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/dual_peeling_final_fragment.glsl
@@ -0,0 +1,28 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Dual Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+uniform samplerRECT DepthBlenderTex;
+uniform samplerRECT FrontBlenderTex;
+uniform samplerRECT BackBlenderTex;
+
+void main(void)
+{
+ vec4 frontColor = textureRect(FrontBlenderTex, gl_FragCoord.xy);
+ vec3 backColor = textureRect(BackBlenderTex, gl_FragCoord.xy).rgb;
+ float alphaMultiplier = 1.0 - frontColor.w;
+
+ // front + back
+ gl_FragColor.rgb = frontColor + backColor * alphaMultiplier;
+
+ // front blender
+ //gl_FragColor.rgb = frontColor + vec3(alphaMultiplier);
+
+ // back blender
+ //gl_FragColor.rgb = backColor;
+}
diff --git a/src/demos/dualDepthPeeling/shaders/dual_peeling_final_vertex.glsl b/src/demos/dualDepthPeeling/shaders/dual_peeling_final_vertex.glsl
new file mode 100644
index 0000000..1d0edfc
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/dual_peeling_final_vertex.glsl
@@ -0,0 +1,13 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Dual Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+void main(void)
+{
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+}
diff --git a/src/demos/dualDepthPeeling/shaders/dual_peeling_init_fragment.glsl b/src/demos/dualDepthPeeling/shaders/dual_peeling_init_fragment.glsl
new file mode 100644
index 0000000..1c6234a
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/dual_peeling_init_fragment.glsl
@@ -0,0 +1,13 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Dual Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+void main(void)
+{
+ gl_FragColor.xy = vec2(-gl_FragCoord.z, gl_FragCoord.z);
+}
diff --git a/src/demos/dualDepthPeeling/shaders/dual_peeling_init_vertex.glsl b/src/demos/dualDepthPeeling/shaders/dual_peeling_init_vertex.glsl
new file mode 100644
index 0000000..583aad4
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/dual_peeling_init_vertex.glsl
@@ -0,0 +1,13 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Dual Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+void main(void)
+{
+ gl_Position = ftransform();
+}
diff --git a/src/demos/dualDepthPeeling/shaders/dual_peeling_peel_fragment.glsl b/src/demos/dualDepthPeeling/shaders/dual_peeling_peel_fragment.glsl
new file mode 100644
index 0000000..2d61b89
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/dual_peeling_peel_fragment.glsl
@@ -0,0 +1,67 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Dual Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+#extension ARB_draw_buffers : require
+
+uniform samplerRECT DepthBlenderTex;
+uniform samplerRECT FrontBlenderTex;
+
+#define MAX_DEPTH 1.0
+
+vec4 ShadeFragment();
+
+void main(void)
+{
+ // window-space depth interpolated linearly in screen space
+ float fragDepth = gl_FragCoord.z;
+
+ vec2 depthBlender = textureRect(DepthBlenderTex, gl_FragCoord.xy).xy;
+ vec4 forwardTemp = textureRect(FrontBlenderTex, gl_FragCoord.xy);
+
+ // Depths and 1.0-alphaMult always increase
+ // so we can use pass-through by default with MAX blending
+ gl_FragData[0].xy = depthBlender;
+
+ // Front colors always increase (DST += SRC*ALPHA_MULT)
+ // so we can use pass-through by default with MAX blending
+ gl_FragData[1] = forwardTemp;
+
+ // Because over blending makes color increase or decrease,
+ // we cannot pass-through by default.
+ // Each pass, only one fragment writes a color greater than 0
+ gl_FragData[2] = vec4(0.0);
+
+ float nearestDepth = -depthBlender.x;
+ float farthestDepth = depthBlender.y;
+ float alphaMultiplier = 1.0 - forwardTemp.w;
+
+ if (fragDepth < nearestDepth || fragDepth > farthestDepth) {
+ // Skip this depth in the peeling algorithm
+ gl_FragData[0].xy = vec2(-MAX_DEPTH);
+ return;
+ }
+
+ if (fragDepth > nearestDepth && fragDepth < farthestDepth) {
+ // This fragment needs to be peeled again
+ gl_FragData[0].xy = vec2(-fragDepth, fragDepth);
+ return;
+ }
+
+ // If we made it here, this fragment is on the peeled layer from last pass
+ // therefore, we need to shade it, and make sure it is not peeled any farther
+ vec4 color = ShadeFragment();
+ gl_FragData[0].xy = vec2(-MAX_DEPTH);
+
+ if (fragDepth == nearestDepth) {
+ gl_FragData[1].xyz += color.rgb * color.a * alphaMultiplier;
+ gl_FragData[1].w = 1.0 - alphaMultiplier * (1.0 - color.a);
+ } else {
+ gl_FragData[2] += color;
+ }
+}
diff --git a/src/demos/dualDepthPeeling/shaders/dual_peeling_peel_vertex.glsl b/src/demos/dualDepthPeeling/shaders/dual_peeling_peel_vertex.glsl
new file mode 100644
index 0000000..b49aeff
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/dual_peeling_peel_vertex.glsl
@@ -0,0 +1,16 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Dual Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+vec3 ShadeVertex();
+
+void main(void)
+{
+ gl_Position = ftransform();
+ gl_TexCoord[0].xyz = ShadeVertex();
+}
diff --git a/src/demos/dualDepthPeeling/shaders/front_peeling_blend_fragment.glsl b/src/demos/dualDepthPeeling/shaders/front_peeling_blend_fragment.glsl
new file mode 100644
index 0000000..81385aa
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/front_peeling_blend_fragment.glsl
@@ -0,0 +1,15 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+uniform samplerRECT TempTex;
+
+void main(void)
+{
+ gl_FragColor = textureRect(TempTex, gl_FragCoord.xy);
+}
diff --git a/src/demos/dualDepthPeeling/shaders/front_peeling_blend_vertex.glsl b/src/demos/dualDepthPeeling/shaders/front_peeling_blend_vertex.glsl
new file mode 100644
index 0000000..817857b
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/front_peeling_blend_vertex.glsl
@@ -0,0 +1,13 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+void main(void)
+{
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+}
diff --git a/src/demos/dualDepthPeeling/shaders/front_peeling_final_fragment.glsl b/src/demos/dualDepthPeeling/shaders/front_peeling_final_fragment.glsl
new file mode 100644
index 0000000..dbc9a65
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/front_peeling_final_fragment.glsl
@@ -0,0 +1,17 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+uniform samplerRECT ColorTex;
+uniform vec3 BackgroundColor;
+
+void main(void)
+{
+ vec4 frontColor = textureRect(ColorTex, gl_FragCoord.xy);
+ gl_FragColor.rgb = frontColor + BackgroundColor * frontColor.a;
+}
diff --git a/src/demos/dualDepthPeeling/shaders/front_peeling_final_vertex.glsl b/src/demos/dualDepthPeeling/shaders/front_peeling_final_vertex.glsl
new file mode 100644
index 0000000..817857b
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/front_peeling_final_vertex.glsl
@@ -0,0 +1,13 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+void main(void)
+{
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+}
diff --git a/src/demos/dualDepthPeeling/shaders/front_peeling_init_fragment.glsl b/src/demos/dualDepthPeeling/shaders/front_peeling_init_fragment.glsl
new file mode 100644
index 0000000..fdaaa79
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/front_peeling_init_fragment.glsl
@@ -0,0 +1,16 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+vec4 ShadeFragment();
+
+void main(void)
+{
+ vec4 color = ShadeFragment();
+ gl_FragColor = vec4(color.rgb * color.a, 1.0 - color.a);
+}
diff --git a/src/demos/dualDepthPeeling/shaders/front_peeling_init_vertex.glsl b/src/demos/dualDepthPeeling/shaders/front_peeling_init_vertex.glsl
new file mode 100644
index 0000000..b005d0c
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/front_peeling_init_vertex.glsl
@@ -0,0 +1,16 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+vec3 ShadeVertex();
+
+void main(void)
+{
+ gl_Position = ftransform();
+ gl_TexCoord[0].xyz = ShadeVertex();
+}
diff --git a/src/demos/dualDepthPeeling/shaders/front_peeling_peel_fragment.glsl b/src/demos/dualDepthPeeling/shaders/front_peeling_peel_fragment.glsl
new file mode 100644
index 0000000..7f58b3e
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/front_peeling_peel_fragment.glsl
@@ -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);
+}
diff --git a/src/demos/dualDepthPeeling/shaders/front_peeling_peel_vertex.glsl b/src/demos/dualDepthPeeling/shaders/front_peeling_peel_vertex.glsl
new file mode 100644
index 0000000..b005d0c
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/front_peeling_peel_vertex.glsl
@@ -0,0 +1,16 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Depth Peeling
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+vec3 ShadeVertex();
+
+void main(void)
+{
+ gl_Position = ftransform();
+ gl_TexCoord[0].xyz = ShadeVertex();
+}
diff --git a/src/demos/dualDepthPeeling/shaders/shade_fragment.glsl b/src/demos/dualDepthPeeling/shaders/shade_fragment.glsl
new file mode 100644
index 0000000..94f8dcc
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/shade_fragment.glsl
@@ -0,0 +1,40 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency Fragment Shader
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+uniform float Alpha;
+
+#define COLOR_FREQ 30.0
+#define ALPHA_FREQ 30.0
+
+#if 1
+vec4 ShadeFragment()
+{
+ float xWorldPos = gl_TexCoord[0].x;
+ float yWorldPos = gl_TexCoord[0].y;
+ float diffuse = gl_TexCoord[0].z;
+
+ vec4 color;
+ float i = floor(xWorldPos * COLOR_FREQ);
+ float j = floor(yWorldPos * ALPHA_FREQ);
+ color.rgb = (fmod(i, 2.0) == 0) ? vec3(.4,.85,.0) : vec3(1.0);
+ //color.a = (fmod(j, 2.0) == 0) ? Alpha : 0.2;
+ color.a = Alpha;
+
+ color.rgb *= diffuse;
+ return color;
+}
+#else
+vec4 ShadeFragment()
+{
+ vec4 color;
+ color.rgb = vec3(.4,.85,.0);
+ color.a = Alpha;
+ return color;
+}
+#endif
diff --git a/src/demos/dualDepthPeeling/shaders/shade_vertex.glsl b/src/demos/dualDepthPeeling/shaders/shade_vertex.glsl
new file mode 100644
index 0000000..2f0a4ba
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/shade_vertex.glsl
@@ -0,0 +1,14 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency Vertex Shader
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+vec3 ShadeVertex()
+{
+ float diffuse = abs(normalize(gl_NormalMatrix * gl_Normal).z);
+ return vec3(gl_Vertex.xy, diffuse);
+}
diff --git a/src/demos/dualDepthPeeling/shaders/wavg_final_fragment.glsl b/src/demos/dualDepthPeeling/shaders/wavg_final_fragment.glsl
new file mode 100644
index 0000000..034491c
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/wavg_final_fragment.glsl
@@ -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;
+}
diff --git a/src/demos/dualDepthPeeling/shaders/wavg_final_vertex.glsl b/src/demos/dualDepthPeeling/shaders/wavg_final_vertex.glsl
new file mode 100644
index 0000000..5c07236
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/wavg_final_vertex.glsl
@@ -0,0 +1,13 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Average Color
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+void main(void)
+{
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+}
diff --git a/src/demos/dualDepthPeeling/shaders/wavg_init_fragment.glsl b/src/demos/dualDepthPeeling/shaders/wavg_init_fragment.glsl
new file mode 100644
index 0000000..e50aeb0
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/wavg_init_fragment.glsl
@@ -0,0 +1,19 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Average Color
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+#extension ARB_draw_buffers : require
+
+vec4 ShadeFragment();
+
+void main(void)
+{
+ vec4 color = ShadeFragment();
+ gl_FragData[0] = vec4(color.rgb * color.a, color.a);
+ gl_FragData[1] = vec4(1.0);
+}
diff --git a/src/demos/dualDepthPeeling/shaders/wavg_init_vertex.glsl b/src/demos/dualDepthPeeling/shaders/wavg_init_vertex.glsl
new file mode 100644
index 0000000..3d3d25a
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/wavg_init_vertex.glsl
@@ -0,0 +1,16 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Average Color
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+vec3 ShadeVertex();
+
+void main(void)
+{
+ gl_Position = ftransform();
+ gl_TexCoord[0].xyz = ShadeVertex();
+}
diff --git a/src/demos/dualDepthPeeling/shaders/wsum_final_fragment.glsl b/src/demos/dualDepthPeeling/shaders/wsum_final_fragment.glsl
new file mode 100644
index 0000000..76c0293
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/wsum_final_fragment.glsl
@@ -0,0 +1,18 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Weighted Sums
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+uniform samplerRECT ColorTex;
+uniform vec3 BackgroundColor;
+
+// Sum(A_i * C_i) + C_bg * (1 - Sum(A_i))
+void main(void)
+{
+ vec4 S = textureRect(ColorTex, gl_FragCoord.xy);
+ gl_FragColor.rgb = S.rgb + BackgroundColor * (1.0 - S.a);
+}
diff --git a/src/demos/dualDepthPeeling/shaders/wsum_final_vertex.glsl b/src/demos/dualDepthPeeling/shaders/wsum_final_vertex.glsl
new file mode 100644
index 0000000..8264811
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/wsum_final_vertex.glsl
@@ -0,0 +1,13 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Weighted Sums
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+void main(void)
+{
+ gl_Position = gl_ModelViewMatrix * gl_Vertex;
+}
diff --git a/src/demos/dualDepthPeeling/shaders/wsum_init_fragment.glsl b/src/demos/dualDepthPeeling/shaders/wsum_init_fragment.glsl
new file mode 100644
index 0000000..5cccb14
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/wsum_init_fragment.glsl
@@ -0,0 +1,16 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Weighted Sums
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+vec4 ShadeFragment();
+
+void main(void)
+{
+ vec4 color = ShadeFragment();
+ gl_FragColor = vec4(color.rgb * color.a, color.a);
+}
diff --git a/src/demos/dualDepthPeeling/shaders/wsum_init_vertex.glsl b/src/demos/dualDepthPeeling/shaders/wsum_init_vertex.glsl
new file mode 100644
index 0000000..5445325
--- /dev/null
+++ b/src/demos/dualDepthPeeling/shaders/wsum_init_vertex.glsl
@@ -0,0 +1,16 @@
+//--------------------------------------------------------------------------------------
+// Order Independent Transparency with Weighted Sums
+//
+// Author: Louis Bavoil
+//
+// Copyright (c) NVIDIA Corporation. All rights reserved.
+//--------------------------------------------------------------------------------------
+
+vec3 ShadeVertex();
+
+void main(void)
+{
+ gl_Position = ftransform();
+ gl_TexCoord[0].xyz = ShadeVertex();
+}