Advertisement
-dane-

OutlinePostProcess.shader

Sep 27th, 2021 (edited)
2,088
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Pastebin needs better syntax highlighting. This is a .shader file if that isn't obvious.
  2.  
  3. // This shader is basically a placeholder that just holds properties mentioned in the other scripts.
  4. // Also I have made this shader SRP batcher compatible.
  5.  
  6. Shader "Hidden/Harryh___h/Outline_Post_Process"
  7. {
  8.     Properties
  9.     {
  10.         _HHO_OuterThreshold ("Outer Threshold", float) = 0.0
  11.         _HHO_InnerThreshold ("Inner Threshold", float) = 0.0
  12.         _HHO_OutlineSizeX ("Outline Size X", float) = 1.0
  13.         _HHO_OutlineSizeY ("Outline Size Y", float) = 1.0
  14.         _HHO_Rotations ("Rotations", int) = 6
  15.         _HHO_DepthPush ("Depth Push", float) = 0.0
  16.         _HHO_OuterLUT ("Outer LUT", 2D) = "white" {}
  17.         _HHO_InnerLUT ("Inner Lut", 2D) = "white" {}
  18.     }
  19.     SubShader
  20.     {
  21.         Tags
  22.         {
  23.             "LightMode" = "Outline"
  24.         }
  25.         Pass
  26.         {
  27.             Name "Outline"
  28.             HLSLPROGRAM
  29.             #pragma vertex vert
  30.             #pragma fragment frag
  31.             #pragma target 5.0
  32.  
  33.             #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  34.             #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  35.             #include "OutlineShared.hlsl"
  36.  
  37.  
  38.             CBUFFER_START(UnityPerMaterial)
  39.  
  40.             TEXTURE2D(_HHO_OutlineOpaqueTexture);
  41.             SAMPLER(sampler_HHO_OutlineOpaqueTexture);
  42.  
  43.             CBUFFER_END
  44.  
  45.             Varyings vert(Attributes IN)
  46.             {
  47.                 Varyings OUT;
  48.                 OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
  49.                 OUT.uv = IN.uv;
  50.                 return OUT;
  51.             }
  52.  
  53.             float4 frag(Varyings input) : SV_Target
  54.             {
  55.                 float4 col = SAMPLE_TEXTURE2D(_HHO_OutlineOpaqueTexture, sampler_HHO_OutlineOpaqueTexture, input.uv);
  56.                 return col;
  57.             }
  58.             ENDHLSL
  59.         }
  60.         Tags
  61.         {
  62.             "LightMode" = "OutlineDepth"
  63.         }
  64.         Pass
  65.         {
  66.             Name "OutlineDepth"
  67.             HLSLPROGRAM
  68.             #pragma vertex vert
  69.             #pragma fragment frag
  70.             #pragma target 5.0
  71.  
  72.             #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  73.             #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  74.             #include "OutlineShared.hlsl"
  75.  
  76.             CBUFFER_START(UnityPerMaterial)
  77.  
  78.             TEXTURE2D(_HHO_OutlineDepthTexture);
  79.             SAMPLER(sampler_HHO_OutlineDepthTexture);
  80.  
  81.             CBUFFER_END
  82.  
  83.             Varyings vert(Attributes IN)
  84.             {
  85.                 Varyings OUT;
  86.                 OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
  87.                 OUT.uv = IN.uv;
  88.                 return OUT;
  89.             }
  90.  
  91.             float4 frag(Varyings input) : SV_Target
  92.             {
  93.                 float4 col = SAMPLE_DEPTH_TEXTURE(_HHO_OutlineDepthTexture, sampler_HHO_OutlineDepthTexture, input.uv);
  94.                 return col;
  95.             }
  96.             ENDHLSL
  97.         }
  98.         Tags
  99.         {
  100.             "LightMode" = "OutlineDirect"
  101.         }
  102.         Pass
  103.         {
  104.             Name "OutlineDirect"
  105.             HLSLPROGRAM
  106.             #pragma vertex vert
  107.             #pragma fragment frag
  108.             #pragma target 5.0
  109.  
  110.             #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  111.             #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
  112.             #include "OutlineShared.hlsl"
  113.  
  114.             CBUFFER_START(UnityPerMaterial)
  115.             TEXTURE2D(_HHO_Pass);
  116.             SAMPLER(sampler_HHO_Pass);
  117.             CBUFFER_END
  118.  
  119.             Varyings vert(Attributes IN)
  120.             {
  121.                 Varyings OUT;
  122.                 OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
  123.                 OUT.uv = IN.uv;
  124.                 return OUT;
  125.             }
  126.  
  127.             float4 frag(Varyings input) : SV_Target
  128.             {
  129.                 float4 col = SAMPLE_TEXTURE2D(_HHO_Pass, sampler_HHO_Pass, input.uv);
  130.                 return col;
  131.             }
  132.             ENDHLSL
  133.         }
  134.     }
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement