Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Question Get normal failing when Accurate G-Buffer Normals is on

Discussion in 'Universal Render Pipeline' started by YJack, Nov 25, 2022.

  1. YJack

    YJack

    Joined:
    Apr 7, 2010
    Posts:
    44
    I'm having issues to get normals in URP. What am I missing?
    The code below return normals if Accurate G-Buffer Normals Off but returns white if On.
    SampleSceneNormals(i.texcoord);



    The same happens getting directly....
       float3 normal = SAMPLE_TEXTURE2D(_CameraNormalsTexture, sampler_CameraNormalsTexture, UnityStereoTransformScreenSpaceTex(i.texcoord)).xyz;



    The code below to unpack when GBuffer packed is used is not helping...
       float2 remappedOctNormalWS = Unpack888ToFloat2(normal); // values between [ 0,  1]
    float2 octNormalWS = remappedOctNormalWS.xy * 2.0 - 1.0; // values between [-1, +1]
    normal = UnpackNormalOctQuadEncode(octNormalWS);


    upload_2022-11-25_15-33-37.png
     
  2. camerondus

    camerondus

    Joined:
    Dec 15, 2018
    Posts:
    29
    Dont forget to include the extra variant in the shader!
    Screenshot_2.png

    Screenshot_6.png
     
    YJack likes this.