I’m back! Thanks for all your help previously guys. I have the same project as before, a flight simulator, but I’m trying to revisit it in HDRP. I think the first thing I can do to improve it is use Unity’s HDRP water surface to emulate a real ocean rather than display the flat texture on the normal tiles.
I have the HDRP water surface working, but when I move my player around during runtime then the water behaves strangely in one of two ways.
When I move the player around, the water appears to sit still. As you can see from the transform data in the upper right, the water surface object is moving as we would expect it to when under the influence of a Globe Anchor component. But the material on the object is stationary, moving with the player instead of staying with the terrain.
In this gif you can see that the camera, or rather it’s parent object, is moving as expected. It’s position in unity is 0,0,0.
Now, I have found a hack to get around this, but it isn’t great. If I disable the Globe Anchor and the Origin Shift on the player then I can move around correctly AND the ocean appears to move under the player as I want it to.
However this solution isn’t helpful because I will be moving the player long distances, and therefore I need the origin shifter to be active so I can avoid the floating point errors associated with large numbers.
Am I missing something? Have I set up my objects correctly?
Hi @mtor_nav,
This is going to be a tough one, because it’s probably a limitation of the HDRP water surface. As I think you know, the CesiumOriginShift, by design, keeps the origin of the Unity world centered on the camera. But the water effect appears to be generated based on world coordinates, rather than (for example) based on the relative coordinates within the water surface’s bounding box. That’s why it moves with the camera; because the coordinate system in which the water effect is rendered moves with the camera.
I don’t know if there’s anything that can be changed with the water itself to fix this. Perhaps someone in a more general Unity forum would have some ideas. On the Cesium side, the only thing I can think of that might help is to set the Distance
property on the CesiumOriginShift
component to a higher value - perhaps even matching the repetition distance of the water itself? - in order to reduce the impact of this problem.
This seems to have worked well enough for now. I set the origin shift to 2000. You can still spot it when it updates, but it’s not as obvious.
I have a second issue too, related to the above. When I move the player around, the water plane moves with it. We’ve established a way to make that movement less noticeable, but when I get far enough away the tiles begin to clip through the water.
For the sake of this gif I’ve reset the origin shift to 0 to make the issue easier to see.
As you can see here, the tiles are rising up through the water plane. I believe this problem is caused by the tile’s curvature. Because Cesium treats the map as a (very large) sphere, as the earth “rotates” under the camera and water, the tiles rise with the earth’s geography.
If I move the water plane to be higher, around Y value -16, then the ocean tiles will no longer clip through the water plane. However, then the water plane is much higher and covers more land than it should. I have found that Y value -35 would line up with the shoreline on the tiles quite well if it weren’t for this issue.
Hmm yeah, a water “plane” is simply never going to cut it over a large area on a globe. If that’s the only option with the HDRP water surface, you may be out of luck.