SpriteLitPass.hlsl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #if ETC1_EXTERNAL_ALPHA
  2. TEXTURE2D(_AlphaTex); SAMPLER(sampler_AlphaTex);
  3. float _EnableAlphaTexture;
  4. #endif
  5. #if USE_SHAPE_LIGHT_TYPE_0
  6. SHAPE_LIGHT(0)
  7. #endif
  8. #if USE_SHAPE_LIGHT_TYPE_1
  9. SHAPE_LIGHT(1)
  10. #endif
  11. #if USE_SHAPE_LIGHT_TYPE_2
  12. SHAPE_LIGHT(2)
  13. #endif
  14. #if USE_SHAPE_LIGHT_TYPE_3
  15. SHAPE_LIGHT(3)
  16. #endif
  17. #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/CombinedShapeLightShared.hlsl"
  18. PackedVaryings vert(Attributes input)
  19. {
  20. Varyings output = (Varyings)0;
  21. output = BuildVaryings(input);
  22. PackedVaryings packedOutput = PackVaryings(output);
  23. return packedOutput;
  24. }
  25. half4 frag(PackedVaryings packedInput) : SV_TARGET
  26. {
  27. Varyings unpacked = UnpackVaryings(packedInput);
  28. UNITY_SETUP_INSTANCE_ID(unpacked);
  29. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
  30. SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
  31. SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
  32. #if ETC1_EXTERNAL_ALPHA
  33. float4 alpha = SAMPLE_TEXTURE2D(_AlphaTex, sampler_AlphaTex, unpacked.texCoord0.xy);
  34. surfaceDescription.Color.a = lerp (surfaceDescription.Color.a, alpha.r, _EnableAlphaTexture);
  35. #endif
  36. surfaceDescription.Color *= unpacked.color;
  37. return CombinedShapeLightShared(surfaceDescription.Color, surfaceDescription.Mask, unpacked.screenPosition.xy / unpacked.screenPosition.w);
  38. }