Closed AusKarlos87 closed 2 years ago
Hello there !
Thank you for using my shader :)
I think you are right when you are talking about floating point precision issue. When you are using an ArcRotateCamera, your camera is not at the origin of the world, hence you loose precision.
The shader is already using maximum float precision so we can't get more memory here.
To overcome this issue you should make your camera stay at the origin of the world and move the planet accordingly. By doing this you can achieve planet scale worlds (like 1 million units each) with no problem at all (demo here: https://barth.paleologue.fr/planetEngine/ if you are interested)
Unfortunately moving everything around the camera at origin will be a very performance heavy task. The scene contains on average 600 meshed objects most of which use "freezeWorldMatrix" as well as other optimizing techniques when hidden and some path finding AI would need to update their nodes every time a meshed was moved and i also use a 3D GUI that have fixed positions on planets surfaces that are only updated when inside the camera frustum. Suffice to say it would be a daunting task to do and im not sure the engine would cope well at all in moving lots of objects.
Edit: Just thinking about it a bit more. I might be able to have the planet render in a different scene and using the camera at origin and swapping to that scene with a small transition.
Well it doesn't come with some performance cost sadly yes.
But you can attach all your meshes to one parent node that you will be moving. So all the problems of fixed positions and AI won't be affected when working in the space of the parent node :+1:.
The only optimization you will be loosing really is "freezeWorldMatrix" that will indeed not be possible. The engine in itself is quite robust and it's not a few thousand meshes that will scare it haha, you can trust it.
I don't think there is a way to make this shader work without having the camera always at the origin in your case I'm afraid so making this change is necessary, and not as daunting as it may appear at first glance :wink:
Hi BarthPaleologue, I've been testing out your shader in babylonJs to see if has any use with my Project. For the most part its amazing and quite customizable. However my planet system is quite large and it seems that the shader is unable to correctly display the atmosphere scattering effect when the distances in question are above 10,000 units in the engine. It seems that its the distance from origin thats the issue as rotating the arc camera causes the effect to jitter about the place. Its almost like missing float precision .