Search Unity

Color pyramid texture not working in latest 2019.2 version of HDRP, but works in 2018.3

Discussion in 'High Definition Render Pipeline' started by nasos_333, Oct 20, 2019.

  1. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,362
    Hi,

    I had a Unity 2018.3 project that i used the following code to read the grabpass of HDRP. I post the relevant shader code parts below.

    Initialized with:
    Code (csharp):
    1.  
    2. HLSLINCLUDE
    3.  
    4. #include "UnityCG.cginc"
    5. #include "Lighting.cginc"
    6. #include "AutoLight.cginc"
    7.  
    8. //HDRP
    9. sampler2D _ColorPyramidTexture;
    10.  
    in fragment shader i do:
    Code (csharp):
    1.  
    2. half4 grabWithOffset = i.grabPassPos + distortOffsetA;
    3.      
    4. float4 grabPassTex = SAMPLE_DEPTH_TEXTURE_PROJ(_ColorPyramidTexture,  UNITY_PROJ_COORD(float4(grabWithOffset.x, grabWithOffset.y, grabWithOffset.z, grabWithOffset.w)));
    5.  
    This works fine in 2018.3 project, but fails in Unity 2019.2, is this a bug or there is new way to handle this texture ?

    Thanks in advance
     
    Last edited: Oct 20, 2019
  2. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,362
    Additionally i tried to fix in Unity 2019.2 like the below code:
    Code (csharp):
    1.  
    2. HLSLINCLUDE
    3.  
    4. #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/API/D3D11.hlsl"
    5. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/TextureXR.hlsl"
    6.  
    7.     #include "UnityCG.cginc"
    8.     #include "Lighting.cginc"
    9.     #include "AutoLight.cginc"
    10.     #include "./WaterIncludeSM30.cginc"
    11.  
    12. TEXTURE2D_X(_CameraDepthTexture);
    13.     SAMPLER(sampler_CameraDepthTexture);
    14.  
    15. TEXTURE2D_X(_ColorPyramidTexture);
    16.     SAMPLER(sampler_ColorPyramidTexture);
    17.  
    In vertex i do:
    Code (csharp):
    1.  
    2. ComputeScreenAndGrabPassPos(o.pos, o.screenPos, o.grabPassPos);
    3.  
    In fragment i do to get the scene color (and apply distortion) and depth:
    Code (csharp):
    1.  
    2. half4 screenWithOffset = i.screenPos + distortOffset;
    3. half4 grabWithOffset = i.grabPassPos + distortOffset;
    4.  
    5. half4 rtRefractionsNoDistort = LOAD_TEXTURE2D_X_LOD(_ColorPyramidTexture, UNITY_PROJ_COORD(i.grabPassPos).xy, 0);
    6.  
    7. half refrFix = LOAD_TEXTURE2D_X_LOD(_CameraDepthTexture, UNITY_PROJ_COORD(grabWithOffset).xy, 0).r;
    8.  
    But this also gives me no results at all
     
  3. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,362
    I got some progress on this, i managed to grab the color texture afteral, by looking at Lit shader, but the scaling of the texture is off, like my projection is not correct and scales as camera moves.

    What is the correct way to assign the UVs for the texture in my vertex shader ? Seems the older sample from previous standard shaders is not working and i.grabPassPos could be wrong, that is why i see this scaling is my guess
     
    Last edited: Oct 21, 2019