-
-
Notifications
You must be signed in to change notification settings - Fork 473
Open
Description
Take an example shader error log:
Uncaught exception: [openfl.display.Shader] ERROR: Error compiling fragment shader
ERROR: 0:58: '>' does not operate on 'float' and 'int'
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#endif
// <large section removed for brevity>
uniform bool _enabled;
uniform float inSize;
uniform float outSize;
uniform vec4 inColor;
uniform vec4 outColor;
bool outline(vec2 coord, float size)
{
float w = size / openfl_TextureSize.x;
float h = size / openfl_TextureSize.y;
return size > 0
&& ( flixel_texture2D(bitmap, vec2(coord.x + w, coord.y)).a != 0.0
|| flixel_texture2D(bitmap, vec2(coord.x - w, coord.y)).a != 0.0
|| flixel_texture2D(bitmap, vec2(coord.x, coord.y + h)).a != 0.0
|| flixel_texture2D(bitmap, vec2(coord.x, coord.y - h)).a != 0.0
);
}
void main()
{
vec4 color = flixel_texture2D(bitmap, openfl_TextureCoordv);
if (color.a == 0.0 && _enabled)
{
if (outline(openfl_TextureCoordv, inSize))
color = inColor;
else if (outline(openfl_TextureCoordv, outSize))
color = outColor;
}
gl_FragColor = color;
}
My goal is to reduce this to:
Uncaught exception: [openfl.display.Shader] ERROR: Error compiling fragment shader: MyShader
LINE: return size > 0
ERROR: 0:58: '>' does not operate on 'float' and 'int'