Advertisement

reflecting sphere with sphere mapping

Started by September 22, 2004 05:13 AM
4 comments, last by Luke Miklos 20 years, 2 months ago
Hi. I'm actually working on a scene with a sphere, that should be able to reflect some objects (cubes, spheres, etc) around it (not just only the background texture - REAL reflections!). For this i looked at the nehe tut 23 (sphere mapping). My sphere has already the texture of the background but does not reflect an object i put around it. So far i don't know how to go on. Can anybody help me? Is it possible to do the reflections on the sphere without a default texture i have to put on it? Or can i use instead of it, a one-coloured texture completely in black or else? Thank you The code can be found at www.markuslanser.com/main.cpp Or you can see the whole vc++ project at www.markuslanser.com/sphere2.zip
If the scene is static it should be possible just to draw them over the background, however if you want real looking reflections you might want to take a look at cube-mapping.
Advertisement
Just the distance and angle between the camera and the reflecting sphere are not changing, but there are going to be some objects moving around that should be reflected in the sphere.

Is there a tutorial or example files for cube mapping?
Google: "cube mapping opengl"
->
http://developer.nvidia.com/object/cube_map_ogl_tutorial.html
isn't it possible to use sphere mapping as a solution to this? In my scene, there is no need for different viewpoints and there won't be other reflecting spheres that have to be drawn realistic.
There is just the system of camera+reflecting sphere that should move around (but their position and viewpoints to each other won't change) and other objects that should be reflected (and move around).
is it possible with sphere mapping?
cube mapping is pretty simple, here are the basics (in psuedo):

for each frame   translate to location of entity that has the reflection   for each direction along +- axis  //+X -X +Y -Y +Z -Z      render the scene to a texture   clear everything   draw the real scene   bind to the cubemap textures   draw the reflective object


since cube-mapping is view independent, if you want it to be a real looking dynamic reflection... a small trick you have to do is:

after the "translate to location of entity" up there, you also have to rotate the negative heading & negative pitch (based on the heading & pitch of the vector from (0,0,0) to the reflective entity) so that the 6 textures you save are actually rotated. In cube-mapping, you can't simply rotate the reflective object to change the reflection textures, you have to actually change the textures.
Whatsoever you do, do it heartily as to the Lord, and not unto men.

This topic is closed to new replies.

Advertisement