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:
authorAntonio Vazquez <blendergit@gmail.com>2022-11-07 18:09:54 +0300
committerAntonio Vazquez <blendergit@gmail.com>2022-11-07 18:09:54 +0300
commitb6b888f7fb706487d9e5ae6b0738201da5493b9f (patch)
tree852f79b4532a1b93e75c2541ca0d181b00de08a2 /source/blender/compositor/realtime_compositor/shaders/compositor_box_mask.glsl
parenta2377b60548f2fe5d46b14ecdf4cf83971432b5c (diff)
parent95631c94c4bd08f8a7e9c713f624e934eb7eb7ae (diff)
Merge branch 'master' into gpencil-new-data-proposalgpencil-new-data-proposal
Diffstat (limited to 'source/blender/compositor/realtime_compositor/shaders/compositor_box_mask.glsl')
-rw-r--r--source/blender/compositor/realtime_compositor/shaders/compositor_box_mask.glsl27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/compositor/realtime_compositor/shaders/compositor_box_mask.glsl b/source/blender/compositor/realtime_compositor/shaders/compositor_box_mask.glsl
new file mode 100644
index 00000000000..fad23f28fde
--- /dev/null
+++ b/source/blender/compositor/realtime_compositor/shaders/compositor_box_mask.glsl
@@ -0,0 +1,27 @@
+#pragma BLENDER_REQUIRE(gpu_shader_compositor_texture_utilities.glsl)
+
+void main()
+{
+ ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
+
+ vec2 uv = vec2(texel) / vec2(domain_size - ivec2(1));
+ uv -= location;
+ uv.y *= float(domain_size.y) / float(domain_size.x);
+ uv = mat2(cos_angle, -sin_angle, sin_angle, cos_angle) * uv;
+ bool is_inside = all(lessThan(abs(uv), size));
+
+ float base_mask_value = texture_load(base_mask_tx, texel).x;
+ float value = texture_load(mask_value_tx, texel).x;
+
+#if defined(CMP_NODE_MASKTYPE_ADD)
+ float output_mask_value = is_inside ? max(base_mask_value, value) : base_mask_value;
+#elif defined(CMP_NODE_MASKTYPE_SUBTRACT)
+ float output_mask_value = is_inside ? clamp(base_mask_value - value, 0.0, 1.0) : base_mask_value;
+#elif defined(CMP_NODE_MASKTYPE_MULTIPLY)
+ float output_mask_value = is_inside ? base_mask_value * value : 0.0;
+#elif defined(CMP_NODE_MASKTYPE_NOT)
+ float output_mask_value = is_inside ? (base_mask_value > 0.0 ? 0.0 : value) : base_mask_value;
+#endif
+
+ imageStore(output_mask_img, texel, vec4(output_mask_value));
+}