Fish eye effect in 3D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Kovalski
:warning: Old Version Published before Godot 3 was released.

Hello!
I wanna make fish eye effect in 3D. How I can make this?

Have tried to play with camera properties ?
Fovy, etc…

Omicron | 2017-06-25 17:40

No it’s not that. Possible I know the way, how to do it in 2D mode. For example: Simple CRT Shader for 2D.

Kovalski | 2017-06-25 20:00

:bust_in_silhouette: Reply From: Kovalski

I know answer on this question. Get code who needs.

uniform float PI = 3.1415926535;

float aperture = 178.0;
float apertureHalf = 0.5 * aperture * (PI / 180.0);
float maxFactor = sin(apertureHalf);
vec2 uv;
vec2 xy = 2.0 * UV.xy - vec2(1.0, 1.0);
float d = length(xy);
if (d < (2.0-maxFactor))
{
    d = length(xy * maxFactor);
    float z = sqrt(1.0 - d * d);
    float r = atan2(d, z) / PI;
    float phi = atan2(xy.y, xy.x);

    uv.x = r * cos(phi) + 0.5;
    uv.y = r * sin(phi) + 0.5;
}
else
{
  uv = UV.xy;
}
vec4 c = vec4(texscreen(vec2(uv.x, 1.0 - uv.y)), 1);
COLOR = c;

The shader is applied to textureFrame.

Hi, which textureframe should it be applied to?

dodgyville | 2018-02-02 01:03