Low poly water splash trail

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
Ats
Posts: 854
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Low poly water splash trail

Post by Ats »

Hello. Today I'm trying to make a moving water splash trail, but with low polygon count.
Something in between this realistic animation: https://app.productioncrate.com/assets/ ... sh-trail-1
and the effect seen on both sides of the boat in Wind Waker:
windwaker.jpg
windwaker.jpg (60.55 KiB) Viewed 480 times

And thanks to the video from that great article about FX in Wind Waker: https://medium.com/@gordonnl/the-ocean-170fdfd659f1
(the first video after the “Shader Vertex” title), I'm using the same low poly half-sphere technique.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" CameraPosition="-0.6472 1.0144 -9.978" CameraRotation="0.0023 91.4897 0" FileVersion="2">
  <OnLoaded>
    <ZExternalLibrary ModuleName="opengl32">
      <Source>
<![CDATA[//

void glBegin(int mode){}
void glEnd(){}
void glVertex3i(int x, int y, int z){}
void glVertex2f(float x, float y){}]]>
      </Source>
    </ZExternalLibrary>
  </OnLoaded>
  <OnUpdate>
    <ZExpression>
      <Expression>
<![CDATA[Time = App.Time;
@RefreshContent(Component :Mesh_WaterSplashTrail);]]>
      </Expression>
    </ZExpression>
    <ZExpression>
      <Expression>
<![CDATA[//

float T, X, Y;

//

T = App.Time;

App.CameraRotation.X = sin(T/2)/32;
App.CameraRotation.Y = T/16;

//

X = App.CameraRotation.X*PI*2;
Y = App.CameraRotation.Y*PI*2;

App.CameraPosition.X = -sin(Y)*cos(X)*10;
App.CameraPosition.Y = 1+sin(X);
App.CameraPosition.Z = cos(Y)*cos(X)*10;]]>
      </Expression>
    </ZExpression>
  </OnUpdate>
  <OnRender>
    <RenderTransformGroup Translate="0 0 -1.2">
      <Children>
        <RenderMesh Mesh="Mesh_Ship"/>
      </Children>
    </RenderTransformGroup>
    <RenderTransformGroup Name="TransformMesh" Rotate="0 0.25 0">
      <Children>
        <RenderMesh Mesh="Mesh_WaterSplashTrail"/>
      </Children>
    </RenderTransformGroup>
    <ZExpression>
      <Expression>
<![CDATA[// Draw grid

glBegin(1);

for(int S=-5; S<6; S++)
{
  glVertex3i(S,0,-5); glVertex3i(S,0,5);
  glVertex3i(-5,0,S); glVertex3i(5,0,S);
}

glEnd();]]>
      </Expression>
    </ZExpression>
  </OnRender>
  <Content>
    <Mesh Name="Mesh_WaterSplashTrail">
      <Producers>
        <MeshSphere ZSamples="3" RadialSamples="16"/>
        <MeshExpression VertexColors="255">
          <Expression>
<![CDATA[if (V.Z == 0) {
  V.X *= 4;
  if (V.Y < 0) V.Y = 0;
  else V.Y += (cos(V.X * Time * 4) * 0.05) * (1 - V.X * 0.5);

  C.R = 1 - V.X * 0.2;
  C.G = 1 - V.X * 0.2;
  C.B = 1;

} else {
  V.Z *= 0.2;

  C.R = 0;
  C.G = 0.8;
  C.B = 1;
}

V.X -= 4;]]>
          </Expression>
        </MeshExpression>
      </Producers>
    </Mesh>
    <Variable Name="Time"/>
    <Mesh Name="Mesh_Ship">
      <Producers>
        <MeshSphere Scale="1 1 1.5" ZSamples="6" RadialSamples="3"/>
        <MeshTransform Position="0 0.4 0" Rotation="0 0 0.083"/>
        <MeshExpression VertexColors="255">
          <Expression>
<![CDATA[//V : current vertex
//N : current normal (turn off AutoNormals when modifying normals)
//C : current color (turn on VertexColors)
//TexCoord : current texture coordinate (turn on HasTexCoords)
C.R = 1;
C.G = 0;
C.B = 0;]]>
          </Expression>
        </MeshExpression>
      </Producers>
    </Mesh>
  </Content>
</ZApplication>
I need to handle the appearance/disappearance of the effect when the object is touching the water or not, and also adjust the length on X for speed, and Y for the depth of the object in the water.

What do you think about the effect? Is this a good approach? Because everything in my game that touches the water will emit something like this. Should it be a shader instead?
User avatar
Kjell
Posts: 1946
Joined: Sat Feb 23, 2008 11:15 pm

Re: Low poly water splash trail

Post by Kjell »

Hi Ats,
Ats wrote: Wed Sep 24, 2025 5:45 pmWhat do you think about the effect?
I assume this is for Omeganaut? It might look a bit flat for objects moving ( primarily ) over the z-axis. Or will you use this on individual wings, like this?

Image

And just to emphasize .. the splash meshes in Wind Waker have a cone-ish shape, which make them look voluminous from every angle.

Image
Ats wrote: Wed Sep 24, 2025 5:45 pmIs this a good approach?
Using a MeshExpression for this kind of effect is a bit awkward, as it's technically closer to a particle system .. except that it generates a solid mesh instead of a bunch of small meshes.
Ats wrote: Wed Sep 24, 2025 5:45 pmShould it be a shader instead?
There's no real good reason to do this using a ( vertex or geometry ) shader.

K
Post Reply