OpenGL 180 Degree View

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

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 on other sites
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 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 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.

vec3 vertex_vector = vertex.xyz - center; //vertex = gl_Vertex, center = the patch's center = the camera positiondepth = length(vertex_vector)/100.0; //depth is a varyingvertex_vector = normalize(vertex_vector);//http://en.wikipedia.org/wiki/Lambert_azimuthal_equal-area_projectionfloat 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 ongl_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 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 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]

Thanks,

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• Forum Statistics

• Total Topics
633417
• Total Posts
3011781
• Who's Online (See full list)

There are no registered users currently online

×