Here it comes
Instead of the usual projection modes, parallel projection and perspective projection, why not use this:
divide X coordinate of a vertex in real space by sqrt(sqr(x)+sqr(y)+sqr(z)) then divide the Y coordinate of the same vertex by the same monster,(the rest is familiar) then multiply the results by the H and Vertical scales respectively, center the X and Y screen coordinates by adding half the x resolution and half the Y resolution respectively and finaly rasterize by either truncating or rounding the results and draw to screen and see what happens. You get the same view as when you would place an opaque reflective sphere in front of a real camera. The only difference is that this is not a reflexion. You've just applied zoom lens simulation to your 3D software engine. You could also divide by a constant to srink the zoom effect. This must be done for every pixel in the frame, obviously. So it will slow things down A LOT. Ray tracing is the only way to go with this thing though I'm not sure even this would work, I have only tried this on my wireframe engine on the endpoint vertexes, for testing purposes only. Even if it can be done using ray tracing, I'm working on it, you must reduce overdraw if you have any hope of using this tehnique, so Z-buffer is out of the question. I've yet to see the simplest little cube be rendered this way and people spend so much time on stuff that is not nearly as exciting and challenging. Maybe this is just a stupid idea and what should be done is simulate a magnifying glass effect on the finished frame, stored in memory, before drawing. This way is probably worse than what I've detailed before. Maybe it will be totally devoid of realism, maybe not. Trouble is, I haven't started developing an algo. for this yet so I can only vouch for the first variant. I must tell you, even though the lines themselves are not altered by this tpe of projection, only their end point position on screen, the effect is quite amasing, even on a wireframe engine. It's like watching who's outside the door through the peek hole . Maybe there's someone out there willing to help me out, share the code and effort or put me out of my misery if it's been done already or impossible? PLEASE?
Keep an open mind and a closed skull but don't outlive your happiness.
Like you said, you want to create a "physically" correct lens or camview, a bit like the fisheye effect.
Why don't you go on for a pixel/vertexshader solution ?
I dont know a game that uses this effect all the time but Silent Hill4 "The room" is having a door and also this kind of distorted view, when you peek through the spy:
http://img.gamershell.com/imagefolio/ga ... S_ES05.jpg
sonyafterdark, as Kai already mentioned, your idea seems like a perfect task for a vertex shader.Kai wrote:Why don't you go on for a pixel/vertexshader solution ?
The task of a vertex shader is normally to transform vertices from object space to clip space. You can simply replace the projection matrix such that it accounts for the terms that you describe, or even do the computations "manually" in the vertex shader (without the projection matrix). If you can create a projection matrix that computes the equations that you mention, you can even have this effect in old, un-extended OpenGL on non-programmable GPUs.
Of course, the results would only be per-vertex rather than per-pixel, but that is probably not all that critical, as your suggestion computes distored images anyway.
just wondering why you want to do this? maybe you said and i just didnt read the whole post oh well this would definetly need to be a shader, i would do just an image effect on the rendered result but it might be slower...
Users browsing this forum: No registered users and 3 guests