I think precision issues?

I’m back here again with another problem.

I’m rendering large scale terrain where 1m = 1 babylon unit.
I was confident in my lod system so I tried rendering with a size of 12742000m as a diameter.
It did produced good results but when I get to the lowest depth where space between two vertices is 1m everything turns into stairs and the vertices start vibrating when I move.

At first I moved the terrain round the origin while the camera remains at zero and it was working, but when I put the terrain under a transform node then make the node position inverse of where the camera is supposed to be then it stopped working and started making stairs.

game.universeNode.position = game.universeNode.position.subtract(game.camera.position);
game.camera.position = new BABYLON.Vector3(0,0,0);

No matter how many times I press undo to go back to when it wasn’t under a node it still doesn’t work.

Maybe From earth scale to street detail - earth tilling can help.

Thanks for the resource. So the problem is no 64 bit precision in the vertex shader, I would need to emulate it. I will see if I can get it working.

I tried splitting the double to two floats and move the mesh around using the vertex shader.
I then saw this:

It took me about 3 hours to realize that the meshes position in babylon is still at 0 and engine uses that position for a lot of things (like auto frustum culling).

How do I update the meshes position without updating its vertices position? (I don’t even think thats possible) so I can do the split double transform in the vertex shader where it needs it.

1 Like

Doesn’t mesh.position not affect the vertices?

I know if you get up too far beyond four or five digits on the left side of the decimal you start losing fractions… Idk wyt (the same thing would technically happen at 64bit?)

It doesn’t but does affect its world matrix which is needed in the vertex shader.

I temporarily disabled frustum culling and I saw that splitting the double did fix the jittering in the vertices but it didn’t fix the stairs:

This link: https://prideout.net/emulating-double-precision explained something about 64 bit vertices which need two vertex arrays.
I’m going to try that too.

You are not sampling textures as the height or density map and are getting this problem?

How are you caching everything? This is similar to the problem I had when I used int textures to cache my terrain vs float. Looks like your setup is quite a bit different though and might not be the same issue, Id have to see if and how you are caching the buffers.

I wish I could say I was sampling height map textures and pass that as the problem, but I’m not. Using high res textures would be too long to load for earth scale so until I find a good way to load them I’m using a noise function on the CPU.

I haven’t yet done the 64 bit vertices thing yet, I didn’t have time today so I’ll push it to tomorrow.

Do you have a pg running with this?

The code has spanned over many files already but I could try to make it a playground