Jump to content
Sign in to follow this  

Custom Z-Depth Pass

Recommended Posts

Hi everyone, 

I am looking for a way to create a custom ZDepth pass where I can define my closest and farthest values, possibly try to keep them between 0 and 1. 

The reason the Z pass is not working out of the box for me is because I believe the scene scale is too small where my values are going to insane values or "inf".

I created a shader with vector Shading Point in World-Space and it seems like it could be right approach but I haven't exactly figured out a way to get exactly what I need.

Any thoughts on how to achieve this custom pass/shader? 

Thank you! 

Share this post

Link to post
Share on other sites

In your shader you can just grab 'P' (which is already in camera space because we are in a shader), take the Z component and fit it between what you want.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this