Polygon Color Shader

This was a school project for a Graphics and Shaders class. The idea was to recreate the stylized low-poly look of things like Polyworld, but without the use of textures- just vertex color data. I’m sure this effect could be entirely with a single shader, but at the time I had fall back on a script to slice up the geometry first.

You can see here the highly technical diagram I made to describe the idea: provide two colors, and each polygon has a random color that is somewhere between the two. I broke this challenge into three parts: Shading per- polygon, lerping colors, and implementing randomness.

Lerping ended up being the easy part, since Nvidia provides color lerp functions in the CG library. For pseudo-randomness I learned about Linear Congruential Generators. The hard part was the polygon situation. I wasn’t able to figure out assigning a randomly chosen color to a specific polygon in a normal mesh, so I decided to break up the geometry in the Editor. This made sure each triangle had its own dedicated three vertices. Each vertex of a triangle was given the same randomly chosen vertex color value. This meant that I could now make a shader that reads in the color data of each triangle by its vertex data, and use it as a seed value for the final color.

I technically met all my goals, but the geometry splitting part meant it couldn’t be all condensed into just a shader, so I settled for one hefty editor script and one small surface shader. You can check out a demo here that lets you play with materials in a scene using the shader. All the models are from Low Poly Forest Set after running them through the geometry slicer script. You can also check out the Github project.