cartographer icon indicating copy to clipboard operation
cartographer copied to clipboard

Vertex morphing

Open darrylryan opened this issue 3 years ago • 5 comments

Hey @arccoza, I've managed to make a nice looking terrain in Godot 4.0 based on your original clipmap shader and its looking really cool! I'm struggling to work out how to stop the noticeable popping between LOD levels though...

I think we need to morph the vertex heights at the edges of the grid towards the position they would be at the next LOD to make a smooth transition, but in practice I've not been able to work out what that position should be.

I don't suppose you've had any thoughts on how to do that?

darrylryan avatar Dec 02 '21 00:12 darrylryan

Hey @darrylryan, difficult to get rid of that pop entirely. One of the things I did was to find a good balance between the size and density of the center and ring meshes (you might want to make this adjustable for performance on low spec machines). High quality normal mapping also helps hide the pop (calc your normals in the fragment shader for better quality).

Also make sure your clipmap is moving at a stride set to a value that matches your lowest clipmap vertex density. It shouldn't be moving unit by unit, but rather every 32 or 64 units so the vertices always land in the position of a previous vertex. There are alternatives that involve filler meshes, but it gets messy (here's the original GPU gems article)

Do you have a vid or gif I can look at?

arccoza avatar Dec 02 '21 03:12 arccoza

Yep, I've got the stride set to the lowest density and it doesn't look bad, but there's still quite noticeable LOD switching. I've experimented with higher strides as well to make it switch less often but of course then you start to leave the high detailed mesh behind as you move and start to see lower LODs under your feet which is probably worse :)

It's not looking bad at all now... and it runs lightning fast... but it still bugs me a bit because you rarely see that in pro games. demoterrain2

darrylryan avatar Dec 02 '21 13:12 darrylryan

Looks good, but also seems like your clipmap meshes might be a bit small, how big are the initial meshes? (Also modern pro engines tend to use tessellation rather than clipmaps, which is something you should finally be able to do in Godot 4).

arccoza avatar Dec 07 '21 05:12 arccoza

I just used your clipmap_multi although I could try scaling it...

It occurred to me as well we do have geometry shaders now in Godot 4... I'll see if I can figure out how to do it without any documentation (yet)!

darrylryan avatar Dec 09 '21 17:12 darrylryan

Yeah, I had planned to explore it as well, but no docs and no time. Let me know if you make any progress.

arccoza avatar Dec 11 '21 18:12 arccoza