View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007823VTK(No Category)public2008-10-17 11:062016-08-12 09:55
ReporterSerge Lalonde 
Assigned ToDave DeMarle 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0007823: Near plane clipping problem with vktRenderer and vtkCamera
DescriptionI have noticed that it is very easy to cause the near clipping plane to cut-off the model when in parallel projection mode.

I ran into this recently when adding a vtkBoxWidget and scaling a simple cube a few times after rotating it so that one of the corners points towards the viewer.

I tried calling vtkRenderer::ResetCameraClippingRange() to no avail. vtkRenderer::ResetCamera() fixed the problem, but would lose my camera setting.

After searching fruitlessly in the vtkusers archives, I decided to trace into the code and I discovered that there is code in vtkRenderer::ResetCameraClippingRange() and vtkCamera::SetClippingRange() that modifies the near plane value to "fix" potential camera and depth buffer problems. In my opinion, these fixes are valid, but only for perspective projections. For parallel projections, they are unnecessary and in fact cause the clipping problem I was encountering. To test this, I modified the code and rebuilt and lo and behold, no more near plane clipping!

Attached is my modified version of vtkCamera.cxx and vtkRenderer.cxx along with the patch files relative to version 5.2.0 (only vtkCamera.cxx has changed since then). The changes are small and localized.
TagsNo tags attached.
ProjectTBD
Typeincorrect functionality
Attached Filescxx file icon vtkCamera.cxx [^] (32,507 bytes) 2008-10-17 11:06
cxx file icon vtkRenderer.cxx [^] (57,287 bytes) 2008-10-17 11:07
patch file icon vtkCamera.cxx.patch [^] (352 bytes) 2008-10-17 11:07 [Show Content]
patch file icon vtkRenderer.cxx.patch [^] (1,166 bytes) 2008-10-17 11:07 [Show Content]
? file icon vtkCamera.cxx.patch-unified [^] (575 bytes) 2009-11-02 23:12
? file icon vtkRenderer.cxx.patch-unified [^] (1,718 bytes) 2009-11-02 23:12
? file icon vtkCamera.cxx.patch-unified_2 [^] (575 bytes) 2009-11-03 01:27
? file icon vtkRenderer.cxx.patch-unified_2 [^] (828 bytes) 2009-11-03 01:27

 Relationships

  Notes
(0016040)
Gerrick Bivins (reporter)
2009-04-16 09:03

I also ran into this issue. The attached patches addressed my problems using VTK 5.2.
(0016730)
Ben Held (reporter)
2009-06-16 10:03

I ran into this as well and the attached patches solved my problem as long as I called ResetCameraClippingRange as needed. I recommend incorporating these in the next VTK release.
(0018324)
edice (reporter)
2009-11-02 23:12

I wanted to try out this patch, but it was not in unified format and did not apply cleanly.

So, I have attempted to recreate the patch in unified format. It compiles, I assume it works.
(0018325)
edice (reporter)
2009-11-03 01:39

I found the patches I uploaded did not allow non-parallel-projection mode to work in the same way as it used to.

I simplified the patches down to its essence, now there is the original code for perspective-projection-mode, and an else{} block for parallel-projection. I believe it now works the way the original poster intended.

I have not tested it in parallel projection mode yet. I suspect it may cause trouble with the depth buffer:

In Perspective-projection mode, there is extra logic to push the Near plane AWAY from the camera, to ensure the clipped range is not too "broad" for the depth buffer.
distance_near / distance_far >= 0.001
so 2/4 = 0.5 -- ok
but 1.5 / 10000 = 0.00015 too broad, near plane will be adjusted so its distance from the camera is 10.
This seems to be the cause of the "near objects clipped at near plane" problems. The only "solution" is to back the camera away from the near objects until the near/far ratio is smaller.

All this is not considered in the Parallel Projection code path, and as such it may cause Depth-Buffer related rendering errors.
(0019938)
xabi riobe (reporter)
2010-03-17 12:45

I would also like to see this issue solved in the next vtk release!
(0031489)
Serge Lalonde (reporter)
2013-08-20 15:03

This issue isn't fixed in 5.10 and I compared the code in 6.0 and it still doesn't look fixed (I can't update to 6 right now for a proper test, sorry).
If it has indeed been fixed, please go ahead and close this issue. Otherwise, there are several users (myself included) who would appreciate this fix being incorporated in the next release.
I had originally submitted the fixed code (which must be updated for the new version), but the core of the changes are there.
Thanks.
(0031943)
Dave DeMarle (administrator)
2013-12-16 12:14

Reformatted as gerrit topic to facilitate testing and review. Please let me know if I applied patch wrong.

http://review.source.kitware.com/#/c/13823/ [^]

Appears to make these tests fail on my machine. Dashboard may turn up more or fewer.
ctest -R "vtkGeovisCoreCxx-TestLabeledGeoView2D|vtkImagingCoreCxx-FastSplatter|vtkRenderingOpenGLCxx-TestImageResliceMapperOffAxis|vtkRenderingOpenGLCxx-TestImageSliceMapperAlpha|vtkRenderingOpenGLCxx-TestImageSliceMapperInterpolation|vtkRenderingOpenGLCxx-TestImageStack|vtkViewsInfovisCxx-TestCoincidentGraphLayoutView|vtkViewsInfovisCxx-TestGraphLayoutView"
(0036283)
Berk Geveci (administrator)
2016-07-06 16:48

Setting to status of bugs that have not been updated in the last year to expired. Please re-open if still important.
(0036323)
edice (reporter)
2016-07-07 05:14

Please reopen until someone can review and patch the mainline.
(0037030)
Kitware Robot (administrator)
2016-08-12 09:55

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2008-10-17 11:06 Serge Lalonde New Issue
2008-10-17 11:06 Serge Lalonde File Added: vtkCamera.cxx
2008-10-17 11:07 Serge Lalonde File Added: vtkRenderer.cxx
2008-10-17 11:07 Serge Lalonde File Added: vtkCamera.cxx.patch
2008-10-17 11:07 Serge Lalonde File Added: vtkRenderer.cxx.patch
2009-04-16 09:03 Gerrick Bivins Note Added: 0016040
2009-06-16 10:03 Ben Held Note Added: 0016730
2009-11-02 23:12 edice Note Added: 0018324
2009-11-02 23:12 edice File Added: vtkCamera.cxx.patch-unified
2009-11-02 23:12 edice File Added: vtkRenderer.cxx.patch-unified
2009-11-03 01:27 edice File Added: vtkCamera.cxx.patch-unified_2
2009-11-03 01:27 edice File Added: vtkRenderer.cxx.patch-unified_2
2009-11-03 01:39 edice Note Added: 0018325
2010-03-17 12:45 xabi riobe Note Added: 0019938
2011-06-16 13:11 Zack Galbreath Category => (No Category)
2013-08-20 15:03 Serge Lalonde Note Added: 0031489
2013-08-20 15:03 Serge Lalonde Status expired => backlog
2013-08-20 15:03 Serge Lalonde Resolution open => reopened
2013-12-16 12:14 Dave DeMarle Project => TBD
2013-12-16 12:14 Dave DeMarle Type => incorrect functionality
2013-12-16 12:14 Dave DeMarle Note Added: 0031943
2016-07-06 16:48 Berk Geveci Status backlog => expired
2016-07-06 16:48 Berk Geveci Note Added: 0036283
2016-07-07 05:14 edice Note Added: 0036323
2016-07-07 07:56 Dave DeMarle Assigned To => Dave DeMarle
2016-07-07 07:56 Dave DeMarle Status expired => backlog
2016-08-12 09:55 Kitware Robot Note Added: 0037030
2016-08-12 09:55 Kitware Robot Status backlog => closed
2016-08-12 09:55 Kitware Robot Resolution reopened => moved


Copyright © 2000 - 2018 MantisBT Team