Godot Version
Godot 4.5
Question
I am trying to recreate the reflex lens spherical levels like sonic x-treme using a vertex shader but i dont know how anybody can create a mesh deformation shader that recreates the fisheye lens in sonic x-tremehere is an example video https://youtu.be/XAv-gNaBn_w
Unlikely that any mesh deformation is happening here.
I’d render half of a cubemap and then sample it in a post processing fragment shader using real or approximated fisheye projection. This will require a bit of setup; 3 perpendicular cameras rendering into 3 viewports, then those 3 viewports textures are assembled into a cubemap layout in another viewport. This is then plugged into a post processing shader running on a full screen plane, and sampled as a cubemap texture.
I’m guessing it could be simplified down to a single very wide viewing angle camera and some fake fisheye warping of that. This wouldn’t look as good as multiple cameras but may be worth trying as it’s much simpler to do.
I am doing this with a gridmap
It doesn’t matter. It’s a rendering effect, it doesn’t involve actual geometry deformation.
i dont know how to do that
Well then maybe you should make a game without that effect.
This is the best I could squeeze out of one camera without proper cubemap sampling. It’s probably similar to how they’ve done it in sonic, given the hardware, although there might be a slight chance that they actually used multiple cameras.
So:
- render into viewport using a very wide lens camera. I used 160 deg fov here.
- run a fullscreen 2d shader and sample the viewport texture with warped UVs
shader_type canvas_item;
void fragment() {
vec2 dvec = UV - vec2(0.5);
float d = length(dvec);
float deform = tan(d * PI / sqrt(2.0)) / TAU;
vec2 uv = vec2(0.5) + normalize(dvec) * deform;
COLOR = texture(TEXTURE, uv);
}
The effect can be tuned by changing camera fov and sampling domain

1 Like