I have created a library for Physically based rendering (PBR) in Processing. PBR is a rendering method for more accurate (and nicer) lighting of surfaces, here’s a demo video.
At the moment it has been tested on Windows and Linux with nVidia graphics. The shader fails to compile on Intel integrated graphics and osX, as I don’t usually work with any of them I don’t plan to look into it in the near future. If you find the solution, please tell me
It should run on Mac by changing whatever functions or operations the shader compiler is not liking, but unfortunately the error message is not very clear.
Thanks, great to know it works on Linux. I tried Linux with Intel integrated graphics with no luck, I guess Intel and Apple drivers are more strict than nVidia’s.
Thanks for the pull request, will look later into them! Keep them coming I have some changes in mind to simplify the library, will try to update it this week and add normal maps support.
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
Thanks! Nice tip for adding preprocessing definitions, I will be using it . Unfortunately, this is related to the graphics driver, rather than the OS, and I don’t know what takes for an Intel o Apple driver to compile the shader, neither have the time or easy acces to any of them to try.
If anyone finds why it fails to compile, I would be happy to change it…
Updated so it now it runs on all desktop platforms!
On osx and integrated graphics cards there is an known issue with samplerCube, in these cases I moved to a equirectangular texture for the environment map instead of a cubemap.