Have a problem with renderer fisheye effect and raycasting

I’ve added raycaster to intersect my red squares and change cursor style, but it working not properly, ray casted with wrong XY coordinates, any chance to solve this problem ?

Renderer fisheye I’ve provided with effectComposer and distortion texture

Not really. The raycaster doesn’t know anything about the fisheye effect… to make it work, you would have to manually transform your input mouse x/y and ray to account for the distortion, which sounds Really hard and somewhat arbitrary.

1 Like

drei has a fisheye that works with raycasting, try this out (click the spinning cube)

if you want this in vanilla, the math was explained in full detail here How to use THREE.RayCaster with a sphere-projected envmap?

ps. i doubt you can get fisheye with postpro alone. you need a cubecamera because a real fisheye can see the behind. with postpro you may be able to warp your scene a bit but it won’t be close to the result above and you’ll loose detail/resolution in the process. if i was you i’d not bother with that and use cube mapping instead, and then you’ll also have the math necessary to figure out raycast. or, you use three with react and all you need to do is wrap your scene into <Fisheye>, that would certainly be the quickest.

2 Likes

p.s.s. you can do high/full resolution fisheye in post by rendering to a rendertarget that is larger than the viewport… but yeah if drei has a fisheye that handles raycasting… that sounds like a good approach. :slight_smile:

i tried this with @N8Three and we concluded it wasn’t working at least. it’s the view to the behind that’s throwing it off, it has to bend around the fish eye in a full circle. even a wider fov wouldn’t catch that. we eventually gave up trying.

I was referring to regular fisheye distortion like:
image
Also called a “barrel distortion shader”.

You may be thinking of something more extreme like those fisheye go-pros or something:


and yea… eventually you would need a cubemap if the distortion is extreme enough:

2 Likes

i think thats barrel distortion? i did try a couple of distortion shaders, i really liked this one btw Shader - Shadertoy BETA i still wanted to try if i can perhaps merge that with fisheye.

2 Likes

The terms fisheye and barrel distortion are used interchangably:

“Fisheye distortion - commonly found in fisheye lenses, can be seen as an exaggerated form of barrel distortion.”

https://docs.nvidia.com/vpi/algo_ldc.html

https://docs.nvidia.com/vpi/sample_fisheye.html