Advertisement
Guest User

Unlit Shader - Shadergraph Code

a guest
Mar 18th, 2019
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Unlit Master"
  2. {
  3.     Properties
  4.     {
  5.         [NonModifiableTextureData] [NoScaleOffset] _Texture2DAsset_63806780_Out("Texture2D", 2D) = "white" {}
  6.  
  7.     }
  8.     SubShader
  9.     {
  10.         Tags
  11.         {
  12.             "RenderPipeline"="HDRenderPipeline"
  13.             "RenderType"="Opaque"
  14.             "Queue"="Geometry+0"
  15.         }
  16.        
  17.         Pass
  18.         {
  19.             // based on HDUnlitPassForward.template
  20.             Name "ShadowCaster"
  21.             Tags { "LightMode" = "ShadowCaster" }
  22.        
  23.             //-------------------------------------------------------------------------------------
  24.             // Render Modes (Blend, Cull, ZTest, Stencil, etc)
  25.             //-------------------------------------------------------------------------------------
  26.             Blend One Zero
  27.        
  28.             Cull Back
  29.        
  30.             ZTest LEqual
  31.        
  32.             ZWrite On
  33.        
  34.             // Default Stencil
  35.        
  36.             ColorMask 0
  37.        
  38.             //-------------------------------------------------------------------------------------
  39.             // End Render Modes
  40.             //-------------------------------------------------------------------------------------
  41.        
  42.             HLSLPROGRAM
  43.        
  44.             #pragma target 4.5
  45.             #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
  46.             //#pragma enable_d3d11_debug_symbols
  47.        
  48.             //enable GPU instancing support
  49.             #pragma multi_compile_instancing
  50.        
  51.             //-------------------------------------------------------------------------------------
  52.             // Variant Definitions (active field translations to HDRP defines)
  53.             //-------------------------------------------------------------------------------------
  54.             //-------------------------------------------------------------------------------------
  55.             // End Variant Definitions
  56.             //-------------------------------------------------------------------------------------
  57.        
  58.             #pragma vertex Vert
  59.             #pragma fragment Frag
  60.        
  61.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  62.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Wind.hlsl"
  63.        
  64.             // define FragInputs structure
  65.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  66.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  67.        
  68.             //-------------------------------------------------------------------------------------
  69.             // Defines
  70.             //-------------------------------------------------------------------------------------
  71.                     #define SHADERPASS SHADERPASS_SHADOWS
  72.                 #define USE_LEGACY_UNITY_MATRIX_VARIABLES
  73.        
  74.             // this translates the new dependency tracker into the old preprocessor definitions for the existing HDRP shader code
  75.             #define ATTRIBUTES_NEED_TEXCOORD0
  76.             #define VARYINGS_NEED_TEXCOORD0
  77.        
  78.             //-------------------------------------------------------------------------------------
  79.             // End Defines
  80.             //-------------------------------------------------------------------------------------
  81.        
  82.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
  83.         #ifdef DEBUG_DISPLAY
  84.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
  85.         #endif
  86.        
  87.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
  88.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
  89.        
  90.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
  91.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
  92.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
  93.        
  94.             // Used by SceneSelectionPass
  95.             int _ObjectId;
  96.             int _PassValue;
  97.        
  98.             //-------------------------------------------------------------------------------------
  99.             // Interpolator Packing And Struct Declarations
  100.             //-------------------------------------------------------------------------------------
  101.         // Generated Type: AttributesMesh
  102.         struct AttributesMesh {
  103.             float3 positionOS : POSITION;
  104.             float4 uv0 : TEXCOORD0; // optional
  105.             #if UNITY_ANY_INSTANCING_ENABLED
  106.             uint instanceID : INSTANCEID_SEMANTIC;
  107.             #endif // UNITY_ANY_INSTANCING_ENABLED
  108.         };
  109.        
  110.         // Generated Type: VaryingsMeshToPS
  111.         struct VaryingsMeshToPS {
  112.             float4 positionCS : SV_Position;
  113.             float4 texCoord0; // optional
  114.             #if UNITY_ANY_INSTANCING_ENABLED
  115.             uint instanceID : INSTANCEID_SEMANTIC;
  116.             #endif // UNITY_ANY_INSTANCING_ENABLED
  117.         };
  118.         struct PackedVaryingsMeshToPS {
  119.             float4 interp00 : TEXCOORD0; // auto-packed
  120.             float4 positionCS : SV_Position; // unpacked
  121.             #if UNITY_ANY_INSTANCING_ENABLED
  122.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  123.             #endif // UNITY_ANY_INSTANCING_ENABLED
  124.         };
  125.         PackedVaryingsMeshToPS PackVaryingsMeshToPS(VaryingsMeshToPS input)
  126.         {
  127.             PackedVaryingsMeshToPS output;
  128.             output.positionCS = input.positionCS;
  129.             output.interp00.xyzw = input.texCoord0;
  130.             #if UNITY_ANY_INSTANCING_ENABLED
  131.             output.instanceID = input.instanceID;
  132.             #endif // UNITY_ANY_INSTANCING_ENABLED
  133.             return output;
  134.         }
  135.         VaryingsMeshToPS UnpackVaryingsMeshToPS(PackedVaryingsMeshToPS input)
  136.         {
  137.             VaryingsMeshToPS output;
  138.             output.positionCS = input.positionCS;
  139.             output.texCoord0 = input.interp00.xyzw;
  140.             #if UNITY_ANY_INSTANCING_ENABLED
  141.             output.instanceID = input.instanceID;
  142.             #endif // UNITY_ANY_INSTANCING_ENABLED
  143.             return output;
  144.         }
  145.        
  146.         // Generated Type: VaryingsMeshToDS
  147.         struct VaryingsMeshToDS {
  148.             float3 positionRWS;
  149.             float3 normalWS;
  150.             #if UNITY_ANY_INSTANCING_ENABLED
  151.             uint instanceID : INSTANCEID_SEMANTIC;
  152.             #endif // UNITY_ANY_INSTANCING_ENABLED
  153.         };
  154.         struct PackedVaryingsMeshToDS {
  155.             float3 interp00 : TEXCOORD0; // auto-packed
  156.             float3 interp01 : TEXCOORD1; // auto-packed
  157.             #if UNITY_ANY_INSTANCING_ENABLED
  158.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  159.             #endif // UNITY_ANY_INSTANCING_ENABLED
  160.         };
  161.         PackedVaryingsMeshToDS PackVaryingsMeshToDS(VaryingsMeshToDS input)
  162.         {
  163.             PackedVaryingsMeshToDS output;
  164.             output.interp00.xyz = input.positionRWS;
  165.             output.interp01.xyz = input.normalWS;
  166.             #if UNITY_ANY_INSTANCING_ENABLED
  167.             output.instanceID = input.instanceID;
  168.             #endif // UNITY_ANY_INSTANCING_ENABLED
  169.             return output;
  170.         }
  171.         VaryingsMeshToDS UnpackVaryingsMeshToDS(PackedVaryingsMeshToDS input)
  172.         {
  173.             VaryingsMeshToDS output;
  174.             output.positionRWS = input.interp00.xyz;
  175.             output.normalWS = input.interp01.xyz;
  176.             #if UNITY_ANY_INSTANCING_ENABLED
  177.             output.instanceID = input.instanceID;
  178.             #endif // UNITY_ANY_INSTANCING_ENABLED
  179.             return output;
  180.         }
  181.        
  182.             //-------------------------------------------------------------------------------------
  183.             // End Interpolator Packing And Struct Declarations
  184.             //-------------------------------------------------------------------------------------
  185.        
  186.             //-------------------------------------------------------------------------------------
  187.             // Graph generated code
  188.             //-------------------------------------------------------------------------------------
  189.                     // Shared Graph Properties (uniform inputs)
  190.                     CBUFFER_START(UnityPerMaterial)
  191.                     CBUFFER_END
  192.                
  193.                     TEXTURE2D(_Texture2DAsset_63806780_Out); SAMPLER(sampler_Texture2DAsset_63806780_Out); float4 _Texture2DAsset_63806780_Out_TexelSize;
  194.                
  195.                 // Pixel Graph Inputs
  196.                     struct SurfaceDescriptionInputs {
  197.                         float4 uv0; // optional
  198.                     };
  199.                 // Pixel Graph Outputs
  200.                     struct SurfaceDescription
  201.                     {
  202.                         float Alpha;
  203.                         float AlphaClipThreshold;
  204.                     };
  205.                    
  206.                 // Shared Graph Node Functions
  207.                 // Pixel Graph Evaluation
  208.                     SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
  209.                     {
  210.                         SurfaceDescription surface = (SurfaceDescription)0;
  211.                         float4 _SampleTexture2D_A19560AC_RGBA = SAMPLE_TEXTURE2D(_Texture2DAsset_63806780_Out, sampler_Texture2DAsset_63806780_Out, IN.uv0.xy);
  212.                         float _SampleTexture2D_A19560AC_R = _SampleTexture2D_A19560AC_RGBA.r;
  213.                         float _SampleTexture2D_A19560AC_G = _SampleTexture2D_A19560AC_RGBA.g;
  214.                         float _SampleTexture2D_A19560AC_B = _SampleTexture2D_A19560AC_RGBA.b;
  215.                         float _SampleTexture2D_A19560AC_A = _SampleTexture2D_A19560AC_RGBA.a;
  216.                         surface.Alpha = _SampleTexture2D_A19560AC_A;
  217.                         surface.AlphaClipThreshold = 0.5;
  218.                         return surface;
  219.                     }
  220.                    
  221.             //-------------------------------------------------------------------------------------
  222.             // End graph generated code
  223.             //-------------------------------------------------------------------------------------
  224.        
  225.        
  226.        
  227.         //-------------------------------------------------------------------------------------
  228.         // TEMPLATE INCLUDE : SharedCode.template.hlsl
  229.         //-------------------------------------------------------------------------------------
  230.             FragInputs BuildFragInputs(VaryingsMeshToPS input)
  231.             {
  232.                 FragInputs output;
  233.                 ZERO_INITIALIZE(FragInputs, output);
  234.        
  235.                 // Init to some default value to make the computer quiet (else it output 'divide by zero' warning even if value is not used).
  236.                 // TODO: this is a really poor workaround, but the variable is used in a bunch of places
  237.                 // to compute normals which are then passed on elsewhere to compute other values...
  238.                 output.worldToTangent = k_identity3x3;
  239.                 output.positionSS = input.positionCS;       // input.positionCS is SV_Position
  240.        
  241.                 output.texCoord0 = input.texCoord0;
  242.                 #if SHADER_STAGE_FRAGMENT
  243.                 #endif // SHADER_STAGE_FRAGMENT
  244.        
  245.                 return output;
  246.             }
  247.        
  248.             SurfaceDescriptionInputs FragInputsToSurfaceDescriptionInputs(FragInputs input, float3 viewWS)
  249.             {
  250.                 SurfaceDescriptionInputs output;
  251.                 ZERO_INITIALIZE(SurfaceDescriptionInputs, output);
  252.        
  253.                 output.uv0 =                         input.texCoord0;
  254.        
  255.                 return output;
  256.             }
  257.        
  258.             // existing HDRP code uses the combined function to go directly from packed to frag inputs
  259.             FragInputs UnpackVaryingsMeshToFragInputs(PackedVaryingsMeshToPS input)
  260.             {
  261.                 UNITY_SETUP_INSTANCE_ID(input);
  262.                 VaryingsMeshToPS unpacked= UnpackVaryingsMeshToPS(input);
  263.                 return BuildFragInputs(unpacked);
  264.             }
  265.        
  266.         //-------------------------------------------------------------------------------------
  267.         // END TEMPLATE INCLUDE : SharedCode.template.hlsl
  268.         //-------------------------------------------------------------------------------------
  269.        
  270.        
  271.        
  272.             void BuildSurfaceData(FragInputs fragInputs, inout SurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData)
  273.             {
  274.                 // setup defaults -- these are used if the graph doesn't output a value
  275.                 ZERO_INITIALIZE(SurfaceData, surfaceData);
  276.        
  277.                 // copy across graph values, if defined
  278.        
  279.         #if defined(DEBUG_DISPLAY)
  280.                 if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
  281.                 {
  282.                     // TODO
  283.                 }
  284.         #endif
  285.             }
  286.        
  287.             void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
  288.             {
  289.                 SurfaceDescriptionInputs surfaceDescriptionInputs = FragInputsToSurfaceDescriptionInputs(fragInputs, V);
  290.                 SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
  291.        
  292.                 // Perform alpha test very early to save performance (a killed pixel will not sample textures)
  293.                 // TODO: split graph evaluation to grab just alpha dependencies first? tricky..
  294.                 DoAlphaTest(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold);
  295.        
  296.                 BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
  297.        
  298.                 // Builtin Data
  299.                 ZERO_INITIALIZE(BuiltinData, builtinData); // No call to InitBuiltinData as we don't have any lighting
  300.        
  301.                 builtinData.opacity = surfaceDescription.Alpha;
  302.        
  303.        
  304.         #if (SHADERPASS == SHADERPASS_DISTORTION)
  305.                 builtinData.distortion = surfaceDescription.Distortion;
  306.                 builtinData.distortionBlur = surfaceDescription.DistortionBlur;
  307.         #else
  308.                 builtinData.distortion = float2(0.0, 0.0);
  309.                 builtinData.distortionBlur = 0.0;
  310.         #endif
  311.             }
  312.        
  313.             //-------------------------------------------------------------------------------------
  314.             // Pass Includes
  315.             //-------------------------------------------------------------------------------------
  316.                 #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl"
  317.             //-------------------------------------------------------------------------------------
  318.             // End Pass Includes
  319.             //-------------------------------------------------------------------------------------
  320.        
  321.             ENDHLSL
  322.         }
  323.        
  324.         Pass
  325.         {
  326.             // based on HDUnlitPassForward.template
  327.             Name "META"
  328.             Tags { "LightMode" = "META" }
  329.        
  330.             //-------------------------------------------------------------------------------------
  331.             // Render Modes (Blend, Cull, ZTest, Stencil, etc)
  332.             //-------------------------------------------------------------------------------------
  333.             Blend One Zero
  334.        
  335.             Cull Off
  336.        
  337.             ZTest LEqual
  338.        
  339.             ZWrite On
  340.        
  341.             // Default Stencil
  342.        
  343.            
  344.             //-------------------------------------------------------------------------------------
  345.             // End Render Modes
  346.             //-------------------------------------------------------------------------------------
  347.        
  348.             HLSLPROGRAM
  349.        
  350.             #pragma target 4.5
  351.             #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
  352.             //#pragma enable_d3d11_debug_symbols
  353.        
  354.             //enable GPU instancing support
  355.             #pragma multi_compile_instancing
  356.        
  357.             //-------------------------------------------------------------------------------------
  358.             // Variant Definitions (active field translations to HDRP defines)
  359.             //-------------------------------------------------------------------------------------
  360.             //-------------------------------------------------------------------------------------
  361.             // End Variant Definitions
  362.             //-------------------------------------------------------------------------------------
  363.        
  364.             #pragma vertex Vert
  365.             #pragma fragment Frag
  366.        
  367.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  368.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Wind.hlsl"
  369.        
  370.             // define FragInputs structure
  371.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  372.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  373.        
  374.             //-------------------------------------------------------------------------------------
  375.             // Defines
  376.             //-------------------------------------------------------------------------------------
  377.                     #define SHADERPASS SHADERPASS_LIGHT_TRANSPORT
  378.        
  379.             // this translates the new dependency tracker into the old preprocessor definitions for the existing HDRP shader code
  380.             #define ATTRIBUTES_NEED_NORMAL
  381.             #define ATTRIBUTES_NEED_TANGENT
  382.             #define ATTRIBUTES_NEED_TEXCOORD0
  383.             #define ATTRIBUTES_NEED_TEXCOORD1
  384.             #define ATTRIBUTES_NEED_TEXCOORD2
  385.             #define ATTRIBUTES_NEED_COLOR
  386.             #define VARYINGS_NEED_TEXCOORD0
  387.        
  388.             //-------------------------------------------------------------------------------------
  389.             // End Defines
  390.             //-------------------------------------------------------------------------------------
  391.        
  392.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
  393.         #ifdef DEBUG_DISPLAY
  394.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
  395.         #endif
  396.        
  397.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
  398.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
  399.        
  400.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
  401.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
  402.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
  403.        
  404.             // Used by SceneSelectionPass
  405.             int _ObjectId;
  406.             int _PassValue;
  407.        
  408.             //-------------------------------------------------------------------------------------
  409.             // Interpolator Packing And Struct Declarations
  410.             //-------------------------------------------------------------------------------------
  411.         // Generated Type: AttributesMesh
  412.         struct AttributesMesh {
  413.             float3 positionOS : POSITION;
  414.             float3 normalOS : NORMAL; // optional
  415.             float4 tangentOS : TANGENT; // optional
  416.             float4 uv0 : TEXCOORD0; // optional
  417.             float4 uv1 : TEXCOORD1; // optional
  418.             float4 uv2 : TEXCOORD2; // optional
  419.             float4 color : COLOR; // optional
  420.             #if UNITY_ANY_INSTANCING_ENABLED
  421.             uint instanceID : INSTANCEID_SEMANTIC;
  422.             #endif // UNITY_ANY_INSTANCING_ENABLED
  423.         };
  424.        
  425.         // Generated Type: VaryingsMeshToPS
  426.         struct VaryingsMeshToPS {
  427.             float4 positionCS : SV_Position;
  428.             float4 texCoord0; // optional
  429.             #if UNITY_ANY_INSTANCING_ENABLED
  430.             uint instanceID : INSTANCEID_SEMANTIC;
  431.             #endif // UNITY_ANY_INSTANCING_ENABLED
  432.         };
  433.         struct PackedVaryingsMeshToPS {
  434.             float4 interp00 : TEXCOORD0; // auto-packed
  435.             float4 positionCS : SV_Position; // unpacked
  436.             #if UNITY_ANY_INSTANCING_ENABLED
  437.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  438.             #endif // UNITY_ANY_INSTANCING_ENABLED
  439.         };
  440.         PackedVaryingsMeshToPS PackVaryingsMeshToPS(VaryingsMeshToPS input)
  441.         {
  442.             PackedVaryingsMeshToPS output;
  443.             output.positionCS = input.positionCS;
  444.             output.interp00.xyzw = input.texCoord0;
  445.             #if UNITY_ANY_INSTANCING_ENABLED
  446.             output.instanceID = input.instanceID;
  447.             #endif // UNITY_ANY_INSTANCING_ENABLED
  448.             return output;
  449.         }
  450.         VaryingsMeshToPS UnpackVaryingsMeshToPS(PackedVaryingsMeshToPS input)
  451.         {
  452.             VaryingsMeshToPS output;
  453.             output.positionCS = input.positionCS;
  454.             output.texCoord0 = input.interp00.xyzw;
  455.             #if UNITY_ANY_INSTANCING_ENABLED
  456.             output.instanceID = input.instanceID;
  457.             #endif // UNITY_ANY_INSTANCING_ENABLED
  458.             return output;
  459.         }
  460.        
  461.         // Generated Type: VaryingsMeshToDS
  462.         struct VaryingsMeshToDS {
  463.             float3 positionRWS;
  464.             float3 normalWS;
  465.             #if UNITY_ANY_INSTANCING_ENABLED
  466.             uint instanceID : INSTANCEID_SEMANTIC;
  467.             #endif // UNITY_ANY_INSTANCING_ENABLED
  468.         };
  469.         struct PackedVaryingsMeshToDS {
  470.             float3 interp00 : TEXCOORD0; // auto-packed
  471.             float3 interp01 : TEXCOORD1; // auto-packed
  472.             #if UNITY_ANY_INSTANCING_ENABLED
  473.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  474.             #endif // UNITY_ANY_INSTANCING_ENABLED
  475.         };
  476.         PackedVaryingsMeshToDS PackVaryingsMeshToDS(VaryingsMeshToDS input)
  477.         {
  478.             PackedVaryingsMeshToDS output;
  479.             output.interp00.xyz = input.positionRWS;
  480.             output.interp01.xyz = input.normalWS;
  481.             #if UNITY_ANY_INSTANCING_ENABLED
  482.             output.instanceID = input.instanceID;
  483.             #endif // UNITY_ANY_INSTANCING_ENABLED
  484.             return output;
  485.         }
  486.         VaryingsMeshToDS UnpackVaryingsMeshToDS(PackedVaryingsMeshToDS input)
  487.         {
  488.             VaryingsMeshToDS output;
  489.             output.positionRWS = input.interp00.xyz;
  490.             output.normalWS = input.interp01.xyz;
  491.             #if UNITY_ANY_INSTANCING_ENABLED
  492.             output.instanceID = input.instanceID;
  493.             #endif // UNITY_ANY_INSTANCING_ENABLED
  494.             return output;
  495.         }
  496.        
  497.             //-------------------------------------------------------------------------------------
  498.             // End Interpolator Packing And Struct Declarations
  499.             //-------------------------------------------------------------------------------------
  500.        
  501.             //-------------------------------------------------------------------------------------
  502.             // Graph generated code
  503.             //-------------------------------------------------------------------------------------
  504.                     // Shared Graph Properties (uniform inputs)
  505.                     CBUFFER_START(UnityPerMaterial)
  506.                     CBUFFER_END
  507.                
  508.                     TEXTURE2D(_Texture2DAsset_63806780_Out); SAMPLER(sampler_Texture2DAsset_63806780_Out); float4 _Texture2DAsset_63806780_Out_TexelSize;
  509.                
  510.                 // Pixel Graph Inputs
  511.                     struct SurfaceDescriptionInputs {
  512.                         float4 uv0; // optional
  513.                     };
  514.                 // Pixel Graph Outputs
  515.                     struct SurfaceDescription
  516.                     {
  517.                         float3 Color;
  518.                         float Alpha;
  519.                         float AlphaClipThreshold;
  520.                     };
  521.                    
  522.                 // Shared Graph Node Functions
  523.                 // Pixel Graph Evaluation
  524.                     SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
  525.                     {
  526.                         SurfaceDescription surface = (SurfaceDescription)0;
  527.                         float4 _SampleTexture2D_A19560AC_RGBA = SAMPLE_TEXTURE2D(_Texture2DAsset_63806780_Out, sampler_Texture2DAsset_63806780_Out, IN.uv0.xy);
  528.                         float _SampleTexture2D_A19560AC_R = _SampleTexture2D_A19560AC_RGBA.r;
  529.                         float _SampleTexture2D_A19560AC_G = _SampleTexture2D_A19560AC_RGBA.g;
  530.                         float _SampleTexture2D_A19560AC_B = _SampleTexture2D_A19560AC_RGBA.b;
  531.                         float _SampleTexture2D_A19560AC_A = _SampleTexture2D_A19560AC_RGBA.a;
  532.                         surface.Color = (_SampleTexture2D_A19560AC_RGBA.xyz);
  533.                         surface.Alpha = _SampleTexture2D_A19560AC_A;
  534.                         surface.AlphaClipThreshold = 0.5;
  535.                         return surface;
  536.                     }
  537.                    
  538.             //-------------------------------------------------------------------------------------
  539.             // End graph generated code
  540.             //-------------------------------------------------------------------------------------
  541.        
  542.        
  543.        
  544.         //-------------------------------------------------------------------------------------
  545.         // TEMPLATE INCLUDE : SharedCode.template.hlsl
  546.         //-------------------------------------------------------------------------------------
  547.             FragInputs BuildFragInputs(VaryingsMeshToPS input)
  548.             {
  549.                 FragInputs output;
  550.                 ZERO_INITIALIZE(FragInputs, output);
  551.        
  552.                 // Init to some default value to make the computer quiet (else it output 'divide by zero' warning even if value is not used).
  553.                 // TODO: this is a really poor workaround, but the variable is used in a bunch of places
  554.                 // to compute normals which are then passed on elsewhere to compute other values...
  555.                 output.worldToTangent = k_identity3x3;
  556.                 output.positionSS = input.positionCS;       // input.positionCS is SV_Position
  557.        
  558.                 output.texCoord0 = input.texCoord0;
  559.                 #if SHADER_STAGE_FRAGMENT
  560.                 #endif // SHADER_STAGE_FRAGMENT
  561.        
  562.                 return output;
  563.             }
  564.        
  565.             SurfaceDescriptionInputs FragInputsToSurfaceDescriptionInputs(FragInputs input, float3 viewWS)
  566.             {
  567.                 SurfaceDescriptionInputs output;
  568.                 ZERO_INITIALIZE(SurfaceDescriptionInputs, output);
  569.        
  570.                 output.uv0 =                         input.texCoord0;
  571.        
  572.                 return output;
  573.             }
  574.        
  575.             // existing HDRP code uses the combined function to go directly from packed to frag inputs
  576.             FragInputs UnpackVaryingsMeshToFragInputs(PackedVaryingsMeshToPS input)
  577.             {
  578.                 UNITY_SETUP_INSTANCE_ID(input);
  579.                 VaryingsMeshToPS unpacked= UnpackVaryingsMeshToPS(input);
  580.                 return BuildFragInputs(unpacked);
  581.             }
  582.        
  583.         //-------------------------------------------------------------------------------------
  584.         // END TEMPLATE INCLUDE : SharedCode.template.hlsl
  585.         //-------------------------------------------------------------------------------------
  586.        
  587.        
  588.        
  589.             void BuildSurfaceData(FragInputs fragInputs, inout SurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData)
  590.             {
  591.                 // setup defaults -- these are used if the graph doesn't output a value
  592.                 ZERO_INITIALIZE(SurfaceData, surfaceData);
  593.        
  594.                 // copy across graph values, if defined
  595.                 surfaceData.color = surfaceDescription.Color;
  596.        
  597.         #if defined(DEBUG_DISPLAY)
  598.                 if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
  599.                 {
  600.                     // TODO
  601.                 }
  602.         #endif
  603.             }
  604.        
  605.             void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
  606.             {
  607.                 SurfaceDescriptionInputs surfaceDescriptionInputs = FragInputsToSurfaceDescriptionInputs(fragInputs, V);
  608.                 SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
  609.        
  610.                 // Perform alpha test very early to save performance (a killed pixel will not sample textures)
  611.                 // TODO: split graph evaluation to grab just alpha dependencies first? tricky..
  612.                 DoAlphaTest(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold);
  613.        
  614.                 BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
  615.        
  616.                 // Builtin Data
  617.                 ZERO_INITIALIZE(BuiltinData, builtinData); // No call to InitBuiltinData as we don't have any lighting
  618.        
  619.                 builtinData.opacity = surfaceDescription.Alpha;
  620.        
  621.        
  622.         #if (SHADERPASS == SHADERPASS_DISTORTION)
  623.                 builtinData.distortion = surfaceDescription.Distortion;
  624.                 builtinData.distortionBlur = surfaceDescription.DistortionBlur;
  625.         #else
  626.                 builtinData.distortion = float2(0.0, 0.0);
  627.                 builtinData.distortionBlur = 0.0;
  628.         #endif
  629.             }
  630.        
  631.             //-------------------------------------------------------------------------------------
  632.             // Pass Includes
  633.             //-------------------------------------------------------------------------------------
  634.                 #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl"
  635.             //-------------------------------------------------------------------------------------
  636.             // End Pass Includes
  637.             //-------------------------------------------------------------------------------------
  638.        
  639.             ENDHLSL
  640.         }
  641.        
  642.         Pass
  643.         {
  644.             // based on HDUnlitPassForward.template
  645.             Name "SceneSelectionPass"
  646.             Tags { "LightMode" = "SceneSelectionPass" }
  647.        
  648.             //-------------------------------------------------------------------------------------
  649.             // Render Modes (Blend, Cull, ZTest, Stencil, etc)
  650.             //-------------------------------------------------------------------------------------
  651.             Blend One Zero
  652.        
  653.             Cull Back
  654.        
  655.             ZTest LEqual
  656.        
  657.             ZWrite On
  658.        
  659.             // Default Stencil
  660.        
  661.             ColorMask 0
  662.        
  663.             //-------------------------------------------------------------------------------------
  664.             // End Render Modes
  665.             //-------------------------------------------------------------------------------------
  666.        
  667.             HLSLPROGRAM
  668.        
  669.             #pragma target 4.5
  670.             #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
  671.             //#pragma enable_d3d11_debug_symbols
  672.        
  673.             //enable GPU instancing support
  674.             #pragma multi_compile_instancing
  675.        
  676.             //-------------------------------------------------------------------------------------
  677.             // Variant Definitions (active field translations to HDRP defines)
  678.             //-------------------------------------------------------------------------------------
  679.             //-------------------------------------------------------------------------------------
  680.             // End Variant Definitions
  681.             //-------------------------------------------------------------------------------------
  682.        
  683.             #pragma vertex Vert
  684.             #pragma fragment Frag
  685.        
  686.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  687.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Wind.hlsl"
  688.        
  689.             // define FragInputs structure
  690.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  691.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  692.        
  693.             //-------------------------------------------------------------------------------------
  694.             // Defines
  695.             //-------------------------------------------------------------------------------------
  696.                     #define SHADERPASS SHADERPASS_DEPTH_ONLY
  697.                 #define SCENESELECTIONPASS
  698.        
  699.             // this translates the new dependency tracker into the old preprocessor definitions for the existing HDRP shader code
  700.             #define ATTRIBUTES_NEED_TEXCOORD0
  701.             #define VARYINGS_NEED_TEXCOORD0
  702.        
  703.             //-------------------------------------------------------------------------------------
  704.             // End Defines
  705.             //-------------------------------------------------------------------------------------
  706.        
  707.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
  708.         #ifdef DEBUG_DISPLAY
  709.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
  710.         #endif
  711.        
  712.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
  713.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
  714.        
  715.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
  716.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
  717.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
  718.        
  719.             // Used by SceneSelectionPass
  720.             int _ObjectId;
  721.             int _PassValue;
  722.        
  723.             //-------------------------------------------------------------------------------------
  724.             // Interpolator Packing And Struct Declarations
  725.             //-------------------------------------------------------------------------------------
  726.         // Generated Type: AttributesMesh
  727.         struct AttributesMesh {
  728.             float3 positionOS : POSITION;
  729.             float4 uv0 : TEXCOORD0; // optional
  730.             #if UNITY_ANY_INSTANCING_ENABLED
  731.             uint instanceID : INSTANCEID_SEMANTIC;
  732.             #endif // UNITY_ANY_INSTANCING_ENABLED
  733.         };
  734.        
  735.         // Generated Type: VaryingsMeshToPS
  736.         struct VaryingsMeshToPS {
  737.             float4 positionCS : SV_Position;
  738.             float4 texCoord0; // optional
  739.             #if UNITY_ANY_INSTANCING_ENABLED
  740.             uint instanceID : INSTANCEID_SEMANTIC;
  741.             #endif // UNITY_ANY_INSTANCING_ENABLED
  742.         };
  743.         struct PackedVaryingsMeshToPS {
  744.             float4 interp00 : TEXCOORD0; // auto-packed
  745.             float4 positionCS : SV_Position; // unpacked
  746.             #if UNITY_ANY_INSTANCING_ENABLED
  747.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  748.             #endif // UNITY_ANY_INSTANCING_ENABLED
  749.         };
  750.         PackedVaryingsMeshToPS PackVaryingsMeshToPS(VaryingsMeshToPS input)
  751.         {
  752.             PackedVaryingsMeshToPS output;
  753.             output.positionCS = input.positionCS;
  754.             output.interp00.xyzw = input.texCoord0;
  755.             #if UNITY_ANY_INSTANCING_ENABLED
  756.             output.instanceID = input.instanceID;
  757.             #endif // UNITY_ANY_INSTANCING_ENABLED
  758.             return output;
  759.         }
  760.         VaryingsMeshToPS UnpackVaryingsMeshToPS(PackedVaryingsMeshToPS input)
  761.         {
  762.             VaryingsMeshToPS output;
  763.             output.positionCS = input.positionCS;
  764.             output.texCoord0 = input.interp00.xyzw;
  765.             #if UNITY_ANY_INSTANCING_ENABLED
  766.             output.instanceID = input.instanceID;
  767.             #endif // UNITY_ANY_INSTANCING_ENABLED
  768.             return output;
  769.         }
  770.        
  771.         // Generated Type: VaryingsMeshToDS
  772.         struct VaryingsMeshToDS {
  773.             float3 positionRWS;
  774.             float3 normalWS;
  775.             #if UNITY_ANY_INSTANCING_ENABLED
  776.             uint instanceID : INSTANCEID_SEMANTIC;
  777.             #endif // UNITY_ANY_INSTANCING_ENABLED
  778.         };
  779.         struct PackedVaryingsMeshToDS {
  780.             float3 interp00 : TEXCOORD0; // auto-packed
  781.             float3 interp01 : TEXCOORD1; // auto-packed
  782.             #if UNITY_ANY_INSTANCING_ENABLED
  783.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  784.             #endif // UNITY_ANY_INSTANCING_ENABLED
  785.         };
  786.         PackedVaryingsMeshToDS PackVaryingsMeshToDS(VaryingsMeshToDS input)
  787.         {
  788.             PackedVaryingsMeshToDS output;
  789.             output.interp00.xyz = input.positionRWS;
  790.             output.interp01.xyz = input.normalWS;
  791.             #if UNITY_ANY_INSTANCING_ENABLED
  792.             output.instanceID = input.instanceID;
  793.             #endif // UNITY_ANY_INSTANCING_ENABLED
  794.             return output;
  795.         }
  796.         VaryingsMeshToDS UnpackVaryingsMeshToDS(PackedVaryingsMeshToDS input)
  797.         {
  798.             VaryingsMeshToDS output;
  799.             output.positionRWS = input.interp00.xyz;
  800.             output.normalWS = input.interp01.xyz;
  801.             #if UNITY_ANY_INSTANCING_ENABLED
  802.             output.instanceID = input.instanceID;
  803.             #endif // UNITY_ANY_INSTANCING_ENABLED
  804.             return output;
  805.         }
  806.        
  807.             //-------------------------------------------------------------------------------------
  808.             // End Interpolator Packing And Struct Declarations
  809.             //-------------------------------------------------------------------------------------
  810.        
  811.             //-------------------------------------------------------------------------------------
  812.             // Graph generated code
  813.             //-------------------------------------------------------------------------------------
  814.                     // Shared Graph Properties (uniform inputs)
  815.                     CBUFFER_START(UnityPerMaterial)
  816.                     CBUFFER_END
  817.                
  818.                     TEXTURE2D(_Texture2DAsset_63806780_Out); SAMPLER(sampler_Texture2DAsset_63806780_Out); float4 _Texture2DAsset_63806780_Out_TexelSize;
  819.                
  820.                 // Pixel Graph Inputs
  821.                     struct SurfaceDescriptionInputs {
  822.                         float4 uv0; // optional
  823.                     };
  824.                 // Pixel Graph Outputs
  825.                     struct SurfaceDescription
  826.                     {
  827.                         float Alpha;
  828.                         float AlphaClipThreshold;
  829.                     };
  830.                    
  831.                 // Shared Graph Node Functions
  832.                 // Pixel Graph Evaluation
  833.                     SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
  834.                     {
  835.                         SurfaceDescription surface = (SurfaceDescription)0;
  836.                         float4 _SampleTexture2D_A19560AC_RGBA = SAMPLE_TEXTURE2D(_Texture2DAsset_63806780_Out, sampler_Texture2DAsset_63806780_Out, IN.uv0.xy);
  837.                         float _SampleTexture2D_A19560AC_R = _SampleTexture2D_A19560AC_RGBA.r;
  838.                         float _SampleTexture2D_A19560AC_G = _SampleTexture2D_A19560AC_RGBA.g;
  839.                         float _SampleTexture2D_A19560AC_B = _SampleTexture2D_A19560AC_RGBA.b;
  840.                         float _SampleTexture2D_A19560AC_A = _SampleTexture2D_A19560AC_RGBA.a;
  841.                         surface.Alpha = _SampleTexture2D_A19560AC_A;
  842.                         surface.AlphaClipThreshold = 0.5;
  843.                         return surface;
  844.                     }
  845.                    
  846.             //-------------------------------------------------------------------------------------
  847.             // End graph generated code
  848.             //-------------------------------------------------------------------------------------
  849.        
  850.        
  851.        
  852.         //-------------------------------------------------------------------------------------
  853.         // TEMPLATE INCLUDE : SharedCode.template.hlsl
  854.         //-------------------------------------------------------------------------------------
  855.             FragInputs BuildFragInputs(VaryingsMeshToPS input)
  856.             {
  857.                 FragInputs output;
  858.                 ZERO_INITIALIZE(FragInputs, output);
  859.        
  860.                 // Init to some default value to make the computer quiet (else it output 'divide by zero' warning even if value is not used).
  861.                 // TODO: this is a really poor workaround, but the variable is used in a bunch of places
  862.                 // to compute normals which are then passed on elsewhere to compute other values...
  863.                 output.worldToTangent = k_identity3x3;
  864.                 output.positionSS = input.positionCS;       // input.positionCS is SV_Position
  865.        
  866.                 output.texCoord0 = input.texCoord0;
  867.                 #if SHADER_STAGE_FRAGMENT
  868.                 #endif // SHADER_STAGE_FRAGMENT
  869.        
  870.                 return output;
  871.             }
  872.        
  873.             SurfaceDescriptionInputs FragInputsToSurfaceDescriptionInputs(FragInputs input, float3 viewWS)
  874.             {
  875.                 SurfaceDescriptionInputs output;
  876.                 ZERO_INITIALIZE(SurfaceDescriptionInputs, output);
  877.        
  878.                 output.uv0 =                         input.texCoord0;
  879.        
  880.                 return output;
  881.             }
  882.        
  883.             // existing HDRP code uses the combined function to go directly from packed to frag inputs
  884.             FragInputs UnpackVaryingsMeshToFragInputs(PackedVaryingsMeshToPS input)
  885.             {
  886.                 UNITY_SETUP_INSTANCE_ID(input);
  887.                 VaryingsMeshToPS unpacked= UnpackVaryingsMeshToPS(input);
  888.                 return BuildFragInputs(unpacked);
  889.             }
  890.        
  891.         //-------------------------------------------------------------------------------------
  892.         // END TEMPLATE INCLUDE : SharedCode.template.hlsl
  893.         //-------------------------------------------------------------------------------------
  894.        
  895.        
  896.        
  897.             void BuildSurfaceData(FragInputs fragInputs, inout SurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData)
  898.             {
  899.                 // setup defaults -- these are used if the graph doesn't output a value
  900.                 ZERO_INITIALIZE(SurfaceData, surfaceData);
  901.        
  902.                 // copy across graph values, if defined
  903.        
  904.         #if defined(DEBUG_DISPLAY)
  905.                 if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
  906.                 {
  907.                     // TODO
  908.                 }
  909.         #endif
  910.             }
  911.        
  912.             void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
  913.             {
  914.                 SurfaceDescriptionInputs surfaceDescriptionInputs = FragInputsToSurfaceDescriptionInputs(fragInputs, V);
  915.                 SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
  916.        
  917.                 // Perform alpha test very early to save performance (a killed pixel will not sample textures)
  918.                 // TODO: split graph evaluation to grab just alpha dependencies first? tricky..
  919.                 DoAlphaTest(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold);
  920.        
  921.                 BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
  922.        
  923.                 // Builtin Data
  924.                 ZERO_INITIALIZE(BuiltinData, builtinData); // No call to InitBuiltinData as we don't have any lighting
  925.        
  926.                 builtinData.opacity = surfaceDescription.Alpha;
  927.        
  928.        
  929.         #if (SHADERPASS == SHADERPASS_DISTORTION)
  930.                 builtinData.distortion = surfaceDescription.Distortion;
  931.                 builtinData.distortionBlur = surfaceDescription.DistortionBlur;
  932.         #else
  933.                 builtinData.distortion = float2(0.0, 0.0);
  934.                 builtinData.distortionBlur = 0.0;
  935.         #endif
  936.             }
  937.        
  938.             //-------------------------------------------------------------------------------------
  939.             // Pass Includes
  940.             //-------------------------------------------------------------------------------------
  941.                 #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl"
  942.             //-------------------------------------------------------------------------------------
  943.             // End Pass Includes
  944.             //-------------------------------------------------------------------------------------
  945.        
  946.             ENDHLSL
  947.         }
  948.        
  949.         Pass
  950.         {
  951.             // based on HDUnlitPassForward.template
  952.             Name "DepthForwardOnly"
  953.             Tags { "LightMode" = "DepthForwardOnly" }
  954.        
  955.             //-------------------------------------------------------------------------------------
  956.             // Render Modes (Blend, Cull, ZTest, Stencil, etc)
  957.             //-------------------------------------------------------------------------------------
  958.             Blend One Zero
  959.        
  960.             Cull Back
  961.        
  962.             ZTest LEqual
  963.        
  964.             ZWrite On
  965.        
  966.             // Default Stencil
  967.        
  968.            
  969.             //-------------------------------------------------------------------------------------
  970.             // End Render Modes
  971.             //-------------------------------------------------------------------------------------
  972.        
  973.             HLSLPROGRAM
  974.        
  975.             #pragma target 4.5
  976.             #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
  977.             //#pragma enable_d3d11_debug_symbols
  978.        
  979.             //enable GPU instancing support
  980.             #pragma multi_compile_instancing
  981.        
  982.             //-------------------------------------------------------------------------------------
  983.             // Variant Definitions (active field translations to HDRP defines)
  984.             //-------------------------------------------------------------------------------------
  985.             //-------------------------------------------------------------------------------------
  986.             // End Variant Definitions
  987.             //-------------------------------------------------------------------------------------
  988.        
  989.             #pragma vertex Vert
  990.             #pragma fragment Frag
  991.        
  992.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  993.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Wind.hlsl"
  994.        
  995.             // define FragInputs structure
  996.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  997.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  998.        
  999.             //-------------------------------------------------------------------------------------
  1000.             // Defines
  1001.             //-------------------------------------------------------------------------------------
  1002.                     #define SHADERPASS SHADERPASS_DEPTH_ONLY
  1003.        
  1004.             // this translates the new dependency tracker into the old preprocessor definitions for the existing HDRP shader code
  1005.             #define ATTRIBUTES_NEED_TEXCOORD0
  1006.             #define VARYINGS_NEED_TEXCOORD0
  1007.        
  1008.             //-------------------------------------------------------------------------------------
  1009.             // End Defines
  1010.             //-------------------------------------------------------------------------------------
  1011.        
  1012.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
  1013.         #ifdef DEBUG_DISPLAY
  1014.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
  1015.         #endif
  1016.        
  1017.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
  1018.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
  1019.        
  1020.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
  1021.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
  1022.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1023.        
  1024.             // Used by SceneSelectionPass
  1025.             int _ObjectId;
  1026.             int _PassValue;
  1027.        
  1028.             //-------------------------------------------------------------------------------------
  1029.             // Interpolator Packing And Struct Declarations
  1030.             //-------------------------------------------------------------------------------------
  1031.         // Generated Type: AttributesMesh
  1032.         struct AttributesMesh {
  1033.             float3 positionOS : POSITION;
  1034.             float4 uv0 : TEXCOORD0; // optional
  1035.             #if UNITY_ANY_INSTANCING_ENABLED
  1036.             uint instanceID : INSTANCEID_SEMANTIC;
  1037.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1038.         };
  1039.        
  1040.         // Generated Type: VaryingsMeshToPS
  1041.         struct VaryingsMeshToPS {
  1042.             float4 positionCS : SV_Position;
  1043.             float4 texCoord0; // optional
  1044.             #if UNITY_ANY_INSTANCING_ENABLED
  1045.             uint instanceID : INSTANCEID_SEMANTIC;
  1046.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1047.         };
  1048.         struct PackedVaryingsMeshToPS {
  1049.             float4 interp00 : TEXCOORD0; // auto-packed
  1050.             float4 positionCS : SV_Position; // unpacked
  1051.             #if UNITY_ANY_INSTANCING_ENABLED
  1052.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  1053.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1054.         };
  1055.         PackedVaryingsMeshToPS PackVaryingsMeshToPS(VaryingsMeshToPS input)
  1056.         {
  1057.             PackedVaryingsMeshToPS output;
  1058.             output.positionCS = input.positionCS;
  1059.             output.interp00.xyzw = input.texCoord0;
  1060.             #if UNITY_ANY_INSTANCING_ENABLED
  1061.             output.instanceID = input.instanceID;
  1062.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1063.             return output;
  1064.         }
  1065.         VaryingsMeshToPS UnpackVaryingsMeshToPS(PackedVaryingsMeshToPS input)
  1066.         {
  1067.             VaryingsMeshToPS output;
  1068.             output.positionCS = input.positionCS;
  1069.             output.texCoord0 = input.interp00.xyzw;
  1070.             #if UNITY_ANY_INSTANCING_ENABLED
  1071.             output.instanceID = input.instanceID;
  1072.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1073.             return output;
  1074.         }
  1075.        
  1076.         // Generated Type: VaryingsMeshToDS
  1077.         struct VaryingsMeshToDS {
  1078.             float3 positionRWS;
  1079.             float3 normalWS;
  1080.             #if UNITY_ANY_INSTANCING_ENABLED
  1081.             uint instanceID : INSTANCEID_SEMANTIC;
  1082.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1083.         };
  1084.         struct PackedVaryingsMeshToDS {
  1085.             float3 interp00 : TEXCOORD0; // auto-packed
  1086.             float3 interp01 : TEXCOORD1; // auto-packed
  1087.             #if UNITY_ANY_INSTANCING_ENABLED
  1088.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  1089.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1090.         };
  1091.         PackedVaryingsMeshToDS PackVaryingsMeshToDS(VaryingsMeshToDS input)
  1092.         {
  1093.             PackedVaryingsMeshToDS output;
  1094.             output.interp00.xyz = input.positionRWS;
  1095.             output.interp01.xyz = input.normalWS;
  1096.             #if UNITY_ANY_INSTANCING_ENABLED
  1097.             output.instanceID = input.instanceID;
  1098.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1099.             return output;
  1100.         }
  1101.         VaryingsMeshToDS UnpackVaryingsMeshToDS(PackedVaryingsMeshToDS input)
  1102.         {
  1103.             VaryingsMeshToDS output;
  1104.             output.positionRWS = input.interp00.xyz;
  1105.             output.normalWS = input.interp01.xyz;
  1106.             #if UNITY_ANY_INSTANCING_ENABLED
  1107.             output.instanceID = input.instanceID;
  1108.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1109.             return output;
  1110.         }
  1111.        
  1112.             //-------------------------------------------------------------------------------------
  1113.             // End Interpolator Packing And Struct Declarations
  1114.             //-------------------------------------------------------------------------------------
  1115.        
  1116.             //-------------------------------------------------------------------------------------
  1117.             // Graph generated code
  1118.             //-------------------------------------------------------------------------------------
  1119.                     // Shared Graph Properties (uniform inputs)
  1120.                     CBUFFER_START(UnityPerMaterial)
  1121.                     CBUFFER_END
  1122.                
  1123.                     TEXTURE2D(_Texture2DAsset_63806780_Out); SAMPLER(sampler_Texture2DAsset_63806780_Out); float4 _Texture2DAsset_63806780_Out_TexelSize;
  1124.                
  1125.                 // Pixel Graph Inputs
  1126.                     struct SurfaceDescriptionInputs {
  1127.                         float4 uv0; // optional
  1128.                     };
  1129.                 // Pixel Graph Outputs
  1130.                     struct SurfaceDescription
  1131.                     {
  1132.                         float Alpha;
  1133.                         float AlphaClipThreshold;
  1134.                     };
  1135.                    
  1136.                 // Shared Graph Node Functions
  1137.                 // Pixel Graph Evaluation
  1138.                     SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
  1139.                     {
  1140.                         SurfaceDescription surface = (SurfaceDescription)0;
  1141.                         float4 _SampleTexture2D_A19560AC_RGBA = SAMPLE_TEXTURE2D(_Texture2DAsset_63806780_Out, sampler_Texture2DAsset_63806780_Out, IN.uv0.xy);
  1142.                         float _SampleTexture2D_A19560AC_R = _SampleTexture2D_A19560AC_RGBA.r;
  1143.                         float _SampleTexture2D_A19560AC_G = _SampleTexture2D_A19560AC_RGBA.g;
  1144.                         float _SampleTexture2D_A19560AC_B = _SampleTexture2D_A19560AC_RGBA.b;
  1145.                         float _SampleTexture2D_A19560AC_A = _SampleTexture2D_A19560AC_RGBA.a;
  1146.                         surface.Alpha = _SampleTexture2D_A19560AC_A;
  1147.                         surface.AlphaClipThreshold = 0.5;
  1148.                         return surface;
  1149.                     }
  1150.                    
  1151.             //-------------------------------------------------------------------------------------
  1152.             // End graph generated code
  1153.             //-------------------------------------------------------------------------------------
  1154.        
  1155.        
  1156.        
  1157.         //-------------------------------------------------------------------------------------
  1158.         // TEMPLATE INCLUDE : SharedCode.template.hlsl
  1159.         //-------------------------------------------------------------------------------------
  1160.             FragInputs BuildFragInputs(VaryingsMeshToPS input)
  1161.             {
  1162.                 FragInputs output;
  1163.                 ZERO_INITIALIZE(FragInputs, output);
  1164.        
  1165.                 // Init to some default value to make the computer quiet (else it output 'divide by zero' warning even if value is not used).
  1166.                 // TODO: this is a really poor workaround, but the variable is used in a bunch of places
  1167.                 // to compute normals which are then passed on elsewhere to compute other values...
  1168.                 output.worldToTangent = k_identity3x3;
  1169.                 output.positionSS = input.positionCS;       // input.positionCS is SV_Position
  1170.        
  1171.                 output.texCoord0 = input.texCoord0;
  1172.                 #if SHADER_STAGE_FRAGMENT
  1173.                 #endif // SHADER_STAGE_FRAGMENT
  1174.        
  1175.                 return output;
  1176.             }
  1177.        
  1178.             SurfaceDescriptionInputs FragInputsToSurfaceDescriptionInputs(FragInputs input, float3 viewWS)
  1179.             {
  1180.                 SurfaceDescriptionInputs output;
  1181.                 ZERO_INITIALIZE(SurfaceDescriptionInputs, output);
  1182.        
  1183.                 output.uv0 =                         input.texCoord0;
  1184.        
  1185.                 return output;
  1186.             }
  1187.        
  1188.             // existing HDRP code uses the combined function to go directly from packed to frag inputs
  1189.             FragInputs UnpackVaryingsMeshToFragInputs(PackedVaryingsMeshToPS input)
  1190.             {
  1191.                 UNITY_SETUP_INSTANCE_ID(input);
  1192.                 VaryingsMeshToPS unpacked= UnpackVaryingsMeshToPS(input);
  1193.                 return BuildFragInputs(unpacked);
  1194.             }
  1195.        
  1196.         //-------------------------------------------------------------------------------------
  1197.         // END TEMPLATE INCLUDE : SharedCode.template.hlsl
  1198.         //-------------------------------------------------------------------------------------
  1199.        
  1200.        
  1201.        
  1202.             void BuildSurfaceData(FragInputs fragInputs, inout SurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData)
  1203.             {
  1204.                 // setup defaults -- these are used if the graph doesn't output a value
  1205.                 ZERO_INITIALIZE(SurfaceData, surfaceData);
  1206.        
  1207.                 // copy across graph values, if defined
  1208.        
  1209.         #if defined(DEBUG_DISPLAY)
  1210.                 if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
  1211.                 {
  1212.                     // TODO
  1213.                 }
  1214.         #endif
  1215.             }
  1216.        
  1217.             void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
  1218.             {
  1219.                 SurfaceDescriptionInputs surfaceDescriptionInputs = FragInputsToSurfaceDescriptionInputs(fragInputs, V);
  1220.                 SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
  1221.        
  1222.                 // Perform alpha test very early to save performance (a killed pixel will not sample textures)
  1223.                 // TODO: split graph evaluation to grab just alpha dependencies first? tricky..
  1224.                 DoAlphaTest(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold);
  1225.        
  1226.                 BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
  1227.        
  1228.                 // Builtin Data
  1229.                 ZERO_INITIALIZE(BuiltinData, builtinData); // No call to InitBuiltinData as we don't have any lighting
  1230.        
  1231.                 builtinData.opacity = surfaceDescription.Alpha;
  1232.        
  1233.        
  1234.         #if (SHADERPASS == SHADERPASS_DISTORTION)
  1235.                 builtinData.distortion = surfaceDescription.Distortion;
  1236.                 builtinData.distortionBlur = surfaceDescription.DistortionBlur;
  1237.         #else
  1238.                 builtinData.distortion = float2(0.0, 0.0);
  1239.                 builtinData.distortionBlur = 0.0;
  1240.         #endif
  1241.             }
  1242.        
  1243.             //-------------------------------------------------------------------------------------
  1244.             // Pass Includes
  1245.             //-------------------------------------------------------------------------------------
  1246.                 #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl"
  1247.             //-------------------------------------------------------------------------------------
  1248.             // End Pass Includes
  1249.             //-------------------------------------------------------------------------------------
  1250.        
  1251.             ENDHLSL
  1252.         }
  1253.        
  1254.         Pass
  1255.         {
  1256.             // based on HDUnlitPassForward.template
  1257.             Name "MotionVectors"
  1258.             Tags { "LightMode" = "MotionVectors" }
  1259.        
  1260.             //-------------------------------------------------------------------------------------
  1261.             // Render Modes (Blend, Cull, ZTest, Stencil, etc)
  1262.             //-------------------------------------------------------------------------------------
  1263.             Blend One Zero
  1264.        
  1265.             Cull Back
  1266.        
  1267.             ZTest LEqual
  1268.        
  1269.             ZWrite On
  1270.        
  1271.             // Default Stencil
  1272.        
  1273.            
  1274.             //-------------------------------------------------------------------------------------
  1275.             // End Render Modes
  1276.             //-------------------------------------------------------------------------------------
  1277.        
  1278.             HLSLPROGRAM
  1279.        
  1280.             #pragma target 4.5
  1281.             #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
  1282.             //#pragma enable_d3d11_debug_symbols
  1283.        
  1284.             //enable GPU instancing support
  1285.             #pragma multi_compile_instancing
  1286.        
  1287.             //-------------------------------------------------------------------------------------
  1288.             // Variant Definitions (active field translations to HDRP defines)
  1289.             //-------------------------------------------------------------------------------------
  1290.             //-------------------------------------------------------------------------------------
  1291.             // End Variant Definitions
  1292.             //-------------------------------------------------------------------------------------
  1293.        
  1294.             #pragma vertex Vert
  1295.             #pragma fragment Frag
  1296.        
  1297.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  1298.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Wind.hlsl"
  1299.        
  1300.             // define FragInputs structure
  1301.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  1302.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  1303.        
  1304.             //-------------------------------------------------------------------------------------
  1305.             // Defines
  1306.             //-------------------------------------------------------------------------------------
  1307.                     #define SHADERPASS SHADERPASS_VELOCITY
  1308.                 #pragma multi_compile _ WRITE_MSAA_DEPTH
  1309.        
  1310.             // this translates the new dependency tracker into the old preprocessor definitions for the existing HDRP shader code
  1311.             #define ATTRIBUTES_NEED_TEXCOORD0
  1312.             #define VARYINGS_NEED_POSITION_WS
  1313.             #define VARYINGS_NEED_TEXCOORD0
  1314.        
  1315.             //-------------------------------------------------------------------------------------
  1316.             // End Defines
  1317.             //-------------------------------------------------------------------------------------
  1318.        
  1319.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
  1320.         #ifdef DEBUG_DISPLAY
  1321.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
  1322.         #endif
  1323.        
  1324.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
  1325.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
  1326.        
  1327.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
  1328.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
  1329.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1330.        
  1331.             // Used by SceneSelectionPass
  1332.             int _ObjectId;
  1333.             int _PassValue;
  1334.        
  1335.             //-------------------------------------------------------------------------------------
  1336.             // Interpolator Packing And Struct Declarations
  1337.             //-------------------------------------------------------------------------------------
  1338.         // Generated Type: AttributesMesh
  1339.         struct AttributesMesh {
  1340.             float3 positionOS : POSITION;
  1341.             float4 uv0 : TEXCOORD0; // optional
  1342.             #if UNITY_ANY_INSTANCING_ENABLED
  1343.             uint instanceID : INSTANCEID_SEMANTIC;
  1344.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1345.         };
  1346.        
  1347.         // Generated Type: VaryingsMeshToPS
  1348.         struct VaryingsMeshToPS {
  1349.             float4 positionCS : SV_Position;
  1350.             float3 positionRWS; // optional
  1351.             float4 texCoord0; // optional
  1352.             #if UNITY_ANY_INSTANCING_ENABLED
  1353.             uint instanceID : INSTANCEID_SEMANTIC;
  1354.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1355.         };
  1356.         struct PackedVaryingsMeshToPS {
  1357.             float3 interp00 : TEXCOORD0; // auto-packed
  1358.             float4 interp01 : TEXCOORD1; // auto-packed
  1359.             float4 positionCS : SV_Position; // unpacked
  1360.             #if UNITY_ANY_INSTANCING_ENABLED
  1361.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  1362.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1363.         };
  1364.         PackedVaryingsMeshToPS PackVaryingsMeshToPS(VaryingsMeshToPS input)
  1365.         {
  1366.             PackedVaryingsMeshToPS output;
  1367.             output.positionCS = input.positionCS;
  1368.             output.interp00.xyz = input.positionRWS;
  1369.             output.interp01.xyzw = input.texCoord0;
  1370.             #if UNITY_ANY_INSTANCING_ENABLED
  1371.             output.instanceID = input.instanceID;
  1372.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1373.             return output;
  1374.         }
  1375.         VaryingsMeshToPS UnpackVaryingsMeshToPS(PackedVaryingsMeshToPS input)
  1376.         {
  1377.             VaryingsMeshToPS output;
  1378.             output.positionCS = input.positionCS;
  1379.             output.positionRWS = input.interp00.xyz;
  1380.             output.texCoord0 = input.interp01.xyzw;
  1381.             #if UNITY_ANY_INSTANCING_ENABLED
  1382.             output.instanceID = input.instanceID;
  1383.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1384.             return output;
  1385.         }
  1386.        
  1387.         // Generated Type: VaryingsMeshToDS
  1388.         struct VaryingsMeshToDS {
  1389.             float3 positionRWS;
  1390.             float3 normalWS;
  1391.             #if UNITY_ANY_INSTANCING_ENABLED
  1392.             uint instanceID : INSTANCEID_SEMANTIC;
  1393.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1394.         };
  1395.         struct PackedVaryingsMeshToDS {
  1396.             float3 interp00 : TEXCOORD0; // auto-packed
  1397.             float3 interp01 : TEXCOORD1; // auto-packed
  1398.             #if UNITY_ANY_INSTANCING_ENABLED
  1399.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  1400.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1401.         };
  1402.         PackedVaryingsMeshToDS PackVaryingsMeshToDS(VaryingsMeshToDS input)
  1403.         {
  1404.             PackedVaryingsMeshToDS output;
  1405.             output.interp00.xyz = input.positionRWS;
  1406.             output.interp01.xyz = input.normalWS;
  1407.             #if UNITY_ANY_INSTANCING_ENABLED
  1408.             output.instanceID = input.instanceID;
  1409.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1410.             return output;
  1411.         }
  1412.         VaryingsMeshToDS UnpackVaryingsMeshToDS(PackedVaryingsMeshToDS input)
  1413.         {
  1414.             VaryingsMeshToDS output;
  1415.             output.positionRWS = input.interp00.xyz;
  1416.             output.normalWS = input.interp01.xyz;
  1417.             #if UNITY_ANY_INSTANCING_ENABLED
  1418.             output.instanceID = input.instanceID;
  1419.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1420.             return output;
  1421.         }
  1422.        
  1423.             //-------------------------------------------------------------------------------------
  1424.             // End Interpolator Packing And Struct Declarations
  1425.             //-------------------------------------------------------------------------------------
  1426.        
  1427.             //-------------------------------------------------------------------------------------
  1428.             // Graph generated code
  1429.             //-------------------------------------------------------------------------------------
  1430.                     // Shared Graph Properties (uniform inputs)
  1431.                     CBUFFER_START(UnityPerMaterial)
  1432.                     CBUFFER_END
  1433.                
  1434.                     TEXTURE2D(_Texture2DAsset_63806780_Out); SAMPLER(sampler_Texture2DAsset_63806780_Out); float4 _Texture2DAsset_63806780_Out_TexelSize;
  1435.                
  1436.                 // Pixel Graph Inputs
  1437.                     struct SurfaceDescriptionInputs {
  1438.                         float4 uv0; // optional
  1439.                     };
  1440.                 // Pixel Graph Outputs
  1441.                     struct SurfaceDescription
  1442.                     {
  1443.                         float Alpha;
  1444.                         float AlphaClipThreshold;
  1445.                     };
  1446.                    
  1447.                 // Shared Graph Node Functions
  1448.                 // Pixel Graph Evaluation
  1449.                     SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
  1450.                     {
  1451.                         SurfaceDescription surface = (SurfaceDescription)0;
  1452.                         float4 _SampleTexture2D_A19560AC_RGBA = SAMPLE_TEXTURE2D(_Texture2DAsset_63806780_Out, sampler_Texture2DAsset_63806780_Out, IN.uv0.xy);
  1453.                         float _SampleTexture2D_A19560AC_R = _SampleTexture2D_A19560AC_RGBA.r;
  1454.                         float _SampleTexture2D_A19560AC_G = _SampleTexture2D_A19560AC_RGBA.g;
  1455.                         float _SampleTexture2D_A19560AC_B = _SampleTexture2D_A19560AC_RGBA.b;
  1456.                         float _SampleTexture2D_A19560AC_A = _SampleTexture2D_A19560AC_RGBA.a;
  1457.                         surface.Alpha = _SampleTexture2D_A19560AC_A;
  1458.                         surface.AlphaClipThreshold = 0.5;
  1459.                         return surface;
  1460.                     }
  1461.                    
  1462.             //-------------------------------------------------------------------------------------
  1463.             // End graph generated code
  1464.             //-------------------------------------------------------------------------------------
  1465.        
  1466.        
  1467.        
  1468.         //-------------------------------------------------------------------------------------
  1469.         // TEMPLATE INCLUDE : SharedCode.template.hlsl
  1470.         //-------------------------------------------------------------------------------------
  1471.             FragInputs BuildFragInputs(VaryingsMeshToPS input)
  1472.             {
  1473.                 FragInputs output;
  1474.                 ZERO_INITIALIZE(FragInputs, output);
  1475.        
  1476.                 // Init to some default value to make the computer quiet (else it output 'divide by zero' warning even if value is not used).
  1477.                 // TODO: this is a really poor workaround, but the variable is used in a bunch of places
  1478.                 // to compute normals which are then passed on elsewhere to compute other values...
  1479.                 output.worldToTangent = k_identity3x3;
  1480.                 output.positionSS = input.positionCS;       // input.positionCS is SV_Position
  1481.        
  1482.                 output.positionRWS = input.positionRWS;
  1483.                 output.texCoord0 = input.texCoord0;
  1484.                 #if SHADER_STAGE_FRAGMENT
  1485.                 #endif // SHADER_STAGE_FRAGMENT
  1486.        
  1487.                 return output;
  1488.             }
  1489.        
  1490.             SurfaceDescriptionInputs FragInputsToSurfaceDescriptionInputs(FragInputs input, float3 viewWS)
  1491.             {
  1492.                 SurfaceDescriptionInputs output;
  1493.                 ZERO_INITIALIZE(SurfaceDescriptionInputs, output);
  1494.        
  1495.                 output.uv0 =                         input.texCoord0;
  1496.        
  1497.                 return output;
  1498.             }
  1499.        
  1500.             // existing HDRP code uses the combined function to go directly from packed to frag inputs
  1501.             FragInputs UnpackVaryingsMeshToFragInputs(PackedVaryingsMeshToPS input)
  1502.             {
  1503.                 UNITY_SETUP_INSTANCE_ID(input);
  1504.                 VaryingsMeshToPS unpacked= UnpackVaryingsMeshToPS(input);
  1505.                 return BuildFragInputs(unpacked);
  1506.             }
  1507.        
  1508.         //-------------------------------------------------------------------------------------
  1509.         // END TEMPLATE INCLUDE : SharedCode.template.hlsl
  1510.         //-------------------------------------------------------------------------------------
  1511.        
  1512.        
  1513.        
  1514.             void BuildSurfaceData(FragInputs fragInputs, inout SurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData)
  1515.             {
  1516.                 // setup defaults -- these are used if the graph doesn't output a value
  1517.                 ZERO_INITIALIZE(SurfaceData, surfaceData);
  1518.        
  1519.                 // copy across graph values, if defined
  1520.        
  1521.         #if defined(DEBUG_DISPLAY)
  1522.                 if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
  1523.                 {
  1524.                     // TODO
  1525.                 }
  1526.         #endif
  1527.             }
  1528.        
  1529.             void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
  1530.             {
  1531.                 SurfaceDescriptionInputs surfaceDescriptionInputs = FragInputsToSurfaceDescriptionInputs(fragInputs, V);
  1532.                 SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
  1533.        
  1534.                 // Perform alpha test very early to save performance (a killed pixel will not sample textures)
  1535.                 // TODO: split graph evaluation to grab just alpha dependencies first? tricky..
  1536.                 DoAlphaTest(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold);
  1537.        
  1538.                 BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
  1539.        
  1540.                 // Builtin Data
  1541.                 ZERO_INITIALIZE(BuiltinData, builtinData); // No call to InitBuiltinData as we don't have any lighting
  1542.        
  1543.                 builtinData.opacity = surfaceDescription.Alpha;
  1544.        
  1545.        
  1546.         #if (SHADERPASS == SHADERPASS_DISTORTION)
  1547.                 builtinData.distortion = surfaceDescription.Distortion;
  1548.                 builtinData.distortionBlur = surfaceDescription.DistortionBlur;
  1549.         #else
  1550.                 builtinData.distortion = float2(0.0, 0.0);
  1551.                 builtinData.distortionBlur = 0.0;
  1552.         #endif
  1553.             }
  1554.        
  1555.             //-------------------------------------------------------------------------------------
  1556.             // Pass Includes
  1557.             //-------------------------------------------------------------------------------------
  1558.                 #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassVelocity.hlsl"
  1559.             //-------------------------------------------------------------------------------------
  1560.             // End Pass Includes
  1561.             //-------------------------------------------------------------------------------------
  1562.        
  1563.             ENDHLSL
  1564.         }
  1565.        
  1566.         Pass
  1567.         {
  1568.             // based on HDUnlitPassForward.template
  1569.             Name "ForwardOnly"
  1570.             Tags { "LightMode" = "ForwardOnly" }
  1571.        
  1572.             //-------------------------------------------------------------------------------------
  1573.             // Render Modes (Blend, Cull, ZTest, Stencil, etc)
  1574.             //-------------------------------------------------------------------------------------
  1575.             Blend One Zero
  1576.        
  1577.             Cull Back
  1578.        
  1579.             ZTest LEqual
  1580.        
  1581.             ZWrite On
  1582.        
  1583.             // Default Stencil
  1584.        
  1585.            
  1586.             //-------------------------------------------------------------------------------------
  1587.             // End Render Modes
  1588.             //-------------------------------------------------------------------------------------
  1589.        
  1590.             HLSLPROGRAM
  1591.        
  1592.             #pragma target 4.5
  1593.             #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
  1594.             //#pragma enable_d3d11_debug_symbols
  1595.        
  1596.             //enable GPU instancing support
  1597.             #pragma multi_compile_instancing
  1598.        
  1599.             //-------------------------------------------------------------------------------------
  1600.             // Variant Definitions (active field translations to HDRP defines)
  1601.             //-------------------------------------------------------------------------------------
  1602.             //-------------------------------------------------------------------------------------
  1603.             // End Variant Definitions
  1604.             //-------------------------------------------------------------------------------------
  1605.        
  1606.             #pragma vertex Vert
  1607.             #pragma fragment Frag
  1608.        
  1609.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
  1610.             #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Wind.hlsl"
  1611.        
  1612.             // define FragInputs structure
  1613.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
  1614.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
  1615.        
  1616.             //-------------------------------------------------------------------------------------
  1617.             // Defines
  1618.             //-------------------------------------------------------------------------------------
  1619.                     #define SHADERPASS SHADERPASS_FORWARD_UNLIT
  1620.                 #pragma multi_compile _ DEBUG_DISPLAY
  1621.                 #pragma multi_compile _ LIGHTMAP_ON
  1622.                 #pragma multi_compile _ DIRLIGHTMAP_COMBINED
  1623.                 #pragma multi_compile _ DYNAMICLIGHTMAP_ON
  1624.        
  1625.             // this translates the new dependency tracker into the old preprocessor definitions for the existing HDRP shader code
  1626.             #define ATTRIBUTES_NEED_TEXCOORD0
  1627.             #define VARYINGS_NEED_TEXCOORD0
  1628.        
  1629.             //-------------------------------------------------------------------------------------
  1630.             // End Defines
  1631.             //-------------------------------------------------------------------------------------
  1632.        
  1633.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
  1634.         #ifdef DEBUG_DISPLAY
  1635.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
  1636.         #endif
  1637.        
  1638.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
  1639.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"
  1640.        
  1641.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl"
  1642.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialUtilities.hlsl"
  1643.             #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderGraphFunctions.hlsl"
  1644.        
  1645.             // Used by SceneSelectionPass
  1646.             int _ObjectId;
  1647.             int _PassValue;
  1648.        
  1649.             //-------------------------------------------------------------------------------------
  1650.             // Interpolator Packing And Struct Declarations
  1651.             //-------------------------------------------------------------------------------------
  1652.         // Generated Type: AttributesMesh
  1653.         struct AttributesMesh {
  1654.             float3 positionOS : POSITION;
  1655.             float4 uv0 : TEXCOORD0; // optional
  1656.             #if UNITY_ANY_INSTANCING_ENABLED
  1657.             uint instanceID : INSTANCEID_SEMANTIC;
  1658.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1659.         };
  1660.        
  1661.         // Generated Type: VaryingsMeshToPS
  1662.         struct VaryingsMeshToPS {
  1663.             float4 positionCS : SV_Position;
  1664.             float4 texCoord0; // optional
  1665.             #if UNITY_ANY_INSTANCING_ENABLED
  1666.             uint instanceID : INSTANCEID_SEMANTIC;
  1667.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1668.         };
  1669.         struct PackedVaryingsMeshToPS {
  1670.             float4 interp00 : TEXCOORD0; // auto-packed
  1671.             float4 positionCS : SV_Position; // unpacked
  1672.             #if UNITY_ANY_INSTANCING_ENABLED
  1673.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  1674.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1675.         };
  1676.         PackedVaryingsMeshToPS PackVaryingsMeshToPS(VaryingsMeshToPS input)
  1677.         {
  1678.             PackedVaryingsMeshToPS output;
  1679.             output.positionCS = input.positionCS;
  1680.             output.interp00.xyzw = input.texCoord0;
  1681.             #if UNITY_ANY_INSTANCING_ENABLED
  1682.             output.instanceID = input.instanceID;
  1683.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1684.             return output;
  1685.         }
  1686.         VaryingsMeshToPS UnpackVaryingsMeshToPS(PackedVaryingsMeshToPS input)
  1687.         {
  1688.             VaryingsMeshToPS output;
  1689.             output.positionCS = input.positionCS;
  1690.             output.texCoord0 = input.interp00.xyzw;
  1691.             #if UNITY_ANY_INSTANCING_ENABLED
  1692.             output.instanceID = input.instanceID;
  1693.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1694.             return output;
  1695.         }
  1696.        
  1697.         // Generated Type: VaryingsMeshToDS
  1698.         struct VaryingsMeshToDS {
  1699.             float3 positionRWS;
  1700.             float3 normalWS;
  1701.             #if UNITY_ANY_INSTANCING_ENABLED
  1702.             uint instanceID : INSTANCEID_SEMANTIC;
  1703.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1704.         };
  1705.         struct PackedVaryingsMeshToDS {
  1706.             float3 interp00 : TEXCOORD0; // auto-packed
  1707.             float3 interp01 : TEXCOORD1; // auto-packed
  1708.             #if UNITY_ANY_INSTANCING_ENABLED
  1709.             uint instanceID : INSTANCEID_SEMANTIC; // unpacked
  1710.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1711.         };
  1712.         PackedVaryingsMeshToDS PackVaryingsMeshToDS(VaryingsMeshToDS input)
  1713.         {
  1714.             PackedVaryingsMeshToDS output;
  1715.             output.interp00.xyz = input.positionRWS;
  1716.             output.interp01.xyz = input.normalWS;
  1717.             #if UNITY_ANY_INSTANCING_ENABLED
  1718.             output.instanceID = input.instanceID;
  1719.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1720.             return output;
  1721.         }
  1722.         VaryingsMeshToDS UnpackVaryingsMeshToDS(PackedVaryingsMeshToDS input)
  1723.         {
  1724.             VaryingsMeshToDS output;
  1725.             output.positionRWS = input.interp00.xyz;
  1726.             output.normalWS = input.interp01.xyz;
  1727.             #if UNITY_ANY_INSTANCING_ENABLED
  1728.             output.instanceID = input.instanceID;
  1729.             #endif // UNITY_ANY_INSTANCING_ENABLED
  1730.             return output;
  1731.         }
  1732.        
  1733.             //-------------------------------------------------------------------------------------
  1734.             // End Interpolator Packing And Struct Declarations
  1735.             //-------------------------------------------------------------------------------------
  1736.        
  1737.             //-------------------------------------------------------------------------------------
  1738.             // Graph generated code
  1739.             //-------------------------------------------------------------------------------------
  1740.                     // Shared Graph Properties (uniform inputs)
  1741.                     CBUFFER_START(UnityPerMaterial)
  1742.                     CBUFFER_END
  1743.                
  1744.                     TEXTURE2D(_Texture2DAsset_63806780_Out); SAMPLER(sampler_Texture2DAsset_63806780_Out); float4 _Texture2DAsset_63806780_Out_TexelSize;
  1745.                
  1746.                 // Pixel Graph Inputs
  1747.                     struct SurfaceDescriptionInputs {
  1748.                         float4 uv0; // optional
  1749.                     };
  1750.                 // Pixel Graph Outputs
  1751.                     struct SurfaceDescription
  1752.                     {
  1753.                         float3 Color;
  1754.                         float Alpha;
  1755.                         float AlphaClipThreshold;
  1756.                     };
  1757.                    
  1758.                 // Shared Graph Node Functions
  1759.                 // Pixel Graph Evaluation
  1760.                     SurfaceDescription SurfaceDescriptionFunction(SurfaceDescriptionInputs IN)
  1761.                     {
  1762.                         SurfaceDescription surface = (SurfaceDescription)0;
  1763.                         float4 _SampleTexture2D_A19560AC_RGBA = SAMPLE_TEXTURE2D(_Texture2DAsset_63806780_Out, sampler_Texture2DAsset_63806780_Out, IN.uv0.xy);
  1764.                         float _SampleTexture2D_A19560AC_R = _SampleTexture2D_A19560AC_RGBA.r;
  1765.                         float _SampleTexture2D_A19560AC_G = _SampleTexture2D_A19560AC_RGBA.g;
  1766.                         float _SampleTexture2D_A19560AC_B = _SampleTexture2D_A19560AC_RGBA.b;
  1767.                         float _SampleTexture2D_A19560AC_A = _SampleTexture2D_A19560AC_RGBA.a;
  1768.                         surface.Color = (_SampleTexture2D_A19560AC_RGBA.xyz);
  1769.                         surface.Alpha = _SampleTexture2D_A19560AC_A;
  1770.                         surface.AlphaClipThreshold = 0.5;
  1771.                         return surface;
  1772.                     }
  1773.                    
  1774.             //-------------------------------------------------------------------------------------
  1775.             // End graph generated code
  1776.             //-------------------------------------------------------------------------------------
  1777.        
  1778.        
  1779.        
  1780.         //-------------------------------------------------------------------------------------
  1781.         // TEMPLATE INCLUDE : SharedCode.template.hlsl
  1782.         //-------------------------------------------------------------------------------------
  1783.             FragInputs BuildFragInputs(VaryingsMeshToPS input)
  1784.             {
  1785.                 FragInputs output;
  1786.                 ZERO_INITIALIZE(FragInputs, output);
  1787.        
  1788.                 // Init to some default value to make the computer quiet (else it output 'divide by zero' warning even if value is not used).
  1789.                 // TODO: this is a really poor workaround, but the variable is used in a bunch of places
  1790.                 // to compute normals which are then passed on elsewhere to compute other values...
  1791.                 output.worldToTangent = k_identity3x3;
  1792.                 output.positionSS = input.positionCS;       // input.positionCS is SV_Position
  1793.        
  1794.                 output.texCoord0 = input.texCoord0;
  1795.                 #if SHADER_STAGE_FRAGMENT
  1796.                 #endif // SHADER_STAGE_FRAGMENT
  1797.        
  1798.                 return output;
  1799.             }
  1800.        
  1801.             SurfaceDescriptionInputs FragInputsToSurfaceDescriptionInputs(FragInputs input, float3 viewWS)
  1802.             {
  1803.                 SurfaceDescriptionInputs output;
  1804.                 ZERO_INITIALIZE(SurfaceDescriptionInputs, output);
  1805.        
  1806.                 output.uv0 =                         input.texCoord0;
  1807.        
  1808.                 return output;
  1809.             }
  1810.        
  1811.             // existing HDRP code uses the combined function to go directly from packed to frag inputs
  1812.             FragInputs UnpackVaryingsMeshToFragInputs(PackedVaryingsMeshToPS input)
  1813.             {
  1814.                 UNITY_SETUP_INSTANCE_ID(input);
  1815.                 VaryingsMeshToPS unpacked= UnpackVaryingsMeshToPS(input);
  1816.                 return BuildFragInputs(unpacked);
  1817.             }
  1818.        
  1819.         //-------------------------------------------------------------------------------------
  1820.         // END TEMPLATE INCLUDE : SharedCode.template.hlsl
  1821.         //-------------------------------------------------------------------------------------
  1822.        
  1823.        
  1824.        
  1825.             void BuildSurfaceData(FragInputs fragInputs, inout SurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData)
  1826.             {
  1827.                 // setup defaults -- these are used if the graph doesn't output a value
  1828.                 ZERO_INITIALIZE(SurfaceData, surfaceData);
  1829.        
  1830.                 // copy across graph values, if defined
  1831.                 surfaceData.color = surfaceDescription.Color;
  1832.        
  1833.         #if defined(DEBUG_DISPLAY)
  1834.                 if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE)
  1835.                 {
  1836.                     // TODO
  1837.                 }
  1838.         #endif
  1839.             }
  1840.        
  1841.             void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
  1842.             {
  1843.                 SurfaceDescriptionInputs surfaceDescriptionInputs = FragInputsToSurfaceDescriptionInputs(fragInputs, V);
  1844.                 SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
  1845.        
  1846.                 // Perform alpha test very early to save performance (a killed pixel will not sample textures)
  1847.                 // TODO: split graph evaluation to grab just alpha dependencies first? tricky..
  1848.                 DoAlphaTest(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold);
  1849.        
  1850.                 BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData);
  1851.        
  1852.                 // Builtin Data
  1853.                 ZERO_INITIALIZE(BuiltinData, builtinData); // No call to InitBuiltinData as we don't have any lighting
  1854.        
  1855.                 builtinData.opacity = surfaceDescription.Alpha;
  1856.        
  1857.        
  1858.         #if (SHADERPASS == SHADERPASS_DISTORTION)
  1859.                 builtinData.distortion = surfaceDescription.Distortion;
  1860.                 builtinData.distortionBlur = surfaceDescription.DistortionBlur;
  1861.         #else
  1862.                 builtinData.distortion = float2(0.0, 0.0);
  1863.                 builtinData.distortionBlur = 0.0;
  1864.         #endif
  1865.             }
  1866.        
  1867.             //-------------------------------------------------------------------------------------
  1868.             // Pass Includes
  1869.             //-------------------------------------------------------------------------------------
  1870.                 #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl"
  1871.             //-------------------------------------------------------------------------------------
  1872.             // End Pass Includes
  1873.             //-------------------------------------------------------------------------------------
  1874.        
  1875.             ENDHLSL
  1876.         }
  1877.        
  1878.     }
  1879.     CustomEditor "UnityEditor.ShaderGraph.HDUnlitGUI"
  1880.     FallBack "Hidden/InternalErrorShader"
  1881. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement