Waves are coming out jagged instead of smooth

So I am working on a wave/ocean system and I’m using this module made by @iamtryingtofindname: Realistic Oceans Using Mesh Deformation!

When I was testing it, I noticed my waves are very jagged and have very sharp lines as you can see in the video below:

I tried covering it up using the built-in perlin noise feature but it didn’t really work as those jagged lines are still very visible. I feel like the issue could probably be the plane with the bones which I might’ve messed up bc I did do it myself without knowing much about bones and rigging.

I want to achieve smooth waves similar to @tyridge77’s system here: Seamless, endless, and performant custom water using skinned meshes and PBR

But I honestly don’t know how to go about that. Here is the code the does the math calculations to determine the waves:

-- local script
local Wave = require(script.Wave)

local Randomness = {
WaveLength = 70,
Gravity = 1.5,
Direction = Vector2.new(1,0), -- It is 0, 0, so it will use the perlin noise algorithm to make random waves for me
--PushPoint = workspace.Wave1.PushPoint, -- Alternative to Direction, the wave's direction will always push away from the part.
Steepness = 0.6,
TimeModifier = 4,
MaxDistance = 1500,
}

local Wave1 = Wave.new(workspace.ocean_plane3.Plane, Randomness --[[Direction]])

Wave1:ConnectRenderStepped()

-- module made by @iamtryingtofindname (just the calculation functions)
local function Gerstner(Position: Vector3,Wavelength: number,Direction: Vector2,Steepness: number,Gravity: number,Time: number)
local k = (2 * math.pi) / Wavelength
local a = Steepness/k
local d = Direction.Unit
local c = math.sqrt(Gravity / k)
local f = k * d:Dot(Vector2.new(Position.X,Position.Z)) - c * Time
local cosF = math.cos(f)

--Displacement Vectors
local dX = (d.X * (a * cosF))
local dY = a * math.sin(f)
local dZ = ( d.Y * (a * cosF))
return Vector3.new(dX,dY,dZ)
end

local function GetDirection(Settings,WorldPos)
local Direction = Settings.Direction
local PushPoint = Settings.PushPoint

if PushPoint then
local PartPos = nil

if PushPoint:IsA("Attachment") then
PartPos = PushPoint.WorldPosition
elseif PushPoint:IsA("BasePart") then
PartPos = PushPoint.Position
else
warn("Invalid class for FollowPart, must be BasePart or Attachment")
return
end

Direction = (PartPos - WorldPos).Unit
Direction = Vector2.new(Direction.X, Direction.Z)
end

return Direction
end

function Wave:Update()
for _,v in pairs(self._bones) do
local WorldPos = v.WorldPosition
local Settings = self._settings
local Direction = Settings.Direction

if Direction == EmptyVector2 then
-- Use Perlin Noise
local Noise = self._noise[v]
local NoiseX = Noise and self._noise[v].X
local NoiseZ = Noise and self._noise[v].Z
local NoiseModifier = 1 -- If you want more of a consistent direction, change this number to something bigger

if not Noise then
self._noise[v] = {}
-- Uses perlin noise to generate smooth transitions between random directions in the waves
NoiseX = math_noise(WorldPos.X/NoiseModifier,WorldPos.Z/NoiseModifier,1)
NoiseZ = math_noise(WorldPos.X/NoiseModifier,WorldPos.Z/NoiseModifier,0)

self._noise[v].X = NoiseX
self._noise[v].Z = NoiseZ
end

Direction = Vector2.new(NoiseX,NoiseZ)
else
Direction = GetDirection(Settings,WorldPos)
end

local cframe1 = newCFrame(Gerstner(WorldPos,Settings.WaveLength,Direction,Settings.Steepness,Settings.Gravity,self._time))

v.Transform = cframe1
end
end

Any help would be greatly appreciated.

1 Like

Did either of those links mention how to set up the Mesh bones?
You may want to look it up since you appear to be on the right track when you say you may have done it incorrectly.
Maybe search for something like ‘mesh bones ocean waves’ or ‘mesh bones fabric’ to see if there’s a tutorial on how to do it. I haven’t ever tried it so that’s about as much info as I can give you.

1 Like

I used this tutorial to make the plane but it’s very vague and assumes you already know how to use Blender which made me suspect I may have followed it wrong: Making A Mesh Deformation Ocean

I guess I will look more into mesh bones though

1 Like

Nvm I found the solution. There was nothing wrong with my mesh. I just had to play with the wave settings and add more wave calculations to the total displacement to give it a more natural/less tiled feel. It now looks more like @tyridge77’s system

This is the major change that was necessary (this runs for every bone, every step; along with some other stuff but this is what’s important):

local cframe1 = Gerstner(WorldPos,Settings.WaveLength,Direction,Settings.Steepness,Settings.Gravity,self._time)
local cframe2 = Gerstner(WorldPos,250,Vector2.new(1,-1),0.15,Settings.Gravity,self._time)
local cframe3 = Gerstner(WorldPos,250,Vector2.new(1,0),0.15,Settings.Gravity,self._time) -- enable for random waves with no direction
local cframe4 = Gerstner(WorldPos,150,noise,0.15,Settings.Gravity,self._time)
local cframe5 = Gerstner(WorldPos,500,Vector2.new(-0.5,-0.5),0.05,Settings.Gravity,self._time)

v.Transform = newCFrame(cframe1 + cframe2 --[[  + cframe3  --]] + cframe4 + cframe5)

The result is this:

The water texture itself still needs some work but I’m getting there! Next is buoyancy!

1 Like

your ocean looks great, I’d like to see an update if you ever add buoyancy and floating

1 Like

Thanks. I definitely will post an update once I complete it. I’ll probably make a new post under creations feedback when I get there

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.