Does anyone have a clever solution for making a Z depth shader usable in the node graph?
Seems like something OSL could handle fairly easily. I'm terrible at coding so I thought I would ask the community for some input
Thanks!
Z Depth Shader?
Forum rules
Please add your OS and Hardware Configuration in your signature, it makes it easier for us to help you analyze problems. Example: Win 7 64 | Geforce GTX680 | i7 3770 | 16GB
Please add your OS and Hardware Configuration in your signature, it makes it easier for us to help you analyze problems. Example: Win 7 64 | Geforce GTX680 | i7 3770 | 16GB
- Phantom107
- Posts: 686
- Joined: Tue Jul 24, 2012 11:31 am
- Location: The Netherlands
Absolutely I need this to. I have an insane amount of work to do but I'm going to get into OSL and then program this -- if someone else hasn't done it in the meantime
Developer of tools for Octane:
Phantom Scatter - Phantom Node Link - Phantom Photo Match - Phantom Architecture
Phantom Scatter - Phantom Node Link - Phantom Photo Match - Phantom Architecture
I think you need somethings like this. You can improve if you need.
Code: Select all
shader zdepth
(
float dmax=10[[float min=0, float max=100]],
output color col = 0
)
{
point CamPos = point("camera", 0, 0, 0);
float d = 1-clamp(distance(CamPos,P)/dmax,0,1);
col = d;
}
Octane For Cinema 4D developer / 3d generalist
3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
- Phantom107
- Posts: 686
- Joined: Tue Jul 24, 2012 11:31 am
- Location: The Netherlands
Thanks for making this!
Developer of tools for Octane:
Phantom Scatter - Phantom Node Link - Phantom Photo Match - Phantom Architecture
Phantom Scatter - Phantom Node Link - Phantom Photo Match - Phantom Architecture
You are welcome guys!
Octane For Cinema 4D developer / 3d generalist
3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
For reference I'll add another common definition of Z depth: the distance from the film plane measured parallel to camera view vector. This is equivalent to what Octane renders in the Z-depth pass.
Code: Select all
shader zdepth
(
float dmax=10[[float min=0, float max=100, float sliderexponent=4]],
output color col = 0
)
{
point pCam = transform("common", "camera", P);
// the camera view vector is the negative Z axis in camera space:
col = -pCam[2] / dmax;
}