NVIDIAGameWorks / PhysX-3.4

NVIDIA PhysX SDK 3.4
https://www.nvidia.com/
2.35k stars 273 forks source link

Heightfield resolution limited to 15 bits? (signed 16bit) #83

Open Pitj3 opened 5 years ago

Pitj3 commented 5 years ago

We are trying to use heightfields inside our game engine, we run into issues where the heightfield takes a signed 16 bit integer for height values. Imagine you have a terrain with a 10KM max height, this will result in about 1/3rd of a meter in accuracy (assuming 15 bits, because of the signed bit).

We're working with massive terrains where we can have such high limits in the max heights.

Is there a different option for PhysX to use 32 bit height values or maybe even a different sort of collision (a triangle mesh will be way too dense since we have tesselation on the terrain and the PhysX collision should use the highest tesselated terrain mesh).

As far as we understand currently, PhysX is locked to signed 16 bit height values, which would limit us immensely.

Hope someone can help us out!

PierreTerdiman commented 5 years ago

There is currently no other option for heightfields.

However you could cut your terrain into multiple heightfield patches (one different object for each), each of them with a reduced height delta compared to the full terrain. The height values are then multiplied by a per-object PxHeightFieldGeometry::heightScale value so you could adjust this per patch to increase the accuracy of height samples overall.

Otherwise a triangle mesh is the only other option. It would use more memory than the heightfield but it wouldn't necessarily be slower.

I am not sure I see why "the PhysX collision should use the highest tesselated terrain mesh". Usually it's the opposite, collision shapes are simpler than rendering shapes.