Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jonbo372

Perspective Transformations

This topic is 6078 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Right now im playing around with different perspective transformations and i have found myself stuck! In a normal perspective view (as the one you get with glFrustum) kind of looks like this (as you all know im sure) | | | | | | | | | | | | | | near far now, what i would like to do is to have the near-projection plane altered to be of any kind of shape. what im trying to do right now is to swap out that near plane so instead of being just being a flat "screen", i want it to be a sphere. so it would kind of look like this: | ( | | near far (ok, the picture isnt all that great but the near is now suppose to be a half-sphere) it seems that my math is kind of old cause i cant come up with the right matrix for it!!! anyone have any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
I think you got the near/far planes swapped. Usually the near is smaller for "normal" perspective.

The "Real time rendering" book has a section on describing derviations of perspective matrix. For making the plane sphere, I don''t think it is possible.

Share this post


Link to post
Share on other sites
With matrices you do linear algebra.
As far as I know, trig functions are not linear.

You could completely redefine the meaning of each coordinate, add rows/colums to the matrices... but then you''d also have to write your own graphics library, because the available API only work with the ''traditional'' 4x4 transformation matrices.

Now, there is a way : if your target video card support pixel shaders, you can try to create a virtual screen surface inside your view volume, acting as a lens (there''s a demo in NV''s SDK). Good luck though.

Share this post


Link to post
Share on other sites
yeah, sorry about the images

they got screwed up when i posted the question... it seems that you cant start off a new line with just blank spaces so this is what i tried to show you:

(dot means blankspace now)

.........|
.........|
.|.......|
.|.......|
.|.......|
.|.......|
.........|
.........|

.........|
.(.......|
.........|

yeah, i was afraid that i might not be able to do it directly but i will check out the lens demo, thanks for the tip! if anyone else has any other ideas, please let me know!

Share this post


Link to post
Share on other sites
It would seem like it would be worthwhile to look at spherical texture mapping and environment mapping. It isn''t clear to me what you are trying to achieve, i.e. what is the image suppose to look like. It is clear how you think you can acheive it, but it isn''t clear what it is.

Share this post


Link to post
Share on other sites
well, i know about spherical mapping and cubemapping but to do spherical mapping (which is kind of the effect i want to achieve) i need a texture. to read the entire frambuffer and to convert that into a tecture everytime takes a long long time, especially when you want to do it in real time. btw, i would also need to do a spherize filtering operation on that texture in order to get the desired effect (like photoshops shperize filter) before i "glued" it to the sphere, via sphere mapping... (ie if i have understood everything correctly, which very well may not be the case :-)

with cubemapping, however, it works great if you reflect everything onto a shiny sphere in the center of the scene. in this case though, its the other way around. the sphere contains the scene and therefore cubemapping will not work...

hmmm... did this better described what im trying to get?

Share this post


Link to post
Share on other sites
I''m no expert, but can''t you set a texture as the render target, so that it is what the card draws to, and then you reset the render target, and draw the texture to the screen.
The only problem is that rendering to a texture isn''t supported by all cards yet (but neither are vertex/pixel shaders).

John B

Share this post


Link to post
Share on other sites
We might have a better chance of offering up the correct answer if we knew the context of the problem, so that we better understand exactly what it is you are trying to do and why. There might be a better alternative solution...

If you want to create a lens affect, one method is to consider your far plane as a tangent plane to a sphere. Consider rays that are perpendicular to the near and far planes. Project them from the near plane, through the far plane and onto the sphere. Then ''bounce'' them out along the normal vector at that point on the sphere until they intersect the far plane again. That is their projected point. Make a new plane that lies over the far plane and store this projected point. When you''ve done that for all possible perpendicular rays between the near and far planes, then simply clip the new projected plane to the size of the near plane. This will create a lens effect where the lens has the focal radius equal to the spheres radius.

I was going to write out the mathematics of this for you, but unfortunately it''s the middle of the day and I really have a lot of work to do. If you get stuck working it out, give me a holler and I''ll assist as needs be.

Cheers,

Timkin

Share this post


Link to post
Share on other sites
Just a big THANK YOU guys for all the help so far!!!

Just a try to clarify things...

ok, this is what im trying to achieve...

normally, everything you project onto the screen is a flat image but what im trying to do is to project stuff onto a sphere (have a half-sphere setup with a projector and everything) instead of a boring flat screen. now, as you can imagine objects that doesnt lay in the dead center will be distorted so i need to fix that. one way of doing it is with sphere maps but it just takes to long since i really want to be able to do this in real time. so if i would have to use sphere maps i would need to update the texture everytime i did something to the scene or if i moved the camera. a fast way i think would be to figure out the right projection matrix (if it is possible) instead. this means that the near plane needs to be "swapped out" from being a plane to a sphere (half).

Did this clarify things?

/Jonas

Edited by - jonbo372 on February 25, 2002 8:18:45 AM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!