Mesh distorted when camera collides with it

Heya, I ran into a weird issue playing with the playground on the Camera Collisions documentation. After the camera collides with the barrel mesh at certain angles, part of the barrel mesh becomes transparent or drawn over. The below playground has the camera’s position and target set so that if you press the up arrow to move forward it will reproduce the issue.

This is called clipping and happens not only with collision but as soon as the camera is too close from something.

Basically the depth infomation are stored in a tiny place in gpu memory without infinite precision so when defining a camera you would chose the range it sees from a min value to a max one: interesting read about tweaking the storage layout to gain more precision in some cases: Logarithmic Depth Buffer

So in Your case some part of the box are drawn closer to the camera than its defined minZ.

You could chose a different one or create a bigger elipsis:


Thanks @sebavan, I tried lowering minZ and found 0.45 to work well for this setup (instead of 0.5). Maybe it would be good to update the playground linked in the documentation too, to either use a bigger ellipsoid or a smaller minZ? :slight_smile:

1 Like

Adding @PirateJC for this part :slight_smile: (I bet at some point he will hate me for this)

1 Like

Thanks again for finding another one @Blake !

This is now fixed!

Should be live in a couple of minutes.

@sebavan - I could never hate you.



Correction: I could never hate you… MORE :wink: