Advertisement

Sphere mapping to simulate reflection

Started by April 09, 2002 07:34 PM
2 comments, last by greeneggs 22 years, 10 months ago
Summary: Because of hardware constraints, I would like to use sphere mapping to simulate reflection off a large object. Ideally, I would use a cube map, but instead I plan to use a number of different sphere maps, for different areas of the large object. I am concerned about discontinuous visual jumps between the different regions, and am curious if anyone has experience in dealing with this problem. I do not care about getting perfect reflections, so an approximation is good enough, but I do care about discontinuities. More detail: I am rendering a large body of water. I would like to render reflections (as well as some other similar effects). Ideally, I''d use a cube map, but my graphics card does not support cube mapping. So I''d like to use sphere mapping to simulate these effects. My idea is to break the surface of the water into a number of connected regions, to calculate (statically if the viewpoint and light position are fixed, or dynamically in general) a sphere map for each region which correctly models the desired function (say, reflection) at the region''s center. Then render each region with the appropriate sphere map. I can see two ways to avoid discontinuities: 1) break the water into a large number of different regions 2) render triangles lying on or near the boundary between two regions twice, once for each sphere map, and then blend between them (perhaps a nice blending function would give alpha 1/2 exactly between the two regions, and then vary linearly with distance away from the boundary, so region 1''s sphere map would contribute more to points further within region 1, etc.) This won''t be easy to code, and I wonder if anyone has experience with using sphere maps to simulate cube maps. And how to deal with the discontinuity problem. Again, I don''t need perfectly visually accurate reflections, but I don''t want any lines of discontinuity cris-crossing the water surface.
Hmm. Interesting idea.

I think the problem is not so much the spheremap. You''re reflection mapping a water surface, so you don''t actually need the full sphere, the upper hemisphere is enough.

The main reason that makes cubemaps so much more attractive compared to spheremaps, is the fact that they have an even directional distribution and no singularity. But you won''t have a problem with sphere map singularities anyway, since they concentrate around the lower hemisphere (the narrow torus around the central circle in the 2D spheremap). So, using cubemaps won''t give you any advantage over spheremaps.

The problem lies somewhere else. You will have several subregions of your water surface, each mapped with a different spheremap. If you have lots of local geometry around (eg. terrain, boats, whatever), then those spheremaps will be significantly different. Since they only approximate the reflectance distribution around the central point of each water tile, the error will increase, the more you go outwards from the center point. It will be at maximum at the border of each tile. And just in this area of highest inaccuracy, you will have a discontinuity between two spheremaps. You will get visible breaks, no matter what.

I don''t know if interpolating between two spheremaps at the tile border faces will be enough. If your spheremaps are very different, then it will almost certainly not be enough. To get a good result, you would need to do bilinear interpolation between the 4 nearest spheremaps (at each face !), with the interpolation lattices being the central points of each tile (where the spheremap error is 0). That means 4 passes per face. On a GF3, you can do it in a single pass, using all 4 texture units. But since you want to have the thing running on low-end HW, you''ll end up having to do 2 or even 4 reflection passes per face. Not so good.

Why don''t you just use a planar reflection rendered to a projective texture ? It''s 100% dynamic, easy to code, and your reflections will be clean and pixelperfect, but still distorted by the waater surface ripples (and not just washed out colours as with spheremaps). I don''t know if that is an alternative in your special case though.

/ Yann
Advertisement
Here is what it currently looks like:


I would like to it look more like this Renderman rendering:

(except with a better Fresnel term; their ocean is too reflective)

Would just a texture work? As you can see, at least for now I am just trying to render the water, not any local objects whose reflections might have to be taken into account.


[edited by - greeneggs on April 10, 2002 4:09:04 PM]

[edited by - greeneggs on April 10, 2002 4:10:02 PM]
OK, if you want to render a pure ocean, without any reflective local geometry, than a single spheremap will be totally enough. The only incident light comes from the sky, that is 'infinitely' far away from your ocean. So approximating the complete ocean with a single spheremap should do the trick. Be sure to have a *good* resolution spheremap though, if you want the subtile differences in sky colouring reflected in the waves. I would suggest a minimum of 1024².

I can see two differences between your rendering and the RMan one. First, your reflection seems to be way to dim at the horizon. The angle at the horizon is very small, so it should be almost 100% reflective here. It looks like there is no fresnel term at all, what kind of fresnel formula did you use ? The full 3D equation (I guess not), or what kind of approximation ? I agree that on the other hand, the reflection on the RMan image is way to strong.

Second point is the geometric detail. The RMan image seems to make heavy use of bumpmapping, this augments the detail perceived in the reflection.

I would suggest the following:
* Bring in a good fresnel term. That will totally change the appearance of your image, esp. in the distance.
* Use a colour modulated trimesh as base, no diffuse texture map.
* Use an EMBM texture on the water, and animate it with the general ocean waves. This will increase the detail and will take care of small changes in the reflection vector, at a subvertex level.

A good article to read about this topic is 'Deep-Water Animation and Rendering' by Lasse Jensen, available online on Gamasutra. Sorry I don't have a direct link, but it should be easy to find.

/ Yann

[edited by - Yann L on April 10, 2002 9:50:44 PM]

This topic is closed to new replies.

Advertisement