Realistic FFT Ocean

YOOOO!! :tada:

Roblox just published an update making In-Experience Mesh & Editable API available in live experiences!

Now you can fully check out the experience yourself without any tinkering

(also added a time changing script to showcase the mesh normals and caustics)

I’ve also witnessed it being quite unstable, working for some people while not for others. Confirmed that it’s an issue with mobile

7 Likes

@IcyMonstrosity its laggy but otherwise its awesome

1 Like

DAMN
image

Hey man, i was wondering, when reading through your code (at the moment im experimenting with editable meshes myself), I have 2 questions, one,


how did you come up with those numbers that are applied to the vertexID inorder to find the relating id, eg the color id or normal id,

and question 2, would finding this out fix my current problem with my flipbook-based fft ocean
problem:

For some reason each of the IDs (Vertex, Triangle, Normals) have different starting positions, I got this number just by subtracting that offset. There’s also a version without the hard coded values which has to index a table each time it wants to get the relevant ID. This was primarily a slight performance decision, it’s a lot better to just add N rather than indexing a table with N.

Potentially? I’m unsure of the cause of the issue you have but the UV coordinate of the vertices might be the issues. I don’t actually use UV coordinates here, since the color is based on the vertex.

How do you mean, ‘subtracting’ the offset, wouldnt that number just be a vector2? or are you talking different positions in the array?,

the reason i say this, is because :setfaceuv’s constantly gives the error ‘invalid id’ even after finding the offset/using your example.


I’m talking about the ID, which is an integer, you can just do this by keeping count of the number of UV IDs and then subtract the ID that returns from :SetFaceUVs with that number, giving you a constant number.

The problem you’re facing is probably because of an incorrect vertex ID. You can compare it with my implementation if the values aren’t the same:

for X = 1, FOURIER_SIZE-2 do
		for Y = 1, FOURIER_SIZE-2 do
			local Vertex1 = X * FOURIER_SIZE + Y
			local Vertex2 = Vertex1 + 1
			local Vertex3 = (X + 1) * FOURIER_SIZE + Y
			local Vertex4 = Vertex3 + 1

			
			local Face = OCEAN_MESH:AddTriangle(4294967296+Vertex1, 4294967296+Vertex2, 4294967296+Vertex3)
			OCEAN_MESH:SetFaceColors(Face, {12884901888+Vertex1, 12884901888+Vertex2, 12884901888+Vertex3})
			OCEAN_MESH:SetFaceNormals(Face, {8589934592+Vertex1, 8589934592+Vertex2, 8589934592+Vertex3})		

			local Face = OCEAN_MESH:AddTriangle(4294967296+Vertex2, 4294967296+Vertex4, 4294967296+Vertex3)
			OCEAN_MESH:SetFaceColors(Face, {12884901888+Vertex2, 12884901888+Vertex4, 12884901888+Vertex3})
			OCEAN_MESH:SetFaceNormals(Face, {8589934592+Vertex2, 8589934592+Vertex4, 8589934592+Vertex3})		
		end
	end