I'm making a sea with waves and buoyancy
I've got running a shader that modifies vertices height so I've got a visual sea going on, but I have trouble getting the vertices height to implement buoyancy. That's the only parameter I need to succeed. I'm using a shader material in a PlaneMesh that I've subdivided.
My sea level is not constant because It's got waves so I can't use y=0 as reference. I've tried 3 aproaches unsuccessfully thus far:
-Trying to get the height back from a shader -> Turns out you can only get uniform params and those can't be modified inside the shader as far as I know
-Using MeshDataTool to access the vertices -> Somehow even if the shader modifies the vertices, they all keep their y=0 when I access them via MeshDataTool, I've tried creating a new MeshDataTool every frame too
Samplecode:
extends MeshInstance
(...)
var surface_tool = SurfaceTool.new()
var mesh_data_tool = MeshDataTool.new()
surface_tool.create_from(mesh,0)
var array_mesh = surface_tool.commit()
mesh_data_tool.create_from_surface(array_mesh,0)
-Generating a collider with createtrimeshcollision() and createconvexcollision() -> The resulting collider is always a plane, no waves to be touched. Maybe it could be a way to generate a collider from vertices? Either way I haven't found either the way to do that nor the way to get those vertices correctly
It is absolutely needed for the final result to be a sea in movement in which is possible to sample the varying height at any point, if you have any suggestions in the way of achieving that it would be most welcome
Thanks in advance