texture.swsl 941 B

1234567891011121314151617181920212223
  1. //Draws the given texture at the given screen coords. Useful in specific scenarios (i.e. this was made for drawing singularity sprites over the lensing effect but below FOV)
  2. //Currently does not work with AtlasTextures, going to need some work.
  3. uniform sampler2D tex;
  4. uniform highp vec2 positionInput;
  5. uniform highp vec2 pixelSize;
  6. uniform highp float alphaCutoff;
  7. uniform bool removeTransparency;
  8. void fragment() {
  9. highp float pixelLength = pixelSize.x*2.0;
  10. highp float halvedLength = pixelLength/2.0;
  11. if(FRAGCOORD.x > positionInput.x - halvedLength && FRAGCOORD.x < positionInput.x + halvedLength && FRAGCOORD.y > positionInput.y - halvedLength && FRAGCOORD.y < positionInput.y + halvedLength){
  12. highp vec2 finalCoords = (FRAGCOORD.xy-positionInput+(pixelLength/2.0))/pixelLength;
  13. highp vec4 color = texture2D(tex, finalCoords);
  14. if(color.a > alphaCutoff){
  15. if(removeTransparency)
  16. color.a = 1.0;
  17. COLOR = color;
  18. }
  19. }
  20. }