|
|
|
|
|
|
//------------------------------------------------------------------------------------- |
|
|
|
// End Defines |
|
|
|
//------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
|
|
|
#include "ShaderGraphLibrary/Functions.hlsl" |
|
|
|
#include "HDRP/ShaderVariables.hlsl" |
|
|
|
#ifdef DEBUG_DISPLAY |
|
|
|
#include "HDRP/Debug/DebugDisplay.hlsl" |
|
|
|
|
|
|
$VertexDescriptionInputs.TangentSpaceViewDirection: float3x3 tangentSpaceTransform = float3x3(output.WorldSpaceTangent,output.WorldSpaceBiTangent,output.WorldSpaceNormal); |
|
|
|
$VertexDescriptionInputs.TangentSpaceViewDirection: output.TangentSpaceViewDirection = mul(tangentSpaceTransform, output.WorldSpaceViewDirection); |
|
|
|
|
|
|
|
$VertexDescriptionInputs.ScreenPosition: output.ScreenPosition = TransformWorldToHClip(output.WorldSpacePosition) * 0.5 + 0.5; |
|
|
|
$VertexDescriptionInputs.ScreenPosition: output.ScreenPosition = ComputeScreenPos(TransformWorldToHClip(output.WorldSpacePosition), _ProjectionParams.x); |
|
|
|
$VertexDescriptionInputs.uv0: output.uv0 = float4(input.uv0, 0.0f, 0.0f); |
|
|
|
$VertexDescriptionInputs.uv1: output.uv1 = float4(input.uv1, 0.0f, 0.0f); |
|
|
|
$VertexDescriptionInputs.uv2: output.uv2 = float4(input.uv2, 0.0f, 0.0f); |
|
|
|
|
|
|
$SurfaceDescriptionInputs.ViewSpaceNormal: output.ViewSpaceNormal = mul(output.WorldSpaceNormal, (float3x3) UNITY_MATRIX_I_V); // transposed multiplication by inverse matrix to handle normal scale |
|
|
|
$SurfaceDescriptionInputs.TangentSpaceNormal: output.TangentSpaceNormal = float3(0.0f, 0.0f, 1.0f); |
|
|
|
|
|
|
|
$SurfaceDescriptionInputs.WorldSpaceTangent output.WorldSpaceTangent = input.worldToTangent[0].xyz; |
|
|
|
$SurfaceDescriptionInputs.WorldSpaceTangent: output.WorldSpaceTangent = input.worldToTangent[0].xyz; |
|
|
|
$SurfaceDescriptionInputs.ObjectSpaceTangent: output.ObjectSpaceTangent = mul((float3x3) unity_WorldToObject, output.WorldSpaceTangent); |
|
|
|
$SurfaceDescriptionInputs.ViewSpaceTangent: output.ViewSpaceTangent = mul((float3x3) UNITY_MATRIX_V, output.WorldSpaceTangent); |
|
|
|
$SurfaceDescriptionInputs.TangentSpaceTangent: output.TangentSpaceTangent = float3(1.0f, 0.0f, 0.0f); |
|
|
|
|
|
|
$SurfaceDescriptionInputs.TangentSpacePosition: output.TangentSpacePosition = float3(0.0f, 0.0f, 0.0f); |
|
|
|
|
|
|
|
// TODO: positionSS is SV_Position, graph input expects screenPosition to be 0..1 across the active viewport (?) |
|
|
|
$SurfaceDescriptionInputs.ScreenPosition: output.ScreenPosition = input.positionSS; |
|
|
|
$SurfaceDescriptionInputs.ScreenPosition: output.ScreenPosition = ComputeScreenPos(TransformWorldToHClip(input.positionWS), _ProjectionParams.x); |
|
|
|
|
|
|
|
$SurfaceDescriptionInputs.uv0: output.uv0 = float4(input.texCoord0, 0.0f, 0.0f); |
|
|
|
$SurfaceDescriptionInputs.uv1: output.uv1 = float4(input.texCoord1, 0.0f, 0.0f); |
|
|
|
|
|
|
|
|
|
|
// Perform alpha test very early to save performance (a killed pixel will not sample textures) |
|
|
|
// TODO: split graph evaluation to grab just alpha dependencies first? tricky.. |
|
|
|
#ifdef _ALPHATEST_ON |
|
|
|
DoAlphaTest(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold); |
|
|
|
#endif |
|
|
|
$AlphaTest: DoAlphaTest(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold); |
|
|
|
|
|
|
|
BuildSurfaceData(fragInputs, surfaceDescription, V, surfaceData); |
|
|
|
|
|
|
|