Change diffuse map through masking

Hello all,

I am looking to achieve a paint-on effect where a new diffuse map is applied to a model through masking. I created a simple demo in order to explain what I mean using two render components but would want achieve this on the same model. Any ideas on how I should approach this?

You can write a shader chunk for diffuse.
In my own case, i merge multiple patterns as black and white textures, and used mix function to display different data, using patterns as a mask.
image

4 Likes

There’s a second texture map that is accessible via code that could be used (detailMap) https://developer.playcanvas.com/api/pc.StandardMaterial.html#diffuseDetailMap

1 Like

I glanced that but didn’t realize it was simply another channel. That would make it rather straightforward although I also notice there was no opacityDetailMap – so wondered if the opacityMap would affect both diffuse maps?

It would apply to the model so in that sense, yes it would affect both diffuse maps

In that case – how would I mask one of the diffuse maps? Is there another way apart from using an opacityMap to do it, without using your own shader chunk?

opacityMap would affect the rendering the mesh hence why there isn’t a ‘detail’ version of it.

@TonyLGC did this for their knife configurator: Showing multiple textures on the same model

@TonyLGC are you able to help here?

IIRC, you had to have a big enough border around the decal detail texture and set the texture to clamp so that the mipmapping of the texture doesn’t grab the pixels on the edge of the mipmaps and stretch them.

You can then use the UV offset and tiling properties to position the decal on the detail map.