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:
authorOmar Emara <mail@OmarEmara.dev>2022-09-02 15:47:39 +0300
committerOmar Emara <mail@OmarEmara.dev>2022-09-02 15:47:39 +0300
commit633117669bcec0f5320cb88443d12b6661bc4886 (patch)
tree1203af1a388023c1b870875af4bcc69e83ab8dea /source/blender/gpu/shaders/compositor/library
parent8cfca8e1bd85a300732d92b30741d5c243797a31 (diff)
Realtime Compositor: Implement dilate erode node
This patch implements the dilate/erode node for the realtime compositor. Differential Revision: https://developer.blender.org/D15790 Reviewed By: Clement Foucault
Diffstat (limited to 'source/blender/gpu/shaders/compositor/library')
-rw-r--r--source/blender/gpu/shaders/compositor/library/gpu_shader_compositor_texture_utilities.glsl10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/compositor/library/gpu_shader_compositor_texture_utilities.glsl b/source/blender/gpu/shaders/compositor/library/gpu_shader_compositor_texture_utilities.glsl
index 00e9a391097..128fc6aeaf5 100644
--- a/source/blender/gpu/shaders/compositor/library/gpu_shader_compositor_texture_utilities.glsl
+++ b/source/blender/gpu/shaders/compositor/library/gpu_shader_compositor_texture_utilities.glsl
@@ -23,3 +23,13 @@ vec4 texture_load(sampler2D sampler, ivec2 texel)
const ivec2 texture_bounds = texture_size(sampler) - ivec2(1);
return texelFetch(sampler, clamp(texel, ivec2(0), texture_bounds), 0);
}
+
+/* A shorthand for 2D texelFetch with zero LOD and a fallback value for out-of-bound access. */
+vec4 texture_load(sampler2D sampler, ivec2 texel, vec4 fallback)
+{
+ const ivec2 texture_bounds = texture_size(sampler) - ivec2(1);
+ if (any(lessThan(texel, ivec2(0))) || any(greaterThan(texel, texture_bounds))) {
+ return fallback;
+ }
+ return texelFetch(sampler, texel, 0);
+}