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

Node-based Shader Editor

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

Postby cyuxi » Wed Dec 26, 2018 8:32 am

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 3223 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 3223 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 3223 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 ?
cyuxi
 
Posts: 3
Joined: Mon Apr 02, 2018 8:46 am

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

Postby Ricardo Teixeira » Thu Dec 27, 2018 3:09 pm

Greetings,

Is that a single cloud object?

Thanks!
Sales & 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!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

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

Postby cyuxi » Fri Dec 28, 2018 8:26 am

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.
Attachments
TestCloud.unitypackage
(164.47 KiB) Downloaded 175 times
Cloud.jpg
Cloud.jpg (117.5 KiB) Viewed 3212 times
cyuxi
 
Posts: 3
Joined: Mon Apr 02, 2018 8:46 am

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

Postby Amplify_Borba » Wed Jan 02, 2019 4:49 pm

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!
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!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

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

Postby cyuxi » Sat Jan 05, 2019 7:22 am

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!
cyuxi
 
Posts: 3
Joined: Mon Apr 02, 2018 8:46 am

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

Postby Amplify_Borba » Mon Jan 07, 2019 11:27 am

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!
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!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 8 guests