Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a "spherical frustum" for 3D projection

Tags:

opengl

3d

I am currently writing a transformation from model space to clip space for use in OpenGL. From what i have seen, programmers typically use a traditional rectangular frustum to define the clipping boundaries in their model space. I personally had in mind a shape like a frustum, except the near and far planes are spheres centered at the apex of the frustum (the camera). So something that looks like this:

Circular sector

The yellow region corresponds to OpenGL's clip space, and the two spheres (depicted as circles in this cross-section image) correspond to OpenGL's z=-1 (inner sphere) and z=1 (outer sphere).

Is this a more realistic way to model the projection, or should i stick with the traditional rectangular frustum when designing my projection matrix?

like image 697
creXALBO Avatar asked Dec 23 '13 09:12

creXALBO


1 Answers

No. I'm not sure what you mean to be completely honest, but in either case no.

  • Do you mean that the view coordinates (view frustum usually) should be bounded by spheres?

Well in many (all?, most?) large polygons that intersect the clip plane are actually broken in to smaller triangles that don't - otherwise a single big polygon that had one vertex outside would simply be ignored. This is what clipping actually involves.

Remember when you played old games and walked into objects, only to have them disappear if you got too close? Wouldn't it suck if when the corner of a polygon was just outside the view the hole thing vanished? see this for clarification.

  • On the other hand you may have meant the view space should be projected onto a sphere instead of a flat plane.

Well a screen is flat, so the objects in a 3d scene are projected onto a flat surface, equivalent to tracing a ray of light from an object towards the camera and finding where it would intersect your monitor. The weird "unrealistic" 3d look is a result of the viewer's eyes being a) not a point camera and b) rarely if ever at the correct distance for the field of view.

like image 82
user3125280 Avatar answered Oct 14 '22 16:10

user3125280