I'm using the Blender Cycles engine to create graphics for a game; specifically, I want to display a grid of coloured ellipsoid counters for the player to move around. To avoid creating a separate image for each colour, I want to store a single greyscale image in the resources, and apply a colour tint at runtime:
However, with this approach, the specular highlights would also be tinted; so I would like to store the highlights as a separate image with an alpha channel, and overlay it on top of the tinted image.
I've tried Googling for ways to do this in Blender, and cannot find anything. The best solution I can think of is to set the glossy BSDF colour to red (1.0, 0.0, 0.0) and the diffuse BSDF colour to green (0.0, 1.0, 0.0):
I would then need to create a mask from the red channel, and create base and overlay greyscale images from the green and red channels respectively, either as a manual step in Gimp, or (better) store a single image in the resources and do the channel operations in code:
While I realise that I'm probably subverting the properties of light for the sake of coding simplicity, I am concerned that I may not be getting the most believable results. Given that the rendering engine knows more about the light paths than I do from the final image, is there a way to do this in Blender?
For posterity, these are the material nodes I ended up with:
With a further change to adjust the alpha channel on the highlight image, these are the compositing nodes I created:
Finally, this is the end result, after tinting and overlaying in the game source code: