JDK-8104138 : Re-evaluate the values and range of near and far clipping planes of Camera
  • Type: Task
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2013-07-09
  • Updated: 2015-06-16
  • Resolved: 2013-09-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Description
This is a follow-up issue of RT-29982 which I didn't realize was restricted to the fixedEye for some reason. I think the clip planes make much worse problems in the default eye position. If you create a usual-sized scene and assign a default perspective camera to it, the eye will be placed around and behind Z=-1000. So anything on the zero plane will be far behind the far clip plane. This can even be considered a serious regression, because if the clipping worked in rendering, I think Ensemble wouldn't show anything (the various 3D demos likewise). Also, take any 2D app, use a perspective camera, and most likely all the content will be out of clip planes. I guess the only reason this has not yet come up as a critical issue is that the near/far clipping doesn't work.
Comments
I'm OK with that, just please make sure it is clearly explained in the documentation (RT-33273).
05-11-2013

Pavel: JavaFX supports 2 perspective camera modes. What is described here is for the model where the fixedEyeAtCameraZero is false. Whereas in the other model (fixedEyeAtCameraZero=true), the 3D world is specified in the normalized space to fix in the view frustum. Hence that is the natural coordinate space to specify the near and far planes, just like other 3D systems
05-11-2013

Thanks, Chien. This works for the default camera, however, the fixed-eye behavior doesn't conform to the definition. It doesn't consider the focalLength and ignores position of projection plane. If farClip is set to 100, it cuts off anything that has Z > 100, regardless of the projection plane being somewhere around Z=1000 (so according to the definition it should cut off objects with Z > ~100000). Is this intended? If so, should we at least document the disjointed definition of the eye coordinate system (mentioned in the near/far clip javadoc)?
17-09-2013

I believe the earlier confusion was caused by the following 2 issues: RT-32880 and RT-32879 on Windows where prism-d3d is the default pipe.
14-09-2013

Evaluation completed. A near value of 0.1 and far value of 100.0 in the eye space are good default.
14-09-2013

The JavaFX eye space is a coordinate system in which the eye is positioned at the origin, and the projection plane is placed 1 unit length in front of the eye in the positive Z direction. The default PerspectiveCamera, where the fixedEyeAtCameraZero is false, fieldOfView is 30 degrees, and the verticalFieldOfView is true. In this mode, we fixed the projection plane at Z = 0 in the scene space, and positive Z direction is into the screen. The following code segment is the trigonometry needed to compute the near and far clips distance in the scene space: final double tanOfHalfFOV = Math.tan(Math.toRadians(FOV) / 2.0); final double halfHeight = HEIGHT / 2; final double focalLenght = halfHeight / tanOfHalfFOV; final double eyePositionZ = -1.0 * focalLenght; final double nearClipDistance = focalLenght * NEAR + eyePositionZ; final double farClipDistance = focalLenght * FAR + eyePositionZ; where FOV = the field of view in degrees, NEAR = near value specified in eye space, FAR = far value specified in eye space. A test program, NearAndFarClipTest.java, to illustrate the concept is in rt/apps/toys/FX8-3DFeatures.
14-09-2013

Will get back to you soon. A bug in the d3d pipe threw us off when verifying the math, but I was able to confirm the math is correct with the es2 pipe. The is a simple transformation to map scene coordinate to the eye coordinate for the default PerspectiveCamera. I will write it up for you later.
10-09-2013

Could you please explain the eye coordinate system to me? I probably need to fix the picking code..
06-09-2013

Oh, then we have picking implemented wrong. We compare the clipping distances to the intersectedDistance which is in scene coordinate system. Could you please explain the eye coordinate system to me?
16-07-2013

I don't think there is a problem -- at least not the one you describe. The clipping planes are in *eye* coordinates which are not the same as world/scene coordinates. The fact that the camera it is at -1000 in scene coordinates and the default 2D plane is at 0 in scene coordinates doesn't matter. In eye coordinates, the camera will be at 0 and the 2D plane will be at 1.
16-07-2013