Jump to content
  • Advertisement
Sign in to follow this  
Geometrian

OpenGL 180 Degree View

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

Hi,

Still working on progressive refinement radiosity. I'm proud to say that it is approaching completion. One final thing (I think/hope).

When rendering the scene from a patch's perspective, ideally, one uses a hemisphere to describe all possible viewing rays. 180° viewing angles don't exactly make sense in an OpenGL frustum's context, so the classic solution is to use a 90° "cubemap"-like approach, requiring five passes.

It seems to me that using a hemisphere would work; the transformation simply has to be done in the vertex shader.

I'm not sure how this'll work. Can anyone give me a sample vertex shader that outputs the proper gl_Position as if it had been a proper 180° projection?

Thanks,
-G

Share this post


Link to post
Share on other sites
Advertisement
There's quite a few articles on "dual paraboloid mapping", which is a cube-map like technique that uses two hemispheres.
You should be able to use the projection ideas from that technique, except you'll just be rendering one hemisphere, not two.

Share this post


Link to post
Share on other sites
Thanks; I hadn't thought of repurposing paraboloid maps . . .

Continuing in that direction, I found a paper, available here, which suggests using the Lambert projection (r=(1-cos(θ))0.5), which looks very similar, but has the property of projecting solid angle proportionally to screen space, which is actually very important for my purposes (I was going to have to find some way to compensate for it before).

Still don't know how to implement it, though. The apex of the surface needs to intersect a vector I define.

Share this post


Link to post
Share on other sites
I found the Wikipedia article, and have tried to make a shader out of it. I also tried cutting out geometry that lies behind the hemisphere (i.e., outside a simple circle), but it wasn't working, and I consider it a confounding factor.

Part of the vertex shader, and part of the fragment shader:
vec3 vertex_vector = vertex.xyz - center; //vertex = gl_Vertex, center = the patch's center = the camera position

depth = length(vertex_vector)/100.0; //depth is a varying

vertex_vector = normalize(vertex_vector);

//http://en.wikipedia.org/wiki/Lambert_azimuthal_equal-area_projection
float z_term = pow( 2.0/(1.0-vertex_vector.z), 0.5 );
vec2 coord = z_term*vertex_vector.xy; // in range (-2,2)

coord = ((coord+vec2(2.0))/4.0);//*vec2(512.0,512.0); //in range (0,1)

vertex.xy = coord;
vertex.z = 0.0;

gl_Position = vertex;
color.rgb = indices; //default values of patch, just so we can see what's going on
gl_FragDepth = depth;
When I leave the vertices transformed normally, I see a 3D view from the patches' perspective. When I try substituting the vertex shader above, the results are screwed up.

I present this as my very first attempt. Wholesale revisions or completely ignoring the whole thing and starting from scratch are most welcome.

Bottom line: still can't figure out how to implement Lambert azimuthal equal-area projection in a vertex shader. Help?

Thanks again,
G

Share this post


Link to post
Share on other sites
Hi,

I've now asked this question in the Math and Physics Forum, here, because I think they might be better suited to answer it.

As a side-problem, I'm not sure exactly how gl_Position works in screen space. I've been abstracting things with matrices so long, I don't know how it works, really. Does screen space x∈[0,1], y∈[0,1] map to gl_Position.x∈[0,1], gl_Position.y∈[0,1]?

G

Share this post


Link to post
Share on other sites
gl_Position (the vertex shader output) is in post-projection-space. Before it's fed into the fragment shader, it will be divided by w. In both of these, the edge of the screen in x/y are -1.0 to +1.0

[Edited by - Hodgman on July 21, 2010 11:45:06 PM]

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.

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!