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:
HLSLINCLUDE
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "AutoLight.cginc"
//HDRP
sampler2D _ColorPyramidTexture;
in fragment shader i do:
half4 grabWithOffset = i.grabPassPos + distortOffsetA;
float4 grabPassTex = SAMPLE_DEPTH_TEXTURE_PROJ(_ColorPyramidTexture, UNITY_PROJ_COORD(float4(grabWithOffset.x, grabWithOffset.y, grabWithOffset.z, grabWithOffset.w)));
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
Additionally i tried to fix in Unity 2019.2 like the below code:
HLSLINCLUDE
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/API/D3D11.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/TextureXR.hlsl"
#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "AutoLight.cginc"
#include "./WaterIncludeSM30.cginc"
TEXTURE2D_X(_CameraDepthTexture);
SAMPLER(sampler_CameraDepthTexture);
TEXTURE2D_X(_ColorPyramidTexture);
SAMPLER(sampler_ColorPyramidTexture);
In vertex i do:
ComputeScreenAndGrabPassPos(o.pos, o.screenPos, o.grabPassPos);
In fragment i do to get the scene color (and apply distortion) and depth:
half4 screenWithOffset = i.screenPos + distortOffset;
half4 grabWithOffset = i.grabPassPos + distortOffset;
half4 rtRefractionsNoDistort = LOAD_TEXTURE2D_X_LOD(_ColorPyramidTexture, UNITY_PROJ_COORD(i.grabPassPos).xy, 0);
half refrFix = LOAD_TEXTURE2D_X_LOD(_CameraDepthTexture, UNITY_PROJ_COORD(grabWithOffset).xy, 0).r;
But this also gives me no results at all
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