View Full Version : Spheremapping looks stwisted
weatx
September 18th, 2007, 20:45
The spheremap looks as though it is rotated 90 degrees on the x-axis. You can see the center of where it wraps around on the sphere (my test object is a sphere). I did a quick fix by swaping the y and z coordinates (of the resulting directional vector) by swizzling them, but the sphere map still draws strange.
Which of the envirnmental maps is like the OpenGL implimentation of spheremapping?
weatx
September 19th, 2007, 00:45
Here's a flash video demonstrating the problem I'm having. Clicky (http://www.spider3d.com/videos/customsm/customsm.html).
ruediger
September 20th, 2007, 16:28
That's what I call an excellent video for describing a request! :)
Actually I had to think a while after watching your video, since I had to remember how the OpenGL reflection mapping works. The spherical environment shader in mental mill is not using the same mathematical formula as the OpenGL Technique.
While OpenGL only uses a circular part of the image for the texture lookup, our implementation takes the whole image by transforming the reflection vector to polar coordinates. So the tiling is intended and correct - using a tileable environment texture will make the environmental illusion perfect.
See the OpenGL red book, Chapter 9: Sphere map for complete details about the OpenGL implementation and Wikipedia under
http://en.wikipedia.org/wiki/Spherical_coordinates for the mathematical details about Spherical coordinates.
Best Regards,
Ruediger
weatx
September 20th, 2007, 17:51
Thanks! Maybe videos will be the new wave of the future :D
I'm understanding how your shader works now that I've applied it to different models. It actually represents reflections a little better than OpenGLs implimentation. With your reflection you can rotate around an object and see the texture as if it was a panarama, whereas the OpenGL version you only see a single still image mapped to the front of the sphere.
Thanks,
Aaron