UV Mapping
On Friday night, I decided to finally learn to UV map. The reason for this is because the way I was applying materials to the cubes was getting way too tedious.
Here are the cubes I’m talking about:

Some faces have squares, some have triangles, there are different colors.
The way I was doing this up until now was I had a different material for each color, and for each symbol. And the symbols were each on individual textures of different colors. With each cube having multiple states. It was something like 60 textures and materials altogether.
Also, because I wanted to start having different combinations of colors on the cube (because of a later mechanic), I would have had to have 300 textures and materials if I continued this method.

It was stupid and unfeasible, and a pain to make changes every time.
I finally decided I had been putting off learning to UV map for way too long, and it was time to sit down and just do it.
I downloaded the Blender, and eventually found this tutorial which showed me exactly what I needed – UV unwrap a box in blender and bring it into Unity.
Once I got the cube UV unwrapped, it was pretty straightforward.
I wrote a shader that takes the base template texture (which now has both the triangle and squares on it in one), and using the alpha channel, I was able to separate out different areas and color them individually:

I am using two textures for this. I could have also done it with a single texture using the RGB channels, but the edges between the colors weren’t as sharp.
Fade-In Fade-Out
Also decided it was time to rewrite the way I was changing the floor colors.
Previously, I had six materials, each with a different normal highlighted with a different color. Every time player changed gravity, I would iterate through every single environment object in the scene and change its material.
I realized I could instead have one material and just change the highlight color and normal instead. When I thought of this, I realized I could also fade in the new color and fade out the old color.
Of course, I wrote a shader for this.
Here was the first go:

Just a simple test to get colors to fade in and out between different surface normals on an object.
Another test with more colors and to make sure changing the material affected all the objects that have that material applied (Renderer.sharedMaterial):
Then apply the effect to the environment, check it out in action:

or comparison, this is what the old effect looks like:

The fade in fade out effect improves the look greatly! It feels much better to transition gravity, and every visual change feels very magical!
2 Comments
Did you handle the fade-in/out timing completely from within the shader somehow, or did you pass in some lerp timing parameter to the material/shader from Unity on every frame?
I’m just starting to work with shaders in Unity and have a relatively similar thing I need to do (fade in then out, once, but keeping the same colour…amongst other things) but I’m finding the “stateless” nature of shader programming (particularly timing and not knowing the original/target “value” of something) a bit unnatural to get used to. So I’m curious as to what approach you took.
Hey, it’s not done with the shader, but instead in the C# script, which does the lerp timing and passes on the color values to the shader. Don’t think it’s possible to get sense of “time” in shader.