Results 1 to 9 of 9

Thread: Terrain reflections problem.

  1. #1
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Terrain reflections problem.

    I have a problem, i want to implement water reflections in my terrain engine.
    I basially at the moment have the terrain mesh ad one large water quad stretching over
    at a certain height over the entire mesh.
    Anyway, usully what you do:
    Draw the terrain mesh
    label all water quad pixels as 1 in teh stencil buffer.
    Draw the height mesh again with negative heights this time. (if the water quad is
    at 0 height) but only over the water quad pixels.
    Then you would draw the water uad with alpha blending on.

    Anyway, you cant do this with a terrain engine. This isbecaus the original mesh
    will cover over the reflection mesh, this is because the original mesh goes continues
    under the water as well.

    Anyway, the closest i have come to a solution is to simpy say only draw thos parts of
    the terrain mesh which are above the water quad, and not those below. Then it kinda works
    but rather obviously it aint pretty because this will produce jagged polygon cutoffs
    in the terrain mesh.
    Anyway, does anyone know how to solve this dilema?
    :: Sleep is a poor substitute for caffeine ::

  2. #2
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Finland
    Posts
    17

    Re: Terrain reflections problem.

    You could use clipping plane to clip off parts of terrain that are under water, when rendering reflection. Not very fast but works.



    [This message has been edited by Spartacus (edited 07-15-2002).]

  3. #3
    Member Contributor
    Join Date
    Jun 2002
    Location
    Alamogordo, NM USA
    Posts
    67

    Re: Terrain reflections problem.

    depends on if you want mixed caustics (appearance of objects under water) along with reflections. Just reflections, I would use an extra clipping plane to cut off at the water level (or at the elevation of your lowest wave if you have them). This avoids your polygon "jaggies" cutting off at the vertex.
    Japanese Proverb: "Talk about things of tomorrow and the mice in the ceiling laugh."

  4. #4
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: Terrain reflections problem.

    Relatively stupid question, but i never used clipping planes before. I know what they are kinda, but could someone give me and example of how to do this?
    :: Sleep is a poor substitute for caffeine ::

  5. #5
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Finland
    Posts
    17

    Re: Terrain reflections problem.

    Use of clipping planes is very simple, just call glClippingPlane(GL_CLIP_PLANEi, clip_plane) and then enable it.

    Code :
    void RenderReflection()
    {
      double clip[4] = {0,1,0,0};//assumes water plane y=0
      glPushMatrix();
      glScalef(1,-1,1);
      glClipPlane(GL_CLIP_PLANE0, clip);
      glEnable(GL_CLIP_PLANE0);
      RenderScene();
      glDisable(GL_CLIP_PLANE0);
      glPopMatrix();
    }
    Hope this helps.

  6. #6
    Senior Member Regular Contributor
    Join Date
    Dec 2001
    Location
    Belmont, CA, USA
    Posts
    216

    Re: Terrain reflections problem.

    How about you clearing the Z buffer after drawing the terrain? Also, make sure you reverse the winding order when you draw the reflection.

  7. #7
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Finland
    Posts
    17

    Re: Terrain reflections problem.

    Originally posted by Jambolo:
    How about you clearing the Z buffer after drawing the terrain? Also, make sure you reverse the winding order when you draw the reflection.
    Doh! I knew I forgot something... Thanks Jambolo for correcting!

  8. #8
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: Terrain reflections problem.

    SLight problem... when i use the clip plane it interferes with my volumetric fog, since this fog is per vertex, and some verteces are cut off my the clip plane, i get fog artefacts near teh water...
    :: Sleep is a poor substitute for caffeine ::

  9. #9
    Junior Member Newbie
    Join Date
    Jan 2002
    Location
    London, England, UK
    Posts
    14

    Re: Terrain reflections problem.

    Have you tried searching the advanced forums? I seem to remember reading several threads about reflections in the past.

    Good luck.

Similar Threads

  1. VBO/IBO Terrain Rendering Problem
    By Erebel55 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-29-2010, 05:38 PM
  2. A problem with reflections.
    By Dawid Dabrowski in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-16-2010, 08:13 AM
  3. a problem about terrain lod using quadtree
    By victorswan in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 05-04-2003, 04:04 AM
  4. Terrain Problem
    By Lsea in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-10-2002, 04:59 AM
  5. Major GL Terrain Problem - Help!
    By TheLabRat in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 05-09-2001, 06:27 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