Universal2D.hlsl 908 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef UNIVERSAL_FALLBACK_2D_INCLUDED
  2. #define UNIVERSAL_FALLBACK_2D_INCLUDED
  3. struct Attributes
  4. {
  5. float4 positionOS : POSITION;
  6. float2 uv : TEXCOORD0;
  7. };
  8. struct Varyings
  9. {
  10. float2 uv : TEXCOORD0;
  11. float4 vertex : SV_POSITION;
  12. };
  13. Varyings vert(Attributes input)
  14. {
  15. Varyings output = (Varyings)0;
  16. VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
  17. output.vertex = vertexInput.positionCS;
  18. output.uv = TRANSFORM_TEX(input.uv, _BaseMap);
  19. return output;
  20. }
  21. half4 frag(Varyings input) : SV_Target
  22. {
  23. half2 uv = input.uv;
  24. half4 texColor = SAMPLE_TEXTURE2D(_BaseMap, sampler_BaseMap, uv);
  25. half3 color = texColor.rgb * _BaseColor.rgb;
  26. half alpha = texColor.a * _BaseColor.a;
  27. AlphaDiscard(alpha, _Cutoff);
  28. #ifdef _ALPHAPREMULTIPLY_ON
  29. color *= alpha;
  30. #endif
  31. return half4(color, alpha);
  32. }
  33. #endif