Results 1 to 5 of 5

Thread: [OpenGL] Water & the Stencil Buffer

  1. #1
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    [OpenGL] Water & the Stencil Buffer

    I've been looking into the Stencil Buffer lately in an attempt to make my first actual 3D effort with a little water demo. Any tips, etc would be appreciated as this is rather new to me. I've read the Red Book somewhat but it's still fuzzy to me how it works. Anyone care to break it down into an easy explanation?

    Ultimately I'm going to be putting my generated water into Garland's Quest after I'm done. So you kind of get the idea of what type of effect style I'm going for. More a lake or pond type of water than an ocean type of water.


    Here are some resources I'm reading to get my information:

    Stencil Buffer overview
    a brief 'How to do water'

    a glscene demo's way I'm trying to follow using the stencil buffer

    a whole shpeal on Perlin noise <- I think this is supposed to be more ocean water than lake or pond type water?
    GameDev.net article about how to do it, but the effect is more so for rain or water-drop effects than a tidal water motion

    a Very Cool Caustics Generator program that creates those really neat lighting effects on the bottom of a pool or shallow clear waters <-- I've made up textures to use from this as the effect is very nice.
    The Volition demo's water here looks great but I'm not sure I want to dig right in there and try to extract and recreate it...

    Anyhow comments and sugestions or heck, simple code! would be well appreciated.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  2. #2
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Re: [OpenGL] Water & the Stencil Buffer

    I did it! This is also my first 3D program btw! Yay for me... updated my blog with the details and a link to a little demo of it. Have a look for yourselves.

    http://redantproductions.blogspot.co...ade-water.html
    Jason McMillen
    Pascal Game Development
    Co-Founder





  3. #3

    Re: [OpenGL] Water & the Stencil Buffer

    Looks good, but kind of plastic though.

    For 3das i took a more basic approach. I just took a water texture aplied that to a plane that i made transparent. That was enough for me back then.

    Basicly a stecil buffer is what it is&#160; a stencil.
    E.g. take a piece of paper. Cut a round shape in the middle.
    Apply it on another piece of paper. Get some paint and paint over the top paper completely even over the hole.
    Now when you remove the top paper you have painted round shape on bottom piece of paper.

    For opengl look at this classic example:
    http://www.opengl.org/resources/code...s/Reflect.html
    http://3das.noeska.com - create adventure games without programming

  4. #4

    Re: [OpenGL] Water & the Stencil Buffer

    I wrote a demo a while ago using some nice water in Glxtreem, it was ages i touched it so i'm kindof rusty of what i did, but take a look anyway!

    http://phoenixlib.net/files/glxWater.zip
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  5. #5
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    Re: [OpenGL] Water & the Stencil Buffer

    Well this is going into Garland's Quest so I don't think that a little surrealism will hurt. I just have to remove a funny little glitch that appears along the edges.

    As for the Stencil Buffers well that's something to tackle down the road I think. Thanks for the explanation and links. I'll be bookmarking and looking it up in the near future I'm sure.

    Next thing I think I need to learn is lighting and how to make better use of light... it would add to the shine and watery look would it not?
    Jason McMillen
    Pascal Game Development
    Co-Founder





Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •