Water???

Well, I figured i could start out the new forums with a question on water. I am wondering the best place to start implementing water into my game, I understand that the look will be done with HLSL mostly but i am wondering if i should just throw down a plane and start shading it or if there is a better way to go about it. I have read multiple papers on rendering it with multiple methods in order to get the best look and performance but all the methods take some work to get going, so i figured just getting it to show up with a good look is a start. Any help would be appreciated. Thanks.


Answer this question

Water???

  • Dacryphil

    Ok, that sounds like something that i can probably handle, my question is then in managed directx how do you compost multiple meshes. Or is it possible to do multiple passes with on a single mesh to get the same effect. I am just thinking out loud now. Idea



  • LittleG

    as I understand it, you can reduce the complexity of the shader by splitting it into components, applying each component to a separate mesh, and then compositing the meshes. you could write a surface-reflection shader, say, and a separate refraction shader for what's visible under the water, and apply them to two separate meshes -- the refraction shader on a simple flat plane, and the surface shader on a "rippled" mesh. that makes the complex refraction calculation less intense, but gives virtually the same visual result.

    at least, I *think* that's how it works. I'm pretty new at all this myself.


  • St1ck

    There was a sample of water rendering in an old DX8 or DX9 sdk.
    Maybe microsoft should make old sample still available.

    U might also take a look at ATI or NVidia SDK's.
    The ATI tool RenderMonkey has some cool water sample (Reflections Refractions.rfx)

    http://www.ati.com/developer/samples/oceanwater.html
    http://download.developer.nvidia.com/developer/SDK/Individual_Samples/3dgraphics_samples.html


  • Matt213213

    the easiest solution (not necessarily the best) is to make the reflective shader semi-transparent, and just lay the "wave" mesh on top of the "refraction" mesh.

    you could also define the shaders as "fragments", and use fragment linking to attach them to the same mesh. it depends, I think, on how sophisticated you want the results to look. take a look at the FragmentLinker sample in the SDK to see how that's done.

    the refractive shader has to work against the "view" of any objects underwater, so you'd want to render those to a billboard and hand that to the refractive shader as a texture. the refractive shader can then choose the correct texture coordinates based on the current view angle (and water depth) at each vertex in the "refraction" mesh. since it's a non-trivial operation, you'd probably want to make that mesh simpler, and calculate the refraction vertices only where the water changes depth, say. that produces the refracted view of the billboard representing the underwater objects, but that view is really flat.

    you can then lay a semi-transparent "wave" mesh over the top, to handle the specular and environmental reflections and any wave animation you want to use. although the refracted view won't be completely accurate (the water depth would change with the "waves", and that won't be considered), it'll look plenty correct. another "trick" for the reflection shader is to use the view angle to determine the transparency: the more normal your view is to the water surface, the more transparent (less reflective) it should be. that helps avoid the "lake of mercury" effect you sometimes see on completely-reflective water.


  • c# crack

    I wrote a water rendering tutorial. Source code is included and it's a simple normal mapping shader with a perlin noise approximation. I tried my best to keep it simple and informative. If you guys/gals have any suggestions please let me know.

    I hope this helps.
    Take care.


  • Water???