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/modes/shaders/object_outline_expand_frag.glsl')
-rw-r--r--source/blender/draw/modes/shaders/object_outline_expand_frag.glsl45
1 files changed, 45 insertions, 0 deletions
diff --git a/source/blender/draw/modes/shaders/object_outline_expand_frag.glsl b/source/blender/draw/modes/shaders/object_outline_expand_frag.glsl
new file mode 100644
index 00000000000..e0568d1157a
--- /dev/null
+++ b/source/blender/draw/modes/shaders/object_outline_expand_frag.glsl
@@ -0,0 +1,45 @@
+
+in vec4 uvcoordsvar;
+
+out vec4 FragColor;
+
+uniform sampler2D outlineColor;
+uniform sampler2D outlineDepth;
+
+uniform float alpha;
+uniform bool doExpand;
+
+void search_outline(ivec2 uv, inout bool found_edge)
+{
+ if (!found_edge) {
+ vec4 color = texelFetch(outlineColor, uv, 0).rgba;
+ if (color.a != 0.0) {
+ if (doExpand || color.a != 1.0) {
+ FragColor = color;
+ found_edge = true;
+ }
+ }
+ }
+}
+
+void main()
+{
+ ivec2 uv = ivec2(gl_FragCoord.xy);
+ FragColor = texelFetch(outlineColor, uv, 0).rgba;
+ float depth = texelFetch(outlineDepth, uv, 0).r;
+
+ if (FragColor.a != 0.0 || (depth == 1.0 && !doExpand))
+ return;
+
+ bool found_edge = false;
+ search_outline(uv + ivec2( 1, 0), found_edge);
+ search_outline(uv + ivec2( 0, 1), found_edge);
+ search_outline(uv + ivec2(-1, 0), found_edge);
+ search_outline(uv + ivec2( 0, -1), found_edge);
+
+ /* We Hit something ! */
+ if (found_edge) {
+ /* only change alpha */
+ FragColor.a *= alpha;
+ }
+}