diff options
author | Juan Linietsky <reduzio@gmail.com> | 2020-04-14 17:05:45 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-04-14 17:05:45 -0300 |
commit | 6f293ed7958d56fb4a8033f04e5ef59e037d2ae7 (patch) | |
tree | 5facee58c1dc6ede57f1b8ef3c0c0effed927103 /servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl | |
parent | 5e5103f460f406899582e4307e56882401fd37d5 (diff) |
Add support for projectors in spot and omni lights.
Diffstat (limited to 'servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl')
-rw-r--r-- | servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl b/servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl index 0f8688ee34..07f8d09743 100644 --- a/servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl +++ b/servers/rendering/rasterizer_rd/shaders/copy_to_fb.glsl @@ -65,6 +65,34 @@ layout(location = 0) out vec4 frag_color; void main() { vec2 uv = uv_interp; + +#ifdef MODE_PANORAMA_TO_DP + + //obtain normal from dual paraboloid uv +#define M_PI 3.14159265359 + + float side; + uv.y = modf(uv.y * 2.0, side); + side = side * 2.0 - 1.0; + vec3 normal = vec3(uv * 2.0 - 1.0, 0.0); + normal.z = 0.5 - 0.5 * ((normal.x * normal.x) + (normal.y * normal.y)); + normal *= -side; + normal = normalize(normal); + + //now convert normal to panorama uv + + vec2 st = vec2(atan(normal.x, normal.z), acos(normal.y)); + + if (st.x < 0.0) + st.x += M_PI * 2.0; + + uv = st / vec2(M_PI * 2.0, M_PI); + + if (side < 0.0) { + //uv.y = 1.0 - uv.y; + uv = 1.0 - uv; + } +#endif vec4 color = textureLod(source_color, uv, 0.0); if (params.force_luminance) { color.rgb = vec3(max(max(color.r, color.g), color.b)); |