Working with shaders - welcome to hell :')



After two long evenings of hard work we finally made it! We got the 2-way vertex color blend shader to work (simple lerp + height based) and actually look acceptable. Here's some background info:

For our projects, we need an awesome level design workflow (which Unity sadly doesn't offer by default). And what is more important than the placement of meshes in the map? The look of them!

Most engines have it, Unreal Engine has it, CryEngine has it... hell! Even Source Engine had its own way of painting vertex colors onto displacements and blending two materials together. That's why we decided to implement this feature into our Unity development environment.

Working with shaders is, at least for me personally, painful as f***. It's just super tedious. Especially with Unity where you have to write them kinda manually. But the cool thing is, you have a much higher satisfaction/time ratio, and you see the actual effects of your programming so much faster. While I prefer working with C# or C++, I do have to admit that working with shaders turned out to be rewarding (and useful!) nonetheless. The learning curve is a bit bumpy and badly documented, but once you know how stuff works out you can get usable results up and running pretty fast.

For this specific shader, we used the heightmap to blend two materials together based on the painted red vertex color. If you want to know more about shaders and how to write them, check out the official nvidia CG tutorial and Unity's documentation.

Stay tuned for more updates and have a great time everybody!


Perhaps we need a custom inspector for that material for a more simplified and pleasant setup (like some sort of a wizard utility that goes through each material channel step by step).

Currently, only the 2-way blends are functional and we're using TOZ to paint the vertex colors, but 3-way blend shaders are coming, as well as a custom vert color painting utility.

 Back  Like (30)