Detegr / openRBRVR

Open source VR implementation for Richard Burns Rally
Mozilla Public License 2.0
32 stars 6 forks source link

Suggestion: Reversed-Z Buffer for high precision #12

Closed retroluxfilm closed 1 month ago

retroluxfilm commented 8 months ago

I just saw you implementation note after I forked your repo and stumbled upon the Z-Fighting issue. Reverse Z-Buffer is a real improvement especially on large stages. For GTR2 it also helped to resolve a lot of Z-Fighting flickering. ( Which I personally did not yet encounter on RBR)

Just a tip you can try out: https://developer.nvidia.com/content/depth-precision-visualized

Feel free to close this issue if its not relevant anymore.

Detegr commented 8 months ago

This is super interesting, I hadn't heard of reverse-z before. I'll come back to this at some point, this would be a nice thing to implement.

The current implementation reduces Z-fighting by rendering the cockpit that's near the driver with different projection matrix than the rest of the stage. It works quite well, although there are some noticeable artifacts sometimes where the stage gets clipped if it comes too near to the driver's eyes, like when driving into a snowbank. It's a bit of a hacky solution though, so this would most likely yield better results.

retroluxfilm commented 8 months ago

Great to hear that it might be helpful. Your solution to split the cockpit and the stage to different matrix is pretty smart trick as well. I did not notice any issues and possibly only happens on the edge cases you explained. On GTR2 it was tricky as the tracks had many decals that where placed close to the track, like the line markings on the road and the light and shadow planes. Reverse Depth fixed all the flickering issues, even on using integer depth precision.

Detegr commented 1 month ago

I'd like to thank you again for this suggestion. I have a rough implementation ready and the results are very promising! This is something that could be beneficial to RBR in general as there are Z-fighting issues on some long stages and this seems to just fix those once and for all.

retroluxfilm commented 1 month ago

Sounds great. Glad I could help with my little hint. Looking forward on how it plays out in RBR. Thanks for your effort making RBR a better game!