CTI URP Billboard DepthOnly Pass.hlsl 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Structs
  2. struct Attributes {
  3. float4 positionOS : POSITION;
  4. float3 normalOS : NORMAL;
  5. float4 tangentOS : TANGENT;
  6. float2 texcoord : TEXCOORD0;
  7. float3 texcoord1 : TEXCOORD1;
  8. UNITY_VERTEX_INPUT_INSTANCE_ID
  9. };
  10. struct Varyings
  11. {
  12. float2 uv : TEXCOORD0;
  13. float4 positionCS : SV_POSITION;
  14. //UNITY_VERTEX_INPUT_INSTANCE_ID
  15. UNITY_VERTEX_OUTPUT_STEREO
  16. };
  17. //--------------------------------------
  18. // Vertex shader
  19. #include "Includes/CTI URP Billboard.hlsl"
  20. Varyings DepthOnlyVertex(Attributes input)
  21. {
  22. Varyings output = (Varyings)0;
  23. UNITY_SETUP_INSTANCE_ID(input);
  24. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  25. half4 color;
  26. CTIBillboardVert(input, 0, color);
  27. output.uv = input.texcoord;
  28. VertexPositionInputs vertexPosition = GetVertexPositionInputs(input.positionOS.xyz);
  29. output.positionCS = vertexPosition.positionCS;
  30. return output;
  31. }
  32. //--------------------------------------
  33. // Fragment shader
  34. half4 DepthOnlyFragment(Varyings input) : SV_Target
  35. {
  36. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  37. #if defined(LOD_FADE_CROSSFADE) && !defined(SHADER_API_GLES)
  38. LODDitheringTransition(input.positionCS.xyz, unity_LODFade.x);
  39. #endif
  40. half alpha = SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap)).a;
  41. clip(alpha - _Cutoff);
  42. return 0;
  43. }