Search Unity

Volumetric Water

Discussion in 'Editor & General Support' started by zumwalt, Feb 28, 2008.

  1. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    How do I add volume to Water or at the very least add water effect to a sphere or cube to get volume instead of a water plane? I want to add some volume to this pond then add friction to it in code after I get the volume thing worked out. (BTW: Terrain ROCKS)
     

    Attached Files:

  2. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    What do you mean by add volume to your water? In the island demo we colored the terrain lightmap with a script that casts rays to measure the water depth. You could do something like that, or a more complex approach using a render texture to get the distance between the water surface at each screen pixel and the surface under the water. This would involve redoing the water shader.

    If you want water on a cube or sphere you will also need to redo the water shader to use a cubemap reflection. You will also need to render to a cubemap each frame which will get slow quick.

    What do you mean by add friction to the pond? Do you mean this: http://forum.unity3d.com/viewtopic.php?t=5796 ?
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can't really add volume to anything in 3D; you just fake it instead. Like I did with the underwater stuff in first-person mode in Fractscape. That's fog + particles + flipped plane with water shader + refractive glass shader (in Fantastic mode, anyway). The "friction" is just slowing down the fp controller when under the water's surface.

    --Eric
     
  4. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
    Its possible to get the depth of a convex object by rendering the depth of its front and back facing polygons and then doing a subtraction, but that method is quite complicated and doesn't really translate to real world situations.

    I think similar methods could be used on water, maybe even well enough to get "real" depth-of-refracted-pixel-direction-thingy but that would be quite complicated, and I don't know if it would even look good.
     
  5. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Well, what I want to do seems to be a mixture of what you have done Yoggy and what EricH has accomplished. I'll have to look at your project that you posted then figure out the underwater effect that EricH has accomplished.

    Thanks to both I know it can be done.
    -Zumwalt
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Oh yeah...+ light cookie for the caustic effect. ;) Doesn't work with the Unity terrain yet though.

    --Eric