SpriteForwardPass.hlsl 1023 B

12345678910111213141516171819202122232425262728293031
  1. #if ETC1_EXTERNAL_ALPHA
  2. TEXTURE2D(_AlphaTex); SAMPLER(sampler_AlphaTex);
  3. float _EnableAlphaTexture;
  4. #endif
  5. PackedVaryings vert(Attributes input)
  6. {
  7. Varyings output = (Varyings)0;
  8. output = BuildVaryings(input);
  9. PackedVaryings packedOutput = PackVaryings(output);
  10. return packedOutput;
  11. }
  12. half4 frag(PackedVaryings packedInput) : SV_TARGET
  13. {
  14. Varyings unpacked = UnpackVaryings(packedInput);
  15. UNITY_SETUP_INSTANCE_ID(unpacked);
  16. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
  17. SurfaceDescriptionInputs surfaceDescriptionInputs = BuildSurfaceDescriptionInputs(unpacked);
  18. SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs);
  19. #if ETC1_EXTERNAL_ALPHA
  20. float4 alpha = SAMPLE_TEXTURE2D(_AlphaTex, sampler_AlphaTex, unpacked.texCoord0.xy);
  21. surfaceDescription.Color.a = lerp (surfaceDescription.Color.a, alpha.r, _EnableAlphaTexture);
  22. #endif
  23. surfaceDescription.Color *= unpacked.color;
  24. return surfaceDescription.Color;
  25. }