Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SpriteMaskShared.hlsl 895B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #if !defined(SPRITE_MASK_SHARED)
  2. #define SPRITE_MASK_SHARED
  3. // alpha below which a mask should discard a pixel, thereby preventing the stencil buffer from being marked with the Mask's presence
  4. half _Cutoff;
  5. TEXTURE2D(_MainTex);
  6. SAMPLER(sampler_MainTex);
  7. struct Attributes
  8. {
  9. float4 positionOS : POSITION;
  10. half2 texcoord : TEXCOORD0;
  11. };
  12. struct Varyings
  13. {
  14. float4 positionCS : SV_POSITION;
  15. half2 uv : TEXCOORD0;
  16. };
  17. Varyings MaskRenderingVertex(Attributes input)
  18. {
  19. Varyings output;
  20. output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
  21. output.uv = input.texcoord;
  22. return output;
  23. }
  24. half4 MaskRenderingFragment(Varyings input) : SV_Target
  25. {
  26. half4 c = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv);
  27. // for masks: discard pixel if alpha falls below MaskingCutoff
  28. clip(c.a - _Cutoff);
  29. return half4(1, 1, 1, 0.2);
  30. }
  31. #endif