# Z-Buffer Values Problem with Camera

**URL:** https://discourse.vtk.org/t/z-buffer-values-problem-with-camera/2224
**Category:** Support
**Created:** [December 6, 2019, 12:02pm UTC](https://discourse.vtk.org/t/z-buffer-values-problem-with-camera/2224 "2019-12-06T12:02:47Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Alex1](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://discourse.vtk.org/u/Alex1)
#### Post date: [December 6, 2019, 12:02pm UTC](https://discourse.vtk.org/t/z-buffer-values-problem-with-camera/2224/1 "2019-12-06T12:02:47Z")

</div>

Hi all,  
I try to get the zBuffer Values from my vtkRenderWindow with renWin-\>GetZbufferData(x1,y1,x2,y2) and it works fine, if I print the Image to file I get this :  
 ![zBufferInfo_withoutCamera](https://discourse.vtk.org/uploads/default/original/2X/9/9e1896d0b6b6d3998ab6b9f1119450cbd8bd1254.png)  
But as soon as I add a Camera to my renderer it doesnt work anymore and I get this as result: ![zBufferInfo_withCamera](https://discourse.vtk.org/uploads/default/original/2X/c/c10a6285098eb93437a6968c7ca1ef54157e45f9.png)  
Can someone help me?  
I used this example [https://vtk.org/Wiki/VTK/Examples/Cxx/Utilities/ZBuffer](https://vtk.org/Wiki/VTK/Examples/Cxx/Utilities/ZBuffer)

---

<div class="post-metadata">

### Author: ![Michael](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael/32/16_2.png) [@Michael](https://discourse.vtk.org/u/Michael)
#### Post date: [December 6, 2019, 2:47pm UTC](https://discourse.vtk.org/t/z-buffer-values-problem-with-camera/2224/2 "2019-12-06T14:47:30Z")

</div>

Hi,  
This is an issue with the near/far plane of your camera.  
Try to call `vtkRenderer::ResetCameraClippingRange()`

---

<div class="post-metadata">

### Author: ![Alex1](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://discourse.vtk.org/u/Alex1)
#### Post date: [December 6, 2019, 3:14pm UTC](https://discourse.vtk.org/t/z-buffer-values-problem-with-camera/2224/3 "2019-12-06T15:14:21Z")

</div>

Hi,  
still the same Problem even if I use `vtkRenderer::ResetCameraClippingRange()`  
I have the following Setup:  
`camera->SetPosition(x, y, z);`  
`renderer->SetActiveCamera(camera);`  
`renderer->ResetCameraClippingRange();`

Any idea?

---

<div class="post-metadata">

### Author: ![Alex1](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@Alex1](https://discourse.vtk.org/u/Alex1)
#### Post date: [December 11, 2019, 12:26pm UTC](https://discourse.vtk.org/t/z-buffer-values-problem-with-camera/2224/4 "2019-12-11T12:26:45Z")

</div>

I found a solution:  
The camera position must be after renderWindow-\> Render (); has been called.
