-
-
Notifications
You must be signed in to change notification settings - Fork 232
Add ocean mesh #887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add ocean mesh #887
Conversation
|
The other PR could have taken this new branch had you just changed the target and wanted to keep the old. Anyway, I spent some time playing with it and the shader today. I think the functionality and organization are good. I'm not convinced we need tessellation for the ocean, but I suppose it's free to offer the option. We may wish to add vertex spacing. This shader seems a bit expensive. One view showed cutting the FPS in half. 300fps to 150fps. I have a lot of tweaks for the shader to improve the look a lot, but we need to look at the performance first. Looking up a noise texture might be a lot cheaper than calculating it. We should test some other popular ocean shaders and make sure they work just by dropping them in, though we may need to add the code snippet for geomorphing the lods that Xtarsia gave. That should be added here. |
|
I added a fix that I'll cherry-pick out. It will go away after a rebase. I also added some updates to the shader and demo that we'll continue to refine or replace. |
|
OK thanks, I have some more updates based on the review I'm about to push |
|
Oh, also we should pass the heightmap into the ocean shader, so that vertex() can discard itself if it is lower than the terrain height minus a margin. |
Yes, i cant help but think this could also be used for shoreline effects, breaking waves rolling towards the land mass. Etc... |
|
The shadee works well in the mobile renderer, with some optimizations ( size and lod) it doesnt cut that much fps ,though there might be some room of improvement there. I would also add some way to tint the color of water and shoreline might be good , but cost a lot of fps from the shadwr i tested. |
|
I pushed some changes to the shader to get it working (as long as the mesh_size / vertex_spacing etc, are correct) |
a4d53a0 to
d96b25b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting _mesh_size in the ocean shader is a bit broken. First the shader should default to 48 which is the C++ default. But that isn't the cause of this issue.
The ocean handles LODs seamlessly in the editor:
However in game, LODs break apart
And this is weird, in game:
It happens with both meshes, it's just if tessellation is enabled it's really small.
In editor it looks fine:
If in game, you continuously print the _mesh_size shader parameter it shows 48.0. Change the shader parameter to 47.9, the LODs seams and the vertices around 0 are fixed. Reset it back to 48 and it remains fixed.
Every shader we make is everyone we have to maintain. I'm looking at combining the two ocean shaders into one with #defines separating the code for the terrain occlusion. I started on it, but ran into a problem. I should wrap it up tomorrow.
project/addons/terrain_3d/extras/shaders/ocean_shader_with_heightmap_reads.gdshader
Outdated
Show resolved
Hide resolved
|
@TokisanGames @aidandavey , I have some thoughts: Or even, a potentially hot take: this would be better suited as a seperate plugin, giving us Ocean3D, Terrain3D, & Sky3D. Outside of the clipmap, there isnt much linking terrain3D to the ocean mesh. The culling based on terrain height is slower from some quick testing too, simply due to extra bandwidth incured by reading the heightmaps for each ocean vertex. Also it seems in this PRs current state, displacement is non-functional, though I didnt look into which change was breaking yet. Maybe some further discusion needed. This is a pretty big feature in its own right and I feel it shouldnt be rushed without abit more planning & thought. |
|
Adding depth_draw_always to the render mode flags should fix that. |
|
4ff0bec to
b9d014d
Compare
Great job! Looks great and very realistic! |
|
Great progress, this is something I've wanted in Terrain3D and am glad it is taking shape. #298 (comment) River flow would also be nice to be able to designate within terrain3D, as I see water inside your terrains as a part of the whole "terrain" ecosystem.
https://github.com/2Retr0/GodotOceanWaves This shader lacks edge foam. However, it has not been updated for a year, so I could probably add edge foam to it. Edge foam makes a lot of sense considering this is Terrain3D, where there is going to be land lol |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@ChampionX1001 @mikest Both of these comments could be moved and discussed in #298 . |
Thanks for informing us Could you elaborate on whether this PR will support geomorphing vertex code out of the box (via the shader drop-in), because the FFT ocean shader I shared uses vertex displacement. |
|
@ChampionX1001 You can see what's in the PR right now. The sample shader geomorphing in vertex(). I expect every ocean shader uses vertex displacement, so they will all need the vertex code adapted to work with the clipmap. |









Adds a secondary clipmap dedicated to the ocean. The ocean now uses an independent mesher/clipmap so ocean LOD, mesh size and tessellation can be configured and updated separately from terrain.
--
Partially addresses #298