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

gpu_shader_compositor_distance_matte.glsl « library « shaders « realtime_compositor « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9beed66826cd870fde8b5aa4d681f19d82c0795f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#pragma BLENDER_REQUIRE(gpu_shader_common_color_utils.glsl)

void node_composite_distance_matte_rgba(
    vec4 color, vec4 key, float tolerance, float falloff, out vec4 result, out float matte)
{
  float difference = distance(color.rgb, key.rgb);
  bool is_opaque = difference > tolerance + falloff;
  float alpha = is_opaque ? color.a : max(0.0, difference - tolerance) / falloff;
  matte = min(alpha, color.a);
  result = color * matte;
}

void node_composite_distance_matte_ycca(
    vec4 color, vec4 key, float tolerance, float falloff, out vec4 result, out float matte)
{
  vec4 color_ycca;
  rgba_to_ycca_itu_709(color, color_ycca);
  vec4 key_ycca;
  rgba_to_ycca_itu_709(key, key_ycca);

  float difference = distance(color_ycca.yz, key_ycca.yz);
  bool is_opaque = difference > tolerance + falloff;
  float alpha = is_opaque ? color.a : max(0.0, difference - tolerance) / falloff;
  matte = min(alpha, color.a);
  result = color * matte;
}