Problem with depth fade

Node-based Shader Editor
mossman
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Problem with depth fade

Post by mossman »

Hello,


I'm having a problem with using the depth fade node to create a intersection detection between meshes. The intersection detection is on a Unlit shader (I use the trasnparent unlit template). The intersection only appears when de Unlit shader with the intersection detection intersects with a Surface shader but not when the Unlit shader intersects with another Unlit Shader.

This image ilustrates the problem.
https://app.box.com/s/sp1piws00zht78ihhr5gc6xnpy79c9oa

Thanks
User avatar
Amplify_Borba
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Problem with depth fade

Post by Amplify_Borba »

mossman wrote:Hello,


I'm having a problem with using the depth fade node to create a intersection detection between meshes. The intersection detection is on a Unlit shader (I use the trasnparent unlit template). The intersection only appears when de Unlit shader with the intersection detection intersects with a Surface shader but not when the Unlit shader intersects with another Unlit Shader.

This image ilustrates the problem.
https://app.box.com/s/sp1piws00zht78ihhr5gc6xnpy79c9oa

Thanks
Hello mossman, thank you for getting in touch!

Not quite sure if this is an expected behavior, our developers are currently taking some time off for the holidays, but rest assured that we'll get back to you as soon as possible on this matter.

Apologies for any inconvenience caused.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
mossman
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: Problem with depth fade

Post by mossman »

Hello,

Thanks for the quick answer. I will waiting the final answer.


Bye
mossman
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: Problem with depth fade

Post by mossman »

Hello, any help?

Thanks
User avatar
Amplify_Borba
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Problem with depth fade

Post by Amplify_Borba »

Apologies for the delayed support response but we are a bit overloaded at the moment as our developers have just returned from holidays and have been sorting through all the support requests.

Do rest assured that we'll review your issue as soon as possible, thank you for understanding!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Amplify_RnD_Rick
Posts: 40
Joined: Wed Mar 01, 2017 6:33 pm

Re: Problem with depth fade

Post by Amplify_RnD_Rick »

Hey mossman,

We apologize again for the delay on providing you support, thank you so much for your patience!

What Depth Fade internally does is to calculate the difference between each pixel's current depth and the value fetched from the depth buffer on that specific location.

So, in order for this node to get correct results its object must not be written on the depth buffer but the other object it intersects should. That is what happens when you intersect the unlit shader box with the surface shader box, the unlit one is not being written on the depth buffer but the surface one is.

When you intersect two unlit boxes, neither of them is being written into the depth buffer thus the Depth fade is unable to calculate correct values.

Please let us know if you need further clarification and don't hesitate on reaching us if you stumble into any issues.
mossman
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: Problem with depth fade

Post by mossman »

Thanks for the clear description is very useful.

Now, the question is:
How I detect the intersection between two meshes with a unlit shader? Using Surface depth node?

Thanks
Amplify_RnD_Rick
Posts: 40
Joined: Wed Mar 01, 2017 6:33 pm

Re: Problem with depth fade

Post by Amplify_RnD_Rick »

Hey mossman,

I know this is not the answer you are looking for but we think that unfortunately it may not be possible using only shaders.

Intersections on a shader can only calculated via the difference between the current fragment depth and what is written on the depth buffer.

Since Unlit objects are not written on the Depth buffer there's no way for them to see each other when each is rendered.

We'll try to figure out a possible solution and let you know if we do find something.
mossman
Posts: 40
Joined: Sun Dec 10, 2017 3:58 pm

Re: Problem with depth fade

Post by mossman »

Hi,

I see... I found a post of the Unity's manual that explain something interesting about de depth buffer.
https://docs.unity3d.com/Manual/SL-Came ... xture.html

Is possible achieve the intersection betwen two unlit shaders with this?

Thanks
Amplify_RnD_Rick
Posts: 40
Joined: Wed Mar 01, 2017 6:33 pm

Re: Problem with depth fade

Post by Amplify_RnD_Rick »

Hey mossman,

What this link is referring is on how to configure your camera to create the depth texture from the depth buffer I mentioned earlier.
I understand your frustration but unfortunately this doesn't have any extra info that would help solving your issue.
Post Reply