Results 1 to 4 of 4

Thread: reflecting water

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2005

    reflecting water

    I'm trying to create world (from heightmap) including water which is partially transparent and partially reflective. Level of transparency and reflectivity depends on distance (most transparent near the point of view and most(=fully) reflective far away).

    Ive solved the problem but I paint too many triangles and I am looking for some more elegant solution

    My solution:
    -First step: I paint world (only above water level) and clip parts below water level
    -Second step: I paint the same part of world but mirrored - this is reflection
    -Third step: I paint bottom part of the world ( below water level) clipped on water level but I have to draw it transparent (more distatnce - more transparency - mirrored(=reflected) part of world is more visible) and I also have to paint these polygons sorted form front to back with enabled depth test
    -Last step: I paint water (transparent)

    This works but it needs many triangles to be drawn and some of them blended and sorted (from nearest to most distant)

    So question is how to do it better and faster

  2. #2
    Senior Member Regular Contributor
    Join Date
    Aug 2005

    Re: reflecting water

    Well, it looks like you have at least 2 areas that you want to optimize.

    1. Efficient visible surface determination.
    2. Efficient sorting of the visible set.

    Look at occlusion queries and/or portals for visible surface/region determination, in addition to some good frustum culling. And for sorting, look at BSPs or order independent methods. For the latter, check out the NVIDIA developer site and SDK samples. Also, look at the clipplane sample.

    What you use will depend on how your world is structured and your hardware. Sometimes it's not a matter of being elegant so much as it's a matter of getting it *work* quickly, whatever it takes .

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2005

    Re: reflecting water

    well, not exactly.
    - I calculate what is in viewable area (depends on position, angle of view, distance, triangle orientation and clipping area) and draw only triangles which fit all these conditions
    -To sort I use quick sort algorithm (and I even calculate mean value in algorithm to make it as fast as possible

    Problem is: It works but it needs three passes, transition between transparent and reflective is not too smooth (depends on heightmap trinagle size
    ) and it looks horrible when I get under water.

    I think it can be done better...

  4. #4

    Re: reflecting water

    you will need to flip the mesh once you're UNDER the water, and apply different material - shader because as you might know, water looks different when seen from inside of it . also you could grab the current frame and apply a deformation shader - effect so it looks like under-water (sometimes this can be done by showing on screen a subdivided quad which uv values you smoothly move to create that water-effect inside the water) i hope you get what i mean

Similar Threads

  1. Matrix for reflecting points on the line y=x
    By baconbeastnz in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 10-30-2008, 09:06 AM
  2. Reflecting local textures on object
    By CatDog in forum OpenGL: Advanced Coding
    Replies: 17
    Last Post: 03-22-2006, 04:40 PM
  3. Reflecting Sphere
    By raoulduke in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 09-13-2004, 03:56 AM
  4. Water
    By c_olin in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 04-17-2004, 06:45 AM
  5. Water
    By nergal in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 11-04-2002, 11:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean