Hey all, using _CameraOpaqueTexture in Shader Graph is very easy, you define a variable and boom you have the camera texture. But that seems to rely on some internal shader graph magic. Does anybody have tips on how one would go about accessing the camera opaque texture from code in a LWRP hlsl shader? I need to rewrite a glass shader in code to have access to a few features that aren’t supported in shader graph.
I made a little progress on this, turns out I was overcomplicating it. All I needed to do in hlsl is define a variable and fill a sampler, just like in shader graph:
TEXTURE2D(_CameraOpaqueTexture);
half3 cameraTex = _CameraOpaqueTexture.SampleLevel(sampler_BaseMap, input.uv, 0);
surfaceData.albedo = cameraTex;
However, the camera texture only appears when the camera is still. When looking around, the texture renders as black. It also renders black when in the game view. Any ideas why this is happening?
3 Likes