Page 1 of 1

Dose Depth Fade node only work with light that has shadow on

PostPosted: Wed Dec 26, 2018 8:32 am
by cyuxi
Hi,
I was trying to make a depth fade effect to smooth out the intersection of clouds and scene objects, however getting stuck with few problems.

It seems the Depth Fade Node cannot work properly if I don't put a light(with shadow on) in the scene.

If shadow on the light is turned on and the scene is not baked, the Depth Fade Node would just worked well, and this is the result I wanted.
Light_ShadowOn_WithDepth.jpg
Light_ShadowOn_WithDepth.jpg (147.99 KiB) Viewed 3221 times



But the Depth Fade node turned invalid if the light or the shadow is turned off...
Light_ShadowOff_NoDepth.jpg
Light_ShadowOff_NoDepth.jpg (150.86 KiB) Viewed 3221 times


And if we baked the scene, the Depth Fade node just won't work at all nonetheless the Shadow option on light is turned on or not.

Here is how the Depth Fade node applied.
DepthFadeUnlitShader.jpg
DepthFadeUnlitShader.jpg (186.02 KiB) Viewed 3221 times


The materials of the three rocks are simply Standard(specular).

I wonder If there are solutions of making Depth Fade node to work with no lighting and baked scene ?

Re: Dose Depth Fade node only work with light that has shado

PostPosted: Thu Dec 27, 2018 3:09 pm
by Ricardo Teixeira
Greetings,

Is that a single cloud object?

Thanks!

Re: Dose Depth Fade node only work with light that has shado

PostPosted: Fri Dec 28, 2018 8:26 am
by cyuxi
Ricardo Teixeira wrote:Greetings,

Is that a single cloud object?

Thanks!


Hi,
The cloud is a mesh.( I split a mesh into four in order to share the texture map which has four shapes of cloud.)
I'm currently using the Unity 2017.2.0f3.
I have attached the screenshot and the test scene. Please have a look.

I'm looking forward to your further advises.Thanks.

Re: Dose Depth Fade node only work with light that has shado

PostPosted: Wed Jan 02, 2019 4:49 pm
by Amplify_Borba
Hello, this behavior is expected since the shadow casting pass is not being called due to the lack of light / shadows.

There is a workaround to this, which involves forcing the camera to generate a depth texture in order to access values from the depth buffer on an unlit scene.

You can add the following script to your MainCamera for this purpose:

Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]

public class EnableDepthTexture : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Camera.main.depthTextureMode = DepthTextureMode.Depth;
    }


Please let me know if this helps, thanks!

Re: Dose Depth Fade node only work with light that has shado

PostPosted: Sat Jan 05, 2019 7:22 am
by cyuxi
Amplify_Borba wrote:Hello, this behavior is expected since the shadow casting pass is not being called due to the lack of light / shadows.

There is a workaround to this, which involves forcing the camera to generate a depth texture in order to access values from the depth buffer on an unlit scene.

You can add the following script to your MainCamera for this purpose:

Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]

public class EnableDepthTexture : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Camera.main.depthTextureMode = DepthTextureMode.Depth;
    }


Please let me know if this helps, thanks!


Great! Such a nice trick! It's working now. You also provided me an explicit direction to learn such mechanism of unity.
Thank you Sir! and Happy new year!

Re: Dose Depth Fade node only work with light that has shado

PostPosted: Mon Jan 07, 2019 11:27 am
by Amplify_Borba
No problem, we're glad we could help.

Have you had the chance to rate and review Amplify Shader Editor? It would be awesome if you could share your experience with the Unity community, every bit helps and your feedback is extremely valuable to us.

Feel free to get back in touch if you have further issues or questions, thank you and a happy new year to you as well!