#_CameraDepthTexture error on HLSL

1 messages · Page 1 of 1 (latest)

frail wedge
#

How can I access _CameraDepthTexture in Unity 6000.10f1 in a HLSL code? Back in 2022 it worked like:

SAMPLER(sampler_CameraDepthTexture);

TEXTURE2D(_CameraNormalsTexture);
SAMPLER(sampler_CameraNormalsTexture);```

But the same code doesn't work on 6000.10f1.

I tried
`    float DepthValue = SAMPLE_TEXTURE2D_X(_CameraDepthTexture, sampler_CameraDepthTexture, ScreenUV).r;`
and the same problem with cmaera normals and normals texel size.

I'm trying to use with a custom function inside a subgraph, I tried a hack I saw in the forums of having the SceneDepth just multiplying by 0 so ShaderGraph could fetch it automatically but didn't work.
frail wedge
#

Ok I don't get it. This works however I keep getting errors of _cameraDepth not existing and then cameradepth being redefined if I add the variables. (Attached image is about this).

                         float3 BiasDirection, float OuterEdgeIntensity, float InnerEdgeIntensity,
                         out float EdgeValue)
{
    float DepthValue = SAMPLE_TEXTURE2D(_CameraDepthTexture, sampler_CameraDepthTexture, ScreenUV);

    if (DepthValue == 0)
    {
        EdgeValue = 0;
        return;
    }
    EdgeValue = 1;
    return;
}```
#

WHICH ONE IS IT?!

lone belfry
#

Might be that shadergraph is defining it but after the custom function include in the generated code. I would try using the DeclareDepthTexture.hlsl include

frail wedge
#

How can I use that? Every time I try to include something it gives me the MaxLight error

#

This. Just tried including and nope.

#

#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"

lone belfry
#

What if you surround it in #ifndef SHADERGRAPH_PREVIEW

#
#ifndef SHADERGRAPH_PREVIEW
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
#endif

void Test_float(float2 uv, out float Out){
    #ifndef SHADERGRAPH_PREVIEW
    Out = SampleSceneDepth(uv);
    #else
    Out = 0;
    #endif
}

Seems to work