Hello!

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

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;
}
else
{
uv = UV.xy;
}
vec4 c = vec4(texscreen(vec2(uv.x, 1.0 - uv.y)), 1);
COLOR = c;
```

The shader is applied to textureFrame.

- All categories
- Engine 28,063