Singularity/Library/PackageCache/com.unity.render-pipelines..../ShaderLibrary/DeclareNormalsTexture.hlsl

34 lines
1.1 KiB
HLSL
Raw Normal View History

2024-05-06 14:45:45 -04:00
#ifndef UNITY_DECLARE_NORMALS_TEXTURE_INCLUDED
#define UNITY_DECLARE_NORMALS_TEXTURE_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
TEXTURE2D_X_FLOAT(_CameraNormalsTexture);
SAMPLER(sampler_CameraNormalsTexture);
float3 SampleSceneNormals(float2 uv)
{
float3 normal = SAMPLE_TEXTURE2D_X(_CameraNormalsTexture, sampler_CameraNormalsTexture, UnityStereoTransformScreenSpaceTex(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;
}
float3 LoadSceneNormals(uint2 uv)
{
float3 normal = LOAD_TEXTURE2D_X(_CameraNormalsTexture, 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;
}
#endif