Reflecting Sphere

Hi.
I don’t know if this is a topic for the beginner’s area - let me know if this is the wrong place for my problem! :wink:

I’m trying to set up a sphere that is able to reflect other objects around it - just like a ball with a mirror-texture.
I did some experiments with the nehe tutorials 26 and 23 but i didn’t get some good results with it.
Can you give me some hints!? Is this possible anyway on a standard computer or is this overstrain it?

Thanks
Markus

There are ways to do this, but none are perfect. To just get a metallic look, you should be able to use sphere mapping. (I’ve had some problems with this; I just posted in the beginner area but made no headway.) I believe there’s also cube mapping which is only a bit more sophistocated.

In order to reflect the actual world around the object, you’d need to render the world from the object’s position, then put that into a sphere or cube map. This might work with one metallic object, but with multiple metallic objects, I imagine it would get quite expensive.

Even so, these would be an approximation – it assumes the object is far from the objects it is reflecting.

You mean like this ?

Yes it’s possible. It’s called dynamic cub mapping. Depending on what a “standard” computer is (that’s an AMD64 with an nVidia 6800 right?) it’s possible on a wide range of hardware - I have run my app on as low as a geforce 256 (I think - definitely a geforce 3). I get reasonable (50-100fps)performance on a PIII 733 with a geforce 3 - and that includes physics, input, zfail shadows and 7 separate objects (sometime more sometimes less) with dynamic cube maps.

There are ways you can optimise the performance of your dynamic cube maps.

  1. Experiment with how you update your cube maps (ie. RTT, glCopyTexSubImage). On different hardware some methods will be faster than others.
  2. Experiement with the resolution - lower resolution doesn’t always mean lower quality - it’s only when you look closely that you notice how crappy a low resolution reflection is - unless it’s too low
  3. You don’t need to update EVERY face of the cube map EVERY frame - IIRC I update one face of every other cube map each frame - so to do a full update of the cube map for a particular object might take 12 frames. If you look carefully you might be able to notice this, but on the whole it’s find to do this.

[EDIT] - Fixed the link to use the IP…

Or you can use texgen spheremap with a correction of a cubemap texture to a single spheremap texture like this:

http://www.sgi.com/products/software/performer/brew/envmap.html

hi. Thank you. Dynamic Cube Mapping seems to be what i was searching for.

Is there any source code in the net available?

Nutty has a demo .

“Basically” it’s just render to texture (or glCopyTexSubImage2d) for each of the 6 sides. You setup your “camera” with the origin at the center of your object (the one that is reflecting the cube map) and you set the frustum with an aspect ratio of 1:1 and a view angle of 90 degrees. The tricky (annoying) part is setting the angle of the camera right (ie. upside down for -X or was it +X, or perhaps Z etc.).

Some of the nVidia papers are generally helpful too (regarding render to texture etc.). The cube map face alignment document didn’t do me any favours though…