Understanding Pz
6446 14 1- nikalaris
- Member
- 10 posts
- Joined: April 2015
- Offline
I can't seem to find the answer to this and my head is hurting, so perhaps someone could please explain..?
If I create a camera and sphere at the origin, set the camera to render a polar projection and add an extra image plane, Pz… shouldn't I expect to see the render filled with a constant color?
Isn't Pz the distance of a point to the camera (which is also a point)?
If not.. how do I go about rendering a depth map in polar mode? (I could achieve this using a custom shader, but that means overriding the shaders already applied to my geo which is no good)
If I create a camera and sphere at the origin, set the camera to render a polar projection and add an extra image plane, Pz… shouldn't I expect to see the render filled with a constant color?
Isn't Pz the distance of a point to the camera (which is also a point)?
If not.. how do I go about rendering a depth map in polar mode? (I could achieve this using a custom shader, but that means overriding the shaders already applied to my geo which is no good)
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
What's your problem exactly ?
Because Pz rendered perfectly with Polar Camera for me !
Also for rendering any custom image plane such as custom depth map you don't need to override any shader , you can use your original shader for exporting any custom data such as depth to extra image planes in the Mantra node .
you should just use Parameter VOP node for exporting your data in your material.
Just you should use exactly same name and data type for Parameter VOP node and Extra image plane.
Because Pz rendered perfectly with Polar Camera for me !
Also for rendering any custom image plane such as custom depth map you don't need to override any shader , you can use your original shader for exporting any custom data such as depth to extra image planes in the Mantra node .
you should just use Parameter VOP node for exporting your data in your material.
Just you should use exactly same name and data type for Parameter VOP node and Extra image plane.
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
- nikalaris
- Member
- 10 posts
- Joined: April 2015
- Offline
Thanks Joker!
I've modified the file so it shows the problem - the only changes I made were to switch off the plane object and move cam1 to the origin. We're now inside the unit sphere you made.
When I render now I get the attached image - I can't even save this out as a png since the right hand side (black) is actually very negative, so here's a screenshot.
If we're at the center of a unit sphere, shouldn't all pixels be a constant value?
I've modified the file so it shows the problem - the only changes I made were to switch off the plane object and move cam1 to the origin. We're now inside the unit sphere you made.
When I render now I get the attached image - I can't even save this out as a png since the right hand side (black) is actually very negative, so here's a screenshot.
If we're at the center of a unit sphere, shouldn't all pixels be a constant value?
- eetu
- Member
- 606 posts
- Joined: May 2007
- Offline
Pz is not really “distance from camera”, it is the z-coordinate of the shaded point in camera coordinates.
For a non-shader solution, and a spherical projection, you could calculate the length of the (Px, Py, Pz) vector in post. (make sure that the position is in camera coordinates). For a cylindrical projection that would be (Px, 0, Pz). For funkier projections you probably would need to grab the length of the view ray in a shader.
For a non-shader solution, and a spherical projection, you could calculate the length of the (Px, Py, Pz) vector in post. (make sure that the position is in camera coordinates). For a cylindrical projection that would be (Px, 0, Pz). For funkier projections you probably would need to grab the length of the view ray in a shader.
- nikalaris
- Member
- 10 posts
- Joined: April 2015
- Offline
Ahh, thanks! so I'm approaching the problem wrongly
Sorry to sound like a noob but mantra is usually the last node in my workflow - I get that I can set P as an export plane and hence get Px,Py,Pz, but how do I then get to my desired final output (I'm after a 16-bit integer single channel png where each pixel is the distance from camera to the surface)?
Are there any example files I can learn from here?
Sorry to sound like a noob but mantra is usually the last node in my workflow - I get that I can set P as an export plane and hence get Px,Py,Pz, but how do I then get to my desired final output (I'm after a 16-bit integer single channel png where each pixel is the distance from camera to the surface)?
Are there any example files I can learn from here?
- eetu
- Member
- 606 posts
- Joined: May 2007
- Offline
- pezetko
- Member
- 387 posts
- Joined: Nov. 2008
- Offline
- nikalaris
- Member
- 10 posts
- Joined: April 2015
- Offline
- eetu
- Member
- 606 posts
- Joined: May 2007
- Offline
- pezetko
- Member
- 387 posts
- Joined: Nov. 2008
- Offline
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
nikalaris
Thanks Joker!
I've modified the file so it shows the problem - the only changes I made were to switch off the plane object and move cam1 to the origin. We're now inside the unit sphere you made.
When I render now I get the attached image - I can't even save this out as a png since the right hand side (black) is actually very negative, so here's a screenshot.
If we're at the center of a unit sphere, shouldn't all pixels be a constant value?
And in my last attached project , if you render it via my custom JKDepth , then you have constant value for Depth !
- eetu
- Member
- 606 posts
- Joined: May 2007
- Offline
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
eetuJoker386
In this project I made a simple setup for exporting custom Depth Map with original shaders (not overriding !) :wink:
Strictly speaking it's not really original shaders, as you would need to modify each and every shader used in the scene..
Of course it's not so hard , it's just a simple Copy and Paste 2 nodes in each shader (Distance VOP and Export Parameter VOP nodes).
We can use a very simple Python Script for doing this operation automatically , for example just select our specify materials and run this script then additional nodes will copy to these shaders .
Also I think using P in render and using COP for convert P to Pz has same result with using simple Pz in Mantra (Just it's inverse) , Because Blue value in P channel has exactly same value like Pz.
however you don't need to using R and G in the COP , because they are not useful for computing Depth , they are only useful for position X and Y (not Z!).
in this case you just connect Cb to Output node in Vop COP and it's same with simply using Pz extra image plane in Mantra , Just with more complexity !
- Sadjad Rabiee
- Member
- 1391 posts
- Joined: Dec. 2010
- Offline
-
- Quick Links