Debian Codegraph @

examples/viewport_and_scenes/projector/data/shaders/limit_texture.fs

raw
1 /* Limit the texture display to the place where its coordinates are in 0..1 range.
2
3 Pretend the color is 1,1,1,1 (opaque white) for the rest of the texture,
4 so mixing it with existing color calculated by lighting will do nothing.
5
6 See Pascal code of AddEffectToLimitTexture for more comments why this is
7 necessary.
8
9 For information about PLUG_ in shaders, see
10 https://castle-engine.io/compositing_shaders.php
11 and in particular PLUG_texture_color is documented at
12 https://castle-engine.io/compositing_shaders_doc/html/section.fragment_plugs.html
13 */
14
15 void PLUG_texture_color(inout vec4 texture_color,
16 const in sampler2D texture,
17 const in vec4 tex_coord)
18 {
19 vec2 tex_coord_2d = tex_coord.xy / tex_coord.w;
20 if (tex_coord_2d.x < 0.0 ||
21 tex_coord_2d.x > 1.0 ||
22 tex_coord_2d.y < 0.0 ||
23 tex_coord_2d.y > 1.0) {
24 texture_color = vec4(1.0, 1.0, 1.0, 1.0);
25 }
26 }