glDepthRange and glowscript

I enjoy making 3D animations with glowscript programs. However, quite often I experience the following two problems:

  1. Objects can be too distant to be displayed even if their size should be large enough to be clearly visible.
  2. When you zoom in some objects disappear even if they are still definitely in front of the camera.

I suspect that it has something to do with glDepthRange from WebGL. Can anybody confirm that? And if yes, would it be possible to adjust the settings of glDepthRange (near and far) from within glowscript?

Poul Riis

That seems unlikely. The depth range probably hasn’t been changed from its initial state of 0…1. It’s more likely due to the near and far distances used to construct the perspective projection. If you can set the projection transformation yourself, it isn’t hard to construct a perspective projection with the far plane at infinity. The near plane is a different matter; making the near distance too small results in the depth resolution being too coarse over most of the scene. The nature of a perspective transformation is such that projected Z (i.e. depth) is inversely proportional to eye-space Z, so too small a near distance results in most of the depth range being used for the region close to the near plane and not leaving much for the rest of the scene.

I have no idea what glowscript is. Ultimately you need to figure out how to choose a projection transformation which is appropriate to the distances used in the scene.

Scenes where depth ranges over many orders of magnitude (including both objects very close to the viewpoint and objects very far away) are typically rendered in layers, with each layer having its own projection transformation, and either each layer using a portion of the depth range or the depth buffer being cleared between layers.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.