hey there,
I’ve found several references across the web to a feature of ShaderFilter that automatically sends the displayobject’s texture to the shader, such as from here: Tip: Custom Mask workaround
there is also a mention of the specific details of this feature here:
i’ve spent the day trying to reproduce this behavior, and I can’t seem to get it to work. setting the shader input manually with shader.data.uImage0.input = bitmapData;
works fine, but the implicit conversion does not.
here’s the code i’m testing with, for reference:
var shader = new Shader();
shader.glFragmentSource =
"uniform sampler2D uImage0;
varying vec2 vTexCoord;
void main(void) {
vec4 color = texture2D (uImage0, vTexCoord);
float alpha = color.a;
if (color.a <= 0.5) {
gl_FragColor = vec4 (0.0, 1.0, 0.0, 1.0);
} else {
gl_FragColor = vec4 (1.0, 0.0, 0.0, 1.0);
}
}";
shader.glVertexSource = "attribute vec4 openfl_Position; attribute vec2 openfl_TextureCoord; varying vec2 vTexCoord; uniform mat4 openfl_Matrix; uniform vec2 openfl_TextureSize;void main(void){vTexCoord = openfl_TextureCoord; gl_Position = openfl_Matrix * openfl_Position;}";
var sg = shape.graphics;
sg.lineStyle(1, 0xFFFFFF, 1, true);
sg.moveTo(20,20);
sg.cubicCurveTo(50,25, 20,60, 40,80);
shape.filters = [ new ShaderFilter(shader) ];
im using openfl version 8.9.5
has this feature been changed/removed?
additionally, is drawing the shape onto a bitmap and assigning that to the shader input computationally identical to how this should work? if so then i’m fine settling for that, i wasn’t sure if there was something openfl did under the hood that optimized it better.
(the motivation behind this is to be able to draw graphics without the antialiasing, and i figure a shader would be the best solution. but that might be better left for another topic)
thank you!