Sign in to follow this  
cooper

reflecting sphere with sphere mapping

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this