1 #ifndef R2_REFRACTION_H 2 #define R2_REFRACTION_H 32 const vec4 position_here_clip,
35 vec3 delta_scaled = delta * refraction.
scale;
37 vec3 position_here_ndc = vec3 (position_here_clip.xyz / position_here_clip.w);
38 vec2 position_here_uv = (position_here_ndc.xy + 1.0) * 0.5;
40 vec3 position_there_ndc = position_here_ndc + delta_scaled;
41 vec2 position_there_uv = (position_there_ndc.xy + 1.0) * 0.5;
43 vec4 scene_there = texture (refraction.
scene, position_there_uv);
44 float mask = texture (refraction.
mask, position_there_uv).x;
45 vec4 scene_here = texture (refraction.
scene, position_here_uv);
47 return mix (scene_here, scene_there, mask) * vec4 (refraction.
color, 1.0);
50 #endif // R2_REFRACTION_H
sampler2D mask
An image to mask sampling to avoid bleeding.
float scale
A scaling values for sampled refraction values.
vec3 color
A color by which to multiply the final refracted image.
vec4 R2_refractionMasked(const R2_refraction_t refraction, const vec4 position_here_clip, const vec3 delta)