Managing Foreground Clipping
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 316
- Avg merge
- 7h 44m
- Merged PRs (30d)
- 5
Description
It seems to me that objects are clipped at distances close to the camera, where 'close' is somehow dependent on the total extent of all objects in the scene. Here is the full code of one example of the problem:
```
import numpy as np
from mayavi import mlab
import sys
def init_cloud():
pre_x=np.mgrid[-500:500:11j]
x,y=np.meshgrid(pre_x,pre_x)
z=0*x
mlab.mesh(x,y,z,color=(0,0,0),representation='wireframe')
def init_planet(zz=-40000, rr=504000, N=61):
deg=np.mgrid[0:360:((N)*1j)]
rad=np.radians(deg)
phi,r=np.meshgrid(rad,(0,rr))
x=r*np.sin(phi)
y=r*np.cos(phi)
z=0*phi + zz;
planet=mlab.mesh(x,y,z,color=(0,0.2,0))
#planet.actor.property.opacity=0
def main():
if (str(sys.argv[1])=="on"):
init_planet()
init_cloud()
mlab.view(-45,75,1500,(0,0,0))
mlab.show()
main()
```
In my example, I have a wide green circular plane representing the planet's surface (I am aware that the earth isn't flat, but bear with me) whose radius is about 500km, and a black square wireframe of dimensions 1km x 1km.
The planet sits at z=-40000. The wireframe is centered at (0,0,0), which is also the focal point of the camera. The camera's zoom is a distance of 1500 meters in both of the following cases:
- When the planet isn't rendered ("python test_cases.py off"), the wireframe is shown in full, as in figure 1.
- However, when the planet is rendered ("python test_cases.py on"), the wireframe's camera-facing edge is cut off, as in figure 2.
It's worth noting that even when the planet is rendered, but its opacity is set to 0, the wireframe is still clipped as in figure 3.

(Figure 1, wireframe rendered, no planet)

(Figure 2, planet and wireframe rendered, wireframe clipped)

(Figure 3, planet rendered invisible, wireframe clipped)
Given these dimensions, one side of the wireframe is 1000m long with 100m divisions, and the distance from the focal point (0,0,0) to the corner of the wireframe closest to the camera is around 707m. This means that the distance from the camera to the corner is 793m. By comparing the images, the clipping obscures slightly more than 424m of the wireframe, which means that the clipping is occurring 1217m from the camera, meaning that I've lost roughly 81% of objects between the camera and the focal point.
Is there any way to manually control the distance at which objects in the foreground are clipped? In essence, I want to be able to see objects that are closer to the camera while maintaining a large field of view.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.