Realistic Oceans Using Mesh Deformation!

Yep

Its not the atmosphere, I deleted that. It seems that its not related to the mesh, but rather the reflection distance limit on any part surface. I added a big part with a texture and it does the same thing as you zoom away the reflection does not render(and so you lose the perception of waves and depth).

Look at the sun reflection in the first shot, then in the second screenshot it is gone(along with the wave reflections)


3 Likes

Its a limitation in the lighting technology. Your map was on Compatibility. I changed to Shadow Map and it renders the reflections up to 600 studs. Better, but still not enough to be useful for flying.

2 Likes

Maybe make a post in #help-and-feedback , as I’m pretty sure there is a way around this. I think this has something to do with the lighting and PBR.

(Also sorry for late reply. I told myself I was going to, but I completely forgot)

This is beautiful! I expect nothing less from you. Oh and
君も!

1 Like

Wow! Those results look very impressive! (I would say better than Roblox’s own water implementation). Keep up the great work!

1 Like

How did you make the Plane with more vertices than 4? I made a whole thread about it but nothing worked?

1 Like

You have to make sure that the bones is rigged to the plane. Check out this tutorial for more details.

1 Like

So it’s not possible to add the bones on roblox in a for loop it needs to be done in blender?

Yeah, pretty much. Add the bones in blender, rig it there, then import it using the avatar importer (it allows for more tris)

image
Whys there a virus in the demo place?

2 Likes

It was from an old plugin of mine, I have since removed it. You can just delete the script, I should probably update the demo place. However the virus doesn’t do anything, I have done toying around with it, it has stopped working. I reccomend you remove it, it was inserted by a plug-in of mine.

A simple delete should stop the virus, not sure what it does.

2 Likes

Very nice module! I think you could do a lot more with this than just oceans, for example moving trampolines… Or nets… Speaking of trampolines and nets, does the module provide any possibility to change the settings after the Wave object is created, such as gradually reducing the timemodifier or wavelength?

Yes! The :ConnectRenderStepped() method on a wave updates the wave every frame based on the wave settings. You can edit the properties on he wave object itself and it will update automatically. This weekend I plan on adding a function to update the wage’s WaveSettings to make what you describe easier to do.

1 Like

I’m having some trouble trying to add my own function into the module for finding the height of the water’s plane given a coordinate, i’d assume it’s just plugging in the target position into the gerstner function + account for perlin noise, but mine appears to be out of a sync the farther i get from a bone. Am I handling this in the right way? I suppose another way of solving this would be approximating height based on the closest surrounding bones, but I have no clue which method would be more efficient. Here’s what I have so far, it’s not much-but the main problem i’m trying to troubleshoot is the “de-sync”

https://gyazo.com/9e79ea2631f3225c2ef6f6fd29e78ca4

https://gyazo.com/43a0727f9b38264375050ec2067f0742

function Wave:GetHeight(pos)
	local Settings = self._settings
	local Direction = Settings.Direction
	
	if Direction == EmptyVector2 then
		--account for noise (havn't done this yet, so I just set the Direction to Vector2.new(0,1) for the meantime )
	else
		Direction = GetDirection(Settings,pos)
	end
	
	return (Gerstner(pos,Settings.WaveLength,Direction,Settings.Steepness,Settings.Gravity,self._time).Y)
end

I barely got by in Pre-Cal 1, so pls b kind if i’m missing something obvious.

edit: I’m also just using a BodyPosition to position the character on the Y axis, and it seems responsive enough so i’m assuming it’s a fault with my implementation.

3 Likes

This is because the gernstner wave formula returns a x, y, and a component, meaning that the x and a components are not always the same. You are simply ignoring the x and z components, making it appear delayed because the corresponding y axis belongs in a different x and z position. I reccomend going with the second option. You might be able to use @Quenty ’s octree tree module to find closest bones. You might have to average the y positions in the bones. Hopefully Roblox will add physics and collision to support to bones and skinned meshes to make this process automated.

1 Like

Thank you very much for your reply, you definitely led me in the right direction. Although even after getting the mean average of heights of nearest bones-the accuracy is still a little off. I know I should probably do more than just average the heights, but i’m not sure what… I tried doing a weighted average by assigning low weights to farther bones, and then averaging them-but that failed as well. I really want to find a slightly more accurate way to approximate without increasing bone density. Any ideas?

Here’s what I’ve come up with so far

https://gyazo.com/3bb4c4c9d6ec7c8556b56984dbde84f2

local RunService	     = game:GetService'RunService'
local ReplicatedStorage	 = game:GetService'ReplicatedStorage'

local Player		 = game.Players.LocalPlayer
local RootPart		 = Player.Character.HumanoidRootPart
local Plane			 = workspace:WaitForChild("Wave"):WaitForChild("Plane")

local BodyMover		 = Instance.new'BodyPosition'
BodyMover.MaxForce	 = Vector3.new(0,math.huge,0)
BodyMover.D		     = 625
BodyMover.P		     = 20000
BodyMover.Parent	 = RootPart

local LoadCustomLibrary	 = require(ReplicatedStorage:WaitForChild("Nevermore"))
local Octree		     = LoadCustomLibrary("Octree")

local planeOctree = Octree.new() --no idea if i'm using the octree module correctly/efficiently, but it seems simple enough
for _,v in pairs(Plane:GetDescendants()) do
	if v:IsA("Bone") then
		planeOctree:CreateNode(v.WorldPosition,v)
	end
end

local sampleRadius	 = 100
local maxSamples	 = 3

RunService.RenderStepped:Connect(function()
	
	local closestObjs,distances = planeOctree:RadiusSearch(RootPart.Position,sampleRadius)
	local sum = 0
	
	--for _,v in pairs(closestObjs) do --unsure if this is less efficient or not, probably dependant on num of samples
	--	local pos = v.TransformedWorldCFrame.p
	--	sum = sum + pos.Y
	--end
	--local average = sum/#closestObjs
	
	local numSamples = math.clamp(#closestObjs,0,maxSamples)
	for i = 1,numSamples do
		local v	 = closestObjs[i]
		local pos = v.TransformedWorldCFrame.p
		sum = sum + (pos.Y)
	end
	local average = sum/numSamples
	
	BodyMover.Position = Vector3.new(0,average,0)

end)

3 Likes

Actually forget what I said about averaging, how about you use the Octree module and find the closest bone. As long as there are enough bones, it will be accurate enough.

1 Like
Out of curiosity, why does your sample file have a hidden backdoor in the Terrain instance?

https://gyazo.com/83af21c757cec346e62f4dd4baac0366

I have already addressed this

I plan on re-adding the models without the virus

EDIT:

I have re-added the models with the virus removed. It was a fake Gui-to-Lua plugin I was using to make guis for plugins.

1 Like

Is there a way to run :ConnectRenderStepped() on variable frequency (1-60hz for example), depending on how far the character is? It lowers FPS a lot in my game.