Monday, August 29, 2011

GLSL water reflections

I have been mostly working on sehle (Khayyam rendering engine) based game framework lately. There have been some new things in Khayyam - that will be the scene/level builder for it - as well. The latest addition is reflective water material.

Esk standing on near water - with ripples and reflection
You can convert all static objects (OBJ, 3DS and Collada) to water bodies - although to get realistic results, they should be bowl- or plane shaped with surface at Z zero (in object coordinates). Everything is fake, of course - there are no real waves or refraction, but only distorted reflections and transparency. But it still looks reasonably good in my opinion.

At moment there are following water properties implemented:
  • Full reflection (everything that can be rendered can be reflected, except other reflective surfaces)
  • Viewing angle based reflectivity - i.e. if looking directly down, water is mostly transparent, looking along water surface it becomes almost perfect mirror
  • Depth-based transparency - shallow water is almost transparent, deeper water becomes opaque
  • Up to 8 simultaneous ripple generators, that can be assigned to "shore" vertices of water body
At the image below you can see how the water color changes from almost fully transparent near bank to completely opaque brown at the middle of river. As the viewing angle is high, overall reflectivity is low and the colors of river bottom and water can be seen. Ripples change the apparent angle between viewer and water surface, so although sky is uniform color, ripples still show as they change the reflectivity of surface.

A river from above showing water and bottom colors
 At the next image the viewing angle is low and thus the surface of water is almost completely reflective.
 
A river from low angle, showing almost perfect mirror
Ripples are circular and their wavelengths, amplitudes and generation points are updated randomly over time. Thus the actual pattern almost never repeats - although sometimes it is not as nice as on the image above.


When I find some free time, I'll write the technical details about the actual mathematics in shaders. And hopefully there will be new Khayyam release too.

Have fun!

14 comments:

  1. Thanks for sharing this blog, this blog is very helpful information for every one.

    ReplyDelete
  2. Most impressive Topic and Blog, this is very helpful Information. thanks for sharing.

    ReplyDelete
  3. Thanks for sharing this blog, this blog is very helpful information for every one.

    ReplyDelete
  4. You have a real ability for writing unique content. I like how you think and the way you represent your views in this article.

    ReplyDelete
  5. Thanks in favor of sharing such a nice thinking, article is pleasant, thats why i have read it entirely.
    Talk to astrologer

    ReplyDelete
  6. looking forward for more posts. Thanks Feel free to visit my website;

    ReplyDelete
  7. Your article looks really adorable, here's a site link i dropped for you which you may like.

    ReplyDelete

  8. Very informative article also check my blog post for Top best earnings tools and many more must check

    ReplyDelete

  9. Super site! I am Loving it!! Will return once more, Im taking your sustenance in addition, Thanks

    ReplyDelete
  10. I want to encourage yourself to continue your great posts, have a nice day! Feel free to visit my website;

    ReplyDelete
  11. I'm wondering why the opposite experts of this sector don't notice this.

    ReplyDelete