AlphaMap.hx 764 B

1234567891011121314151617181920212223242526272829303132
  1. package h3d.shader;
  2. class AlphaMap extends hxsl.Shader {
  3. static var SRC = {
  4. var calculatedUV : Vec2;
  5. var pixelColor : Vec4;
  6. @input var input : { uv : Vec2 };
  7. @param var texture : Sampler2D;
  8. @param var uvScale : Vec2;
  9. @param var uvDelta : Vec2;
  10. @const var useAlphaChannel : Bool;
  11. @const @param var useSourceUVs : Bool = false;
  12. function fragment() {
  13. var uv = useSourceUVs ? input.uv : calculatedUV;
  14. uv = uv * uvScale + uvDelta;
  15. if( useAlphaChannel )
  16. pixelColor.a *= texture.get(uv).a;
  17. else
  18. pixelColor.a *= texture.get(uv).b;
  19. }
  20. }
  21. public function new(texture, useAlphaChannel=false) {
  22. super();
  23. uvScale.set(1, 1);
  24. this.useAlphaChannel = useAlphaChannel;
  25. this.texture = texture;
  26. }
  27. }