I'm not sure if or how you could get hardware to calculate the perspective like that
I'm pretty sure this would be simple with a vertex shader. Taj will know for positive.
Jim
Lunchtime! OK, first off check out this demo by FR. It has an interactive bit at the end you can use to explore the perspective using the mouse.
http://www.pouet.net/prod.php?which=27000It uses polar mapping, a variation on your fish-eye distortion. Although they don't provide shaders, I'm pretty sure of what they are doing. The distortion would be done like this:
Pass 1:
1. Render the scene to texture using FBOs or render to back buffer and copy into texture
Pass 2:
2. Bind the texture you just created.
3. Enable a shader to do the distortion
- this is a pixel shader, it reads from the texture.
- the texel it reads depends on screen position *and* a distort equation
4. Draw a full screen quad
If you look closely you can see at the top and bottom of the demo from FR this is what they are doing. You can see the texels being stretched - there is no geometry distortion here. Using a vertex shader to distort triangles will only work if the triangles are very small and even then I mean in screen space, not world space which is incredibly hard to guarantee.
This seems like it shouldn't work because you can't use Z when you do pass 2. Although I can't prove this, I will offer justification why you dont need Z in pass 2. In essence Pass 1, normal rendering, projects a point in space into the screen depending on its Z co-ordinate. In other words the image after pass 1 has the Z "encoded" in it simply by the pixels that things project to. You then, in pass 2 , are applying a transformation of this Z to get a different perspective simply by mapping the pixels in the first image to the second image with the distortion equation.
Its essentially an oldskool lens effect!
Taj