PDA

View Full Version : Rendering scene from a virtual viewpoint



muffin
02-16-2013, 06:10 AM
Hi

I need to render a scene of a table and teapot from a virtual viewpoint that is from under the table. Then I have to capture the image as a texture map. Im not sure of the steps and what functions to use to go about doing this. Can someone please help me out? thank you so much, in advance!

Dark Photon
02-17-2013, 06:37 PM
I need to render a scene of a table and teapot from a virtual viewpoint that is from under the table. Then I have to capture the image as a texture map. Im not sure of the steps and what functions to use to go about doing this. Can someone please help me out? thank you so much, in advance!
Do you really need a texture map? Or do you more generally need a reflection of the scene rendered in the table (e.g. glossy reflection?

If the former, even then you have several choices. Create a framebuffer object, create/attach a color texture to COLOR_ATTACHMENT0, and render into that. That's the simplest way. Before FBOs (many years ago), what you had to do is render into the system framebuffer, and then copy that into a texture with glCopyTexSubImage2D.

muffin
02-17-2013, 07:15 PM
Hi

Yes, I have to create a reflection of the ceiling and objects on the table, on the tabletop. However, I'm not sure how to setup the view frustum such that I can capture this image from the viewpoint of under the table, then put it on a framebuffer.

Could you help me out with the setting of the view frustum to capture the image from that angle for the reflection? Thank you so much!!

Dark Photon
02-18-2013, 04:24 AM
There are a number of ways to do this, and you may actually prefer an approach besides render-to-texture, such as one which generates pixel-perfect results (e.g. the stencil technique). See this link:

* Advanced Graphics Programming Techniques Using OpenGL (SIGGRAPH 1999) - 11.1 Reflections and Refractions (http://www.opengl.org/archives/resources/code/samples/sig99/advanced99/notes/node156.html)

In particular the 3 sections on "Planar Reflections" (stencil buffer, clip planes, texture mapping).

Also, for code and more docs, search for "reflection" on this page -- several hits:

* Code Resources (OpenGL wiki) (http://www.opengl.org/wiki/Code_Resources)

muffin
02-18-2013, 05:29 AM
Hi,

Thanks for the input, however I need to first set up the virtual viewpoint before i can go about rendering the scene as texture. It can be done by setting the glfrustum i believe. However I'm not sure what values to give for the parameters of glfrustum(), since there are bottom,top,near,far...

Dark Photon
02-19-2013, 05:57 AM
The frustum (projection) is the same it's the viewing transform that changes. See this:

* http://www.opengl.org/archives/resources/code/samples/sig99/advanced99/notes/node159.html