Fix shader problems on GLES2

This commit is contained in:
Pieter-Jan Briers
2021-03-11 19:04:21 +01:00
parent 063d1c71b3
commit e539092b4b
5 changed files with 36 additions and 27 deletions

View File

@@ -3,21 +3,21 @@
//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;
uniform highp vec2 positionInput;
uniform highp vec2 pixelSize;
uniform highp float alphaCutoff;
uniform bool removeTransparency;
void fragment() {
float pixelLength = pixelSize.x*2;
float halvedLength = pixelLength/2;
highp float pixelLength = pixelSize.x*2.0;
highp float halvedLength = pixelLength/2.0;
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);
highp vec2 finalCoords = (FRAGCOORD.xy-positionInput+(pixelLength/2.0))/pixelLength;
highp vec4 color = texture2D(tex, finalCoords);
if(color.a > alphaCutoff){
if(removeTransparency)
color.a = 1.0;
COLOR = color;
}
}
}
}