There is an issue with preprocessor statements in the GLSL code.
If you come across this, here are some hints to rewrite the code:
Suppose this is the code you find online:
varying vec2 vTexCoord;
uniform sampler2D uImage0;
uniform float uTime;
void main() {
vec2 texCoord = vTexCoord;
vec2 iResolution = vec2(320.0, 240.0);
float main_a=1.0;
float main_b=2.0;
float main_c=3.0;
#define afunc( R, G, B) {
const vec3 tst = vec3(R, G, B);
main_a = R*G*B;
main_b = R/G/B;
main_c = (R*G)*B;
}
afunc(23./255.,171./255., 116./255.);
afunc(44./255.,230./255., 126./255.);
afunc(213./255.,140./255., 216./255.);
afunc(35./255.,46./255., 161./255.);
afunc(26./255.,41./255., 165./255.);
#undef afunc
gl_FragColor = vec4(vec3(main_a,main_b,main_c), 1.0);
}
It will generate errors like these : invalid character: #define
* remove all the comments
* varying vec2 vTextCoord changing to : varying vec2 openfl_TextureCoordv;
* uniform sampler2D uImage0; becomes : uniform sampler2D openfl_Texture;
* vec2 texCoord = vTexCoord; becomes : vec2 texCoord = openfl_TextureCoordv;
Do not inline the function in the main method.
So use public variables for the members that are changed inside the function.
Ported code:
varying vec2 openfl_TextureCoordv;
uniform sampler2D openfl_Texture;
float main_a = 0.1;
float main_b = 0.1;
float main_c = 0.1;
void afunc(float R, float G, float B){
vec3 tst = vec3(R, G, B);
main_a = R*G*B;
main_b = R/G/B;
main_c = (R*G)*B;
}
void main() {
vec2 texCoord = openfl_TextureCoordv;
vec2 iResolution = vec2(320.0, 240.0);
afunc(23./255.,171./255., 116./255.);
afunc(44./255.,230./255., 126./255.);
afunc(213./255.,140./255., 216./255.);
afunc(35./255.,46./255., 161./255.);
afunc(26./255.,41./255., 165./255.);
gl_FragColor = vec4(vec3(main_a,main_b,main_c), 1.0);
}
(Example gives bright green image: just for demonstration purposes)