Physically based rendering library for Processing SimplePBR

#1

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.

There is more information on my website and the source is hosted at this Github repo.

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 :slight_smile:

Would love knowing if you find it useful.

7 Likes

How to make crystal like shapes with Processing?
#2

Can’t test it on my old Mac desktop but this looks awesome ! Thank you for sharing this as a library.

0 Likes

#3

You’re welcome!

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.

0 Likes

#4

Thank you! Very nice! And it works fine on Linux with nVidia :slight_smile:

0 Likes

#5

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 :wink: I have some changes in mind to simplify the library, will try to update it this week and add normal maps support.

0 Likes

#6

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
0 Likes

#7

Thanks! Nice tip for adding preprocessing definitions, I will be using it :raised_hands:. 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…

0 Likes