In this tutorial, we will use the versatile utility shader to generate random colors for the sprinkles on a donut. We will then use a variety of color shaders to further adjust the colors of the sprinkles.
Start off by creating a standard_surface shader and rename the shader 'Sprinkles'. Assign it to the sprinkles geometry.
Utility Shader - Color Mode
Create a utility shader and connect it to the base_color parameter of a standard_surface shader. We will use the object_mode of the utility shader to add random colors to the sprinkles. This mode uses the name of the shapes to compute the color.
We don't want any shading from the utility shader as we are already using the standard_surface, so change the shade_mode to flat. Flat renders the model as a pure, solid, flatly lit and shaded color.
Utility Map connected to standard_surface.base_color
Random - Seed
We can use the random shader to create variations of color for our sprinkles.
Create a random shader and connect it to the base_color of the standard_surface shader. Connect the utility shader to the input_color of the random shader.
Change the seed parameter number. You should notice that the color of the sprinkles randomly changes.
Random's seed parameter animated (utility shader set to object mode)
Composite
We can also use the composite shader to mix in another color using a blend mode.
Delete the random shader and create a composite shader. Connect it to the diffuse_color parameter of the standard_surface shader. Connect the utility shader to Input A of the composite shader.
Change the operation parameter of the composite shader to multiply and change the Input B color to orange. You should see that the colors of the sprinkles now have an orange tint to them.
Color of sprinkles tinted with an orange color using the multiply operation of the composite shader
Change B color to orange and Operation to 'multiply'
Color Convert
Another way to change the colors of the sprinkles is to use a color_convert shader.
Delete the composite shader and create a color_convert shader. Connect it to the diffuse_color parameter of the standard_surface shader. Connect the utility shader to the input parameter of the composite shader.
Try changing the color space to see the effect it has on the color of the sprinkles. In this case, it was changed to xyY.
Color space converted to xyY
Color Correct
Once you are happy with the general colors of the sprinkles, you can use a color_correct shader to further fine-tune their appearance.
Create a color_correct shader and connect it to the diffuse_color parameter of the standard_surface shader. Connect the utility shader to the input parameter of the color_correct shader. You can adjust the exposure and multiply parameters, for example, to add more variation to the color values.
Fine-tune the colors using a color_correct shader
That concludes this tutorial. Have a go at experimenting with some of the other color correct shaders to create some different variations of color.