This looks awesome! But I cannot compile it. I tried on Windows and Mac. I get this error on the mat.bind() function:
The sketch has been automatically resized to fit the screen resolution
Cannot validate shader program:Validation Error: Samplers of different types point to the same texture unitValidation Error: Samplers of different types point to the same texture unit
You could make your own loadShader that adds a definition depending on your os:
public PShader loadShader(String vertsrc, String fragsrc) {
String os = System.getProperty("os.name");
// Load shader files
String vert = join(loadStrings(vertsrc), "\n");
String frag = join(loadStrings(fragsrc), "\n");
// Windows
if(os.contains("Windows")) {
vert = "#define WINDOWS\n" + vert;
frag = "#define WINDOWS\n" + frag;
}
// Mac OS
else if(os.contains("Mac")) {
vert = "#define MAC\n" + vert;
frag = "#define MAC\n" + frag;
}
// Linux
else if(os.contains("Linux")) {
vert = "#define LINUX\n" + vert;
frag = "#define LINUX\n" + frag;
}
// Other...
else {
vert = "#define UNKNOWNOS\n" + vert;
frag = "#define UNKNOWNOS\n" + frag;
}
// Build shader from strings
return new PShader(this, vert.split("\n"), frag.split("\n"));
}
And then use #ifdef OSNAME
with #endif
in your shader to mask blocks of code depending on the user os, for exemple:
#ifdef WINDOWS
vec4 coolcolor = texture2D(texture, uv);
#endif
#ifdef MAC
vec4 coolcolor = texture(texture, uv);
#endif