Amplifying your potential.
Page 1 of 2

Problem with depth fade

PostPosted: Tue Dec 26, 2017 1:47 am
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

Re: Problem with depth fade

PostPosted: Tue Dec 26, 2017 8:08 pm
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.

Re: Problem with depth fade

PostPosted: Thu Dec 28, 2017 11:42 pm
by mossman
Hello,

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


Bye

Re: Problem with depth fade

PostPosted: Tue Jan 02, 2018 6:32 pm
by mossman
Hello, any help?

Thanks

Re: Problem with depth fade

PostPosted: Tue Jan 02, 2018 6:55 pm
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!

Re: Problem with depth fade

PostPosted: Wed Jan 03, 2018 6:30 pm
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.

Re: Problem with depth fade

PostPosted: Wed Jan 03, 2018 9:32 pm
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

Re: Problem with depth fade

PostPosted: Thu Jan 04, 2018 11:17 am
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.

Re: Problem with depth fade

PostPosted: Thu Jan 04, 2018 5:14 pm
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

Re: Problem with depth fade

PostPosted: Fri Jan 05, 2018 12:23 pm
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.