Unity Community


Results 1 to 12 of 12

  1. Posts
    84

    Real Ocean Waves On Water

    while the shader effects look great, real time wave action is a must for anything more than water in a pond or swimming pool...

    is there any chance this feature will see the light of day...

    thx

    --Mike

  2. Volunteer Moderator
    Posts
    23,711

    Re: Real Ocean Waves On Water

    That's quite possible right now; you can deform the ocean mesh in realtime. For example, if you take the sinus curve modifier example from the procedural mesh examples, and apply the script to a plane, and change the "vertex.y += ..." line to:

    Code:  
    1.         vertex.y += Mathf.Sin(Time.time * speed+ baseHeight[i].x + baseHeight[i].y) * (scale*.5)
    2.                  + Mathf.Sin(Time.time * speed+ baseHeight[i].z + baseHeight[i].y) * (scale*.5);

    then you get some nice rolling waves. If you're using reflective water, the reflection will be kinda wonky, but short of ray-tracing I'm not sure if there's much to be done about that.

    --Eric


  3. Location
    32.71 N, 117.15 W
    Posts
    5,419
    I'm guessing that what you're looking for is more of a "realistic ocean water shader" similar to what Quest3D and DX Studio have. There have been several posts by people who may be working on this, not sure of their progress:

    http://forum.unity3d.com/viewtopic.p...ighlight=waves

    http://forum.unity3d.com/viewtopic.p...=waves&start=0

    An ocean wave shader is on my "want" list also. If someone develops such a thing for Unity and is interested in licensing it, I'm interested.


  4. Location
    NE Ohio, USA
    Posts
    7,173
    Quote Originally Posted by bigkahuna
    I'm guessing that what you're looking for is more of a "realistic ocean water shader" similar to what Quest3D and DX Studio have.
    I don't get that impression. I think he means the kind of thing that Wave Race 64 introduced.

    I'll be interested in doing this when I have time, so thanks, Eric, for a method to get started.


  5. Posts
    137

    Lost

    That's quite possible right now; you can deform the ocean mesh in realtime. For example, if you take the sinus curve modifier example from the procedural mesh examples, and apply the script to a plane, and change the "vertex.y += ..." line to:

    Code:
    vertex.y += Mathf.Sin(Time.time * speed+ baseHeight[i].x + baseHeight[i].y) * (scale*.5)
    + Mathf.Sin(Time.time * speed+ baseHeight[i].z + baseHeight[i].y) * (scale*.5);


    then you get some nice rolling waves. If you're using reflective water, the reflection will be kinda wonky, but short of ray-tracing I'm not sure if there's much to be done about that.


    I'm completely lost as to what that means, could you walk me through your instructions?


  6. Posts
    137
    Is there a way to alter the mesh resolution for a plane. I'm trying to create a object whereby I can adjust the wavelength so that I can show a boat traveling through the water and through a gui change the wave height and "speed" of the waves. I put speed in quotes because I'm planning on having the boat stationary and have the water oscillate faster to simulate the boat moving. The problem I'm having w/ this particular code is that I can't get a good wavelength.

  7. Volunteer Moderator
    Posts
    23,711
    Quote Originally Posted by ungoliath
    Is there a way to alter the mesh resolution for a plane.
    The resolution is whatever you make it.

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  8. Posts
    137
    I mean can I alter the resolution based on a game input?

  9. Volunteer Moderator
    Posts
    23,711
    Quote Originally Posted by ungoliath
    I mean can I alter the resolution based on a game input?
    You can do whatever you want. http://unity3d.com/support/documenta...ence/Mesh.html

    --Eric
    SpriteTile: new tile system that works seamlessly with Unity 4.3 sprites
    FlyingText3D: dynamic 3D text with TTF fonts | Vectrosity: fast & easy line drawing
    Nifty utilities! Stitch terrains together - runtime model importing - file browser - fractal landscapes


  10. Posts
    137
    I'm trying to have a single wave travel across the plane to start slow. In this script I've tried just to deform the mesh but it's not working. Can anyone tell me what I'm doing wrong?

    private var baseHeight : Vector3[];

    function Update () {
    var mesh : Mesh = GetComponent(MeshFilter).mesh;

    if (baseHeight == null)
    baseHeight = mesh.vertices;

    var vertices = new Vector3[baseHeight.Length];
    for (var i=0;i<vertices.Length;i++)
    {
    var vertex = baseHeight[i];
    vertex.y = vertex.y * 1.1*Time.time;
    vertices[i] = vertex;
    }
    mesh.vertices = vertices;
    mesh.RecalculateNormals();
    }


  11. Posts
    137
    For anyone else needing to change the mesh density

    http://answers.unity3d.com/questions...eated-in-unity


  12. Location
    Arlington, VA
    Posts
    1,356
    I think the problem with providing a general solution here is that everyone will want different things. Is it cosmetic or is it supposed to drive physics?

    As Eric points point, the basic math for propagating waves through a mesh is trivial (and indeed running "swell" (tidal wave action) and "chop" (wind-driven waves) at different angles is just a matter of picking frequencies, amplitudes, and directions and adding offsets.) But if you want to be able to do bouyancy or displacement by ships or splashes... Foam?

    Even in the non-realtime world water is a huge issue and tends to be handled as a special case pretty much every time.

Posting Permissions

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