#How do you get access to scene normals in a URP full screen render pass?

1 messages · Page 1 of 1 (latest)

charred igloo
#

I have a Camera that has its own unique Render Pipeline. I am trying to do edge detection as full-screen passes.

I am struggling to get access to the camera's blit Normal of the scene. How do you access the normal?

I've gotten access to color and depth by doing stuff like shown, but how do I get the normals from the blit in the same way?

pseudo coral
charred igloo
#

Is this how I access that?

#

I got an error about redefinition, but I ALSO get a different error if I dont include
//TEXTURE2D_X(_CameraNormalsTexture);

#
{
    uv = ClampAndScaleUVForBilinear(UnityStereoTransformScreenSpaceTex(uv), _CameraNormalsTexture_TexelSize.xy);
    float3 normal = SAMPLE_TEXTURE2D_X(_CameraNormalsTexture, samplerParam, uv).xyz;

    #if defined(_GBUFFER_NORMALS_OCT)
    float2 remappedOctNormalWS = Unpack888ToFloat2(normal); // values between [ 0,  1]
    float2 octNormalWS = remappedOctNormalWS.xy * 2.0 - 1.0;    // values between [-1, +1]
    normal = UnpackNormalOctQuadEncode(octNormalWS);
    #endif

    return normal;
}```
#

Looking at this from the code you linked

#

I am not sure how to use these methods from within my HLSL shader graph custom node

#

can I just invoke those methods? How will it know what/where to look?

pseudo coral
charred igloo
#

Thats why I explicitly dont try to access it if its the preview atm

#
{
    uint2 pixelCoords = uint2(uv * _ScreenSize.xy);
    //return LOAD_TEXTURE2D_X_LOD(_CameraNormalsTexture, pixelCoords, 0);
    return SAMPLE_TEXTURE2D_X(_CameraNormalsTexture, samplerParam, uv).xyz;
}```
#

I guess to acess normals I should do something like this?

#

But I don't have a sampler to pass in

#

Where do you get a texture sampler in a full screen renderer feature pass UnityChanThink

pseudo coral
#

URP uses inline samplers for fullscreen textures, usually sampler_PointClamp which is already defined by URP's shaderlibrary

charred igloo
#

Ooh I see

#

Like this:

#

Thanks, that got me the Normals 👀 now I can move forward on my edge detection

charred igloo
#

@pseudo coral Following up on this I realized I also need the Texel size for the outline shader
I can see the name of it in the code you linked, but when I try to reference that variable, I get an Undeclaired Identifier error

#

Hm adding this at the top seemed to have worked?

#

the same way they define it outside the scope