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.

Hi! Sorry, didnā€™t see the notification! Is this still unresolved? :sweat_smile:

Iā€™m not really sure how to help though, and no idea how to animate all thisā€¦ Can a texture be a .gif?
Also, blending the main diffusemap and the diffusedetailmap is hard (for me :stuck_out_tongue:) when the detail is something else than a black&white or black&transparent image.
A B&W diffuseDetailMap with multiply mode makes a nice mask, everything white (or already transparent) becomes transparent.

Hereā€™s an example with a ā€œstainā€ and the more a pixel is close of white, the more itā€™s alpha value decreases. This is in MIN mode, which has the best effect in this example but it will vary depending on which of the main or detail texture is the darkestā€¦

Not sure if it helps, but it might be a step towards a solution haha, good luck !

Yep thatā€™s correct! The size of the border varies and the glitching pixels can appear at any zoom levelā€¦ (in general 10px is good enough in my experience)

3 Likes