• Advertisement
Sign in to follow this  

reflecting sphere with sphere mapping

This topic is 4870 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. 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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement