View Full Version : Reflections

03-22-2006, 01:18 AM
Hi everyone!!!

How are you doing?!
Hope someone can help on this one:
I want to render a model as realistic as this one I found:
Piano with awesome reflections (http://www.arbitermt.co.uk/ni/products/images/akoustik_piano/akoustik_piano_play.jpg)

What techniques do I have to use to get something as realistic as as that in real-time?!
I am only concerned on the piano reflections on the black parts of the piano, not the keyboard. It looks as if the enveiroment is reflected on the piano, and the part where scores are put looks like hit by a direct light.

Cube Enveiromental Mapping?! Spherical Enveriomental Mapping?!
I am trying to avoid using extensions if they are not supported for a standard type computer user.

Please if you can, point me to tutorials, as I couldn't find any about cube mapping, and only a basic example of Spherical Mapping.
I took a look at Nehe's spherical mapping tutorial , but I don't know if I can use it for so complex objects?

Thanks all in advance!
Cheers! :)


03-22-2006, 09:07 AM
Sphere mapping is pretty limiting - I suggest using cubemaps - they're pretty wide supported nowadays:

Now about achieving good reflections:
First of all app;ly diffuse lighting - use standard OpenGL lighting model or a cubemap (if you want it to be more precise). If you use standard lighting then do not use specular lighting.

If you have this it's time to add reflections. That article about cubemapping should explain everything.

That should be enough for beginning. Try implementing it before you read the rest of this post and see if you are satisfied with the results.

If you want more, then next step should be to modulate your environment cubemap using fresnel term. You can implement this modulation on per-vertex basis or by using another cubemap.

Finally - if you used fresnel term, then strong light sources will not be reflected properly unless you use floating point format for your environment map texture, but this will require modern GPU. Instead, as an approximation, you can apply yet another environment cubemap - this time do not use fresnel term, and cubemap should contain only light sources (so you reflect light sources again, on top of previous texture).

03-22-2006, 08:27 PM
Thanks for the info!
I started playing around with spherical mapping for the first time before moving on...

What textures should I use (and what soft can I use) to create the reflection as shown in the example?! Cause if I use textures with the surrounding landscapes, my piano looks like a made of reflective metal.

Also, the reflection mapping looks good on flat surfaces, but on curves it looks like a twirlpool...
Will this be fixed if I apply cube mapping, or do I have do to something with the vertexs of my piano!!?

Thanks so much in advance!

03-23-2006, 05:21 PM
About that "twirlpool" thing:
Cubemapping should give better results, since sphere map itself is a "twirly" image. Still, it's normal vectors that are most important. Imagine a cube - choose one vertex and think what normal vector it should have. It should in fact be 3 separate vertices placed at the same point, each having different normal vector. On a sphere hovewer, vertices should be shared between faces and use averaged normal vectors.
On more complex shapes some faces can share vertices, and some should not. This is often solved by smoothing groups or simply by calculating angle between faces to see if they can share a vertex.

And now the metallic appearance. This is probably because your environment texture completely replaces the black color of piano.

The simplest solution is to use dark color when rendering environment map, for example:
glColor3ub(50, 50, 50);
Note that this will cause all light source reflections to appear dark aswell. So another solution is to edit your environment texture - make it dark, but leave light sources bright.

These are of course not proper approaches. They're just a low-cost solutions.

To achieve really good results you will need to use multipass or multitexture rendering. I assume you don't want to use pixel shaders.