Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders/workbench_transparent_resolve_frag.glsl')
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_transparent_resolve_frag.glsl26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_transparent_resolve_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_transparent_resolve_frag.glsl
new file mode 100644
index 00000000000..d985737a35b
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_transparent_resolve_frag.glsl
@@ -0,0 +1,26 @@
+
+uniform sampler2D transparentAccum;
+uniform sampler2D transparentRevealage;
+
+in vec4 uvcoordsvar;
+
+out vec4 fragColor;
+
+/* Based on :
+ * McGuire and Bavoil, Weighted Blended Order-Independent Transparency, Journal of
+ * Computer Graphics Techniques (JCGT), vol. 2, no. 2, 122–141, 2013
+ */
+
+void main()
+{
+ /* Revealage is actually stored in transparentAccum alpha channel.
+ * This is a workaround to older hardware not having separate blend equation per render target.
+ */
+ vec4 trans_accum = texture(transparentAccum, uvcoordsvar.st);
+ float trans_weight = texture(transparentRevealage, uvcoordsvar.st).r;
+ float trans_reveal = trans_accum.a;
+
+ /* Listing 4 */
+ fragColor.rgb = trans_accum.rgb / clamp(trans_weight, 1e-4, 5e4);
+ fragColor.a = 1.0 - trans_reveal;
+}