Delta-v/Resources/Textures/Shaders/texture.swsl

23 lines
950 B
Plaintext

//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)
//Currently does not work with AtlasTextures, going to need some work.
uniform sampler2D tex;
uniform highp vec2 positionInput = vec2(0,0);
uniform highp vec2 pixelSize = vec2(32, 32);
uniform highp float alphaCutoff = 0.0;
uniform bool removeTransparency = false;
void fragment() {
float pixelLength = pixelSize.x*2;
float halvedLength = pixelLength/2;
if(FRAGCOORD.x > positionInput.x - halvedLength && FRAGCOORD.x < positionInput.x + halvedLength && FRAGCOORD.y > positionInput.y - halvedLength && FRAGCOORD.y < positionInput.y + halvedLength){
vec2 finalCoords = (FRAGCOORD.xy-positionInput+(pixelLength/2))/pixelLength;
vec4 color = texture(tex, finalCoords);
if(color.a > alphaCutoff){
if(removeTransparency)
color.a = 1.0;
COLOR = color;
}
}
}