77 lines
2.2 KiB
HLSL
77 lines
2.2 KiB
HLSL
#ifndef UNIVERSAL_UNLIT_DEPTH_NORMALS_PASS_INCLUDED
|
|
#define UNIVERSAL_UNLIT_DEPTH_NORMALS_PASS_INCLUDED
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
|
|
struct Attributes
|
|
{
|
|
float2 texcoord : TEXCOORD0;
|
|
float3 normal : NORMAL;
|
|
float4 positionOS : POSITION;
|
|
float4 tangentOS : TANGENT;
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
float4 positionCS : SV_POSITION;
|
|
float3 normalWS : TEXCOORD1;
|
|
|
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
|
UNITY_VERTEX_OUTPUT_STEREO
|
|
|
|
//Advanced Dissolve
|
|
ADVANCED_DISSOLVE_UV(2)
|
|
};
|
|
|
|
Varyings DepthNormalsVertex(Attributes input)
|
|
{
|
|
Varyings output = (Varyings)0;
|
|
UNITY_SETUP_INSTANCE_ID(input);
|
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
|
|
|
|
|
#if defined(CURVEDWORLD_IS_INSTALLED) && !defined(CURVEDWORLD_DISABLED_ON)
|
|
#ifdef CURVEDWORLD_NORMAL_TRANSFORMATION_ON
|
|
CURVEDWORLD_TRANSFORM_VERTEX_AND_NORMAL(input.positionOS, input.normal, input.tangentOS)
|
|
#else
|
|
CURVEDWORLD_TRANSFORM_VERTEX(input.positionOS)
|
|
#endif
|
|
#endif
|
|
|
|
|
|
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
|
|
|
VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangentOS);
|
|
output.normalWS = NormalizeNormalPerVertex(normalInput.normalWS);
|
|
|
|
|
|
//Advanced Dissolve
|
|
ADVANCED_DISSOLVE_INIT_UV(output, input.texcoord, output.positionCS)
|
|
|
|
return output;
|
|
}
|
|
|
|
float4 DepthNormalsFragment(Varyings input) : SV_TARGET
|
|
{
|
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
|
|
|
|
|
//Advanced Dissolve////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//?
|
|
|
|
|
|
// Output...
|
|
#if defined(_GBUFFER_NORMALS_OCT)
|
|
float3 normalWS = normalize(input.normalWS);
|
|
float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on some platforms
|
|
float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1]
|
|
half3 packedNormalWS = half3(PackFloat2To888(remappedOctNormalWS)); // values between [ 0, 1]
|
|
return half4(packedNormalWS, 0.0);
|
|
#else
|
|
return half4(NormalizeNormalPerPixel(input.normalWS), 0.0);
|
|
#endif
|
|
}
|
|
|
|
#endif
|