# Physically based rendering library for Processing SimplePBR

**URL:** <https://discourse.processing.org/t/physically-based-rendering-library-for-processing-simplepbr/8152>\
**Category:** Gallery\
**Created:** [February 6, 2019, 12:09pm UTC](https://discourse.processing.org/t/physically-based-rendering-library-for-processing-simplepbr/8152 "2019-02-06T12:09:15Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Stephcraft](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/stephcraft/32/22024_2.png) [@Stephcraft](https://discourse.processing.org/u/Stephcraft)\
**Post date:** [February 17, 2019, 8:32pm UTC](https://discourse.processing.org/t/physically-based-rendering-library-for-processing-simplepbr/8152/6 "2019-02-17T20:32:03Z")

</div>

This looks awesome! But I cannot compile it. I tried on Windows and Mac. I get this error on the mat.bind() function:

```nohighlight
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:

```auto
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:

```auto
#ifdef WINDOWS
	vec4 coolcolor = texture2D(texture, uv);
#endif

#ifdef MAC
	vec4 coolcolor = texture(texture, uv);
#endif

```

---

_[View the full topic](https://discourse.processing.org/t/physically-based-rendering-library-for-processing-simplepbr/8152)._
