Understanding Pz

   6338   14   1
User Avatar
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)
User Avatar
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.

Attachments:
JKPolar_Pz.jpg (134.2 KB)
JKPolar_Cd.jpg (180.1 KB)

https://www.youtube.com/c/sadjadrabiee [www.youtube.com]
Rabiee.Sadjad@Gmail.Com
User Avatar
Member
1391 posts
Joined: Dec. 2010
Offline
In this project I made a simple setup for exporting custom Depth Map with original shaders (not overriding !) :wink:

Attachments:
JK_Custom_Depth.hip.tar.gz (155.5 KB)

https://www.youtube.com/c/sadjadrabiee [www.youtube.com]
Rabiee.Sadjad@Gmail.Com
User Avatar
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?

Attachments:
weirdPz.png (142.2 KB)
pz_problem.hipnc (1.7 MB)

User Avatar
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.
User Avatar
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?
User Avatar
Member
606 posts
Joined: May 2007
Offline
One way could be to route your render through COPs, like the attached. I'm unsure whether Houdini can write single-channel pngs, though.

Attachments:
pz_probleme.hipnc (248.5 KB)

User Avatar
Member
387 posts
Joined: Nov. 2008
Offline
Other way would be exporting directly from your shader.

Attachments:
distance_to_camera.PNG (36.9 KB)

User Avatar
Member
10 posts
Joined: April 2015
Offline
That looks to be spot on, thanks eetu!
and I learned yet another new way to do things in houdini - awesome
User Avatar
Member
606 posts
Joined: May 2007
Offline
pezetko
Other way would be exporting directly from your shader.

Sure, but in the first post he said he wasn't looking for a shader solution, that's why the jumping through hoops
User Avatar
Member
387 posts
Joined: Nov. 2008
Offline
I liked that composite solution more too. It's far more flexible, faster to setup and could be done on demand.

(And yes, I missed end of that first post )
User Avatar
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 !
https://www.youtube.com/c/sadjadrabiee [www.youtube.com]
Rabiee.Sadjad@Gmail.Com
User Avatar
Member
606 posts
Joined: May 2007
Offline
Joker386
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..
User Avatar
Member
1391 posts
Joined: Dec. 2010
Offline
eetu
Joker386
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 !

Attachments:
P_Cam.jpg (149.4 KB)
Pz_Mantra.jpg (154.6 KB)
P_Color.jpg (166.8 KB)

https://www.youtube.com/c/sadjadrabiee [www.youtube.com]
Rabiee.Sadjad@Gmail.Com
User Avatar
Member
1391 posts
Joined: Dec. 2010
Offline
Sorry about big pictures guys :roll: !
https://www.youtube.com/c/sadjadrabiee [www.youtube.com]
Rabiee.Sadjad@Gmail.Com
  • Quick Links