Jump to content
  • Advertisement
Sign in to follow this  
Caglow

OpenGL Custom Projections?

This topic is 3339 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

The only 2 projects I know of that are built into OpenGL are Orthographic and Perspective. I've been using these for a while now but am wondering if it's possible to have other projection types...like stereographic. I've searched Google for code for this but have come up empty-handed. My current project is to be purely based on this projection type. I've realized that other programs written with OpenGL, like stellarium, seem to be able to do this. However, I'm not about to look through 1M+ lines of code just to find a few hundred that I need (not to mention that stellarium has SO few comments). If possible, I'd like to see some example code and a brief explanation (unless the code is self-explanatory). Thanks.

Share this post


Link to post
Share on other sites
Advertisement
The projection matrix used in OpenGL is supposed to map all 3d points within some volume onto a 2d plane.

Stereographic projection seems to map only points located on a sphere (except for one, the projection point) onto a 2d plane.

So I think you'd have to something on your own to achieve the effect you want (I'm not sure what that is, exactly, so I can't offer any more help).

Share this post


Link to post
Share on other sites
Yes, that's what I'm trying to figure out how to do. I'm trying to convert everything 3D and draw it onto a sphere which then needs to be converted to 2D with a stereographic projection. I'm sure this is possible (to some extent) as, like I said, stellarium uses it (and the objects appear remarkably 3D as if drawn using Perspective).

Share this post


Link to post
Share on other sites
I'm not entirely sure if this is what you want, but here goes.

Why don't you render your scene 6 times in 6 directions: up, down, left, right, forward, backward. Just like if you were making a cubemap.

Then, you just need a mapping from the 6-sided cube to a sphere. After that, you can go from the sphere to 2d plane via the Stereographic projection like you wanted.

So in the end, you'd have to render a big quad that covers the entire screen. For each pixel, you want to go from the 2d position -> position on a sphere (inverse Stereographic projection), and then from a position on the sphere to a position on the cube. Then, sample the texture of the side of the cube that you hit.

Essentially, you'd be doing something very similar to Sperical/Cube Environment Mapping, except done in reverse.

I have no idea if that's what you're looking for, or if this helps at all (you'd have to know shaders to implement the above), but good luck.

Share this post


Link to post
Share on other sites
I haven't a clue about how to do this but I will take a look at some of those tutorials. (I've never rendered anything successfully on the inside of a polyhedron or any other solid)

Also, if anyone else has a solution, please post. Stereographic Projections on Wikipedia: http://en.wikipedia.org/wiki/Stereographic_projection (there are formulas but no matrices).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!