Texture2.hx 826 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package h3d.shader;
  2. /**
  3. This is similar to [Texture] shader but uses a second UV set.
  4. **/
  5. class Texture2 extends hxsl.Shader {
  6. static var SRC = {
  7. @input var input : {
  8. var uv2 : Vec2;
  9. };
  10. @const var additive : Bool;
  11. @const var killAlpha : Bool;
  12. @param var killAlphaThreshold : Float;
  13. @param var texture : Sampler2D;
  14. var calculatedUV2 : Vec2;
  15. var pixelColor : Vec4;
  16. function vertex() {
  17. calculatedUV2 = input.uv2;
  18. }
  19. function fragment() {
  20. var c = texture.get(calculatedUV2);
  21. if( killAlpha && c.a - killAlphaThreshold < 0 ) discard;
  22. if( additive )
  23. pixelColor += c;
  24. else
  25. pixelColor *= c;
  26. }
  27. }
  28. public function new(?tex) {
  29. super();
  30. this.texture = tex;
  31. this.killAlphaThreshold = h3d.mat.Defaults.defaultKillAlphaThreshold;
  32. }
  33. }