Three.js: Smart camera parameters

Created on 5 Sep 2018  路  8Comments  路  Source: mrdoob/three.js

Description of the problem

Smart camera parameters to optimize depth accuracy.
We often see z-fighting issue(rendering is flicking) for many models if camera NEAR-FAR range is not minimum (minimum to cover all geometry)
When using OrbitControl or other controls or camera animation, this NEAR-FAR range should be dynamically updated to avoid rendering issue.

Three.js version
  • [ x] Dev
Browser
  • [x] All of them
OS
  • [x] All of them
Hardware Requirements (graphics card, VR Device, ...)

Most helpful comment

It is the user's responsibility to avoid small values of the near plane.

Are you not able to do that for some reason?

All 8 comments

It is the user's responsibility to avoid small values of the near plane.

Are you not able to do that for some reason?

NEAR-FAR range should be dynamically updated to avoid rendering issue.

I've never seen that a 3D or game engine does this. Can you name an example if possible?

I just think it is an enhancement for the dynamic(moving) camera.
The camera needs to understand the situation of the scene to update NEAR plane with optimal value, not by human manually.
As a result, render always render with the best accuracy.

There is no way for the library to know what is optimal for your use case. Your feature will have to be implemented in the application layer.

I've never seen that a 3D or game engine does this. Can you name an example if possible?

@Mugen87
My engine does that :)

I'm not very sure if that's a good idea overall or not, as you end up with a bit of flickering when clipping planes are adjusted. For me the results have been great so far, but your mileage may vary.

I do a search query on scene BVH to determine depth clipping planes before rendering takes place.

@Usnul It would be interesting for @whatisor if you can share a link to your code :+1:

@whatisor You can also have a look at certain model viewers. They also perform such an adjustment based on the size of the model's bounding box:

https://github.com/donmccurdy/three-gltf-viewer/blob/f9a7accd380ed2eaa64b6debaa56510246bf06dc/src/viewer.js#L228-L229

Thank @Usnul, in fact, I am considering if we ought to make it as renderer feature to make it work in the best accuracy with any camera parameters and scene.
Just a suggestion! :)

Closing, as @WestLangley said this needs to be implemented in the app layer.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jack-jun picture jack-jun  路  3Comments

danieljack picture danieljack  路  3Comments

Horray picture Horray  路  3Comments

akshaysrin picture akshaysrin  路  3Comments

scrubs picture scrubs  路  3Comments