This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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

in Engine by (85 points)

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

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

1 Answer

0 votes

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;
  uv = UV.xy;

vec4 c = vec4(texscreen(vec2(uv.x, 1.0 - uv.y)), 1);
COLOR = c;

The shader is applied to textureFrame.

by (85 points)

Hi, which textureframe should it be applied to?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.