Forums: Z Depth Shader?
Generic forum to discuss Octane Render, post ideas and suggest improvements.
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
by Bulwerk » Fri Jun 29, 2018 3:36 pm
Bulwerk
Fri Jun 29, 2018 3:36 pm
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!
-
Bulwerk
- Licensed Customer
-
- Posts: 235
- Joined: Sun Aug 01, 2010 8:04 pm
by Phantom107 » Fri Jun 29, 2018 6:46 pm
Phantom107
Fri Jun 29, 2018 6:46 pm
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
-
Phantom107
- Licensed Customer
-
- Posts: 686
- Joined: Tue Jul 24, 2012 11:31 am
- Location: The Netherlands
by aoktar » Fri Jun 29, 2018 7:49 pm
aoktar
Fri Jun 29, 2018 7:49 pm
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
-
aoktar
- Octane Plugin Developer
-
- Posts: 15962
- Joined: Tue Mar 23, 2010 8:28 pm
- Location: Türkiye
-
by Bulwerk » Fri Jun 29, 2018 7:57 pm
Bulwerk
Fri Jun 29, 2018 7:57 pm
Exactly what I was looking for!
Thanks!
-
Bulwerk
- Licensed Customer
-
- Posts: 235
- Joined: Sun Aug 01, 2010 8:04 pm
by Phantom107 » Sat Jun 30, 2018 8:48 pm
Phantom107
Sat Jun 30, 2018 8:48 pm
Thanks for making this!
-
Phantom107
- Licensed Customer
-
- Posts: 686
- Joined: Tue Jul 24, 2012 11:31 am
- Location: The Netherlands
by aoktar » Sun Jul 01, 2018 12:15 am
aoktar
Sun Jul 01, 2018 12:15 am
You are welcome guys!
Octane For Cinema 4D developer / 3d generalist
3930k / 16gb / 780ti + 1070/1080 / psu 1600w / numerous hw
-
aoktar
- Octane Plugin Developer
-
- Posts: 15962
- Joined: Tue Mar 23, 2010 8:28 pm
- Location: Türkiye
-
by roeland » Sun Jul 01, 2018 10:15 pm
roeland
Sun Jul 01, 2018 10:15 pm
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;
}
-
roeland
- OctaneRender Team
-
- Posts: 1810
- Joined: Wed Mar 09, 2011 10:09 pm
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 23 guests