Shader to dynamically recolor select parts of a fully textured mesh?

I’m aware of ID maps in Blender and the mix map in the Babylon.js Terrain Material and multi-materials but none of these are quite what I’m after. I am wondering if there’s something sort of like this in a shader, node material or other technique to dynamically change the color of select portions of a fully PBR textured mesh using a mask or ID map? Or selectively blend with the underlying base color?

Use case: Multi-player tank combat game with each tank having the same geometry, UVs etc and a single PBR material, but with the ability to easily colorise each player’s tank livery (the main part, not trim, grime, dirt, reflectivity etc) say red, green, blue etc.

This would mean far less texture variant creation, loading time and lower memory footprint.

I think decals could fit the bill?

This can also help if you want to use texture decals instead of mesh decals:

Thanks for the reminder @Evgeni_Popov as this had slipped my mind. I think it’ll be really useful for damage but I’m ideally after something a bit different for dynamically colorising the bulk of a player mesh. Using texture decals I’d still need multiple textures - one for each potential player color right? What I’d prefer is each mesh having a definable base diffuse color and the shader renders / allows more or less of this base color to shine through when it encounters a texel of a certain color, like a “green screen” or an ID map e.g. if texel is solid green then fragment color is whatever the base diffuse color is. Or a simple greyscale mask I can use that blends more or less of the underlying base diffuse color with the overlaid textures.

Yes indeed.

You could try using a plugin material to modify the output color based on a texture mask or another mechanism.

1 Like