@brandon, now I understand more about what you are trying to achieve… I wasn’t aware you wanted to swap out the decals before. So there are a few ways you can approach this, one being splitting the mesh into two and assigning different materials containing the textures you need for each surface. That works, but isn’t a very elegant solution as you carry extra draw calls for the split meshes.
So I would opt for a custom shader (like I normally do) which will require a little bit of planning on the part of your UV layout. Let’s make these assumptions for the sake of argument:
- Each side of the deck is UVed in a vertical orientation, side by side
- The decal side of your deck can be contained between 0 and 0.3 in U space, leaving the rest over 0.3 in U for the other side of the deck and your edge thickness
- Your decal textures are all the same size and are 30% of the width of the texture you are using for the base board.
- You want to show the deck without any decal at some point, so you would just have bare wood as the default in your main texture between 0 and 0.3 in U
The we just need to mix the two textures, the base texture and the decal texture, in the shader. I am just going to show the part of the shader that will mix the two textures for you as you can see the rest of the PBR node setup in (8193) PBR Nodes in Node Materials Part 1 - YouTube. You will want to do this for each of the PBR inputs that need to change. For example, if you need custom roughness or normal textures for your decal, you will need to do this method for each of those inputs. I would always double check the reasoning for adding more channels like normal or roughness to this method just so that my number of texture loads does not get out of hand.
For the two images, we have a UV debug map used as the base texture:
And a Babylon.js logo on a background for the decal. Note that the decal is exactly 30% of the width of the base texture and 100% of the height. Setting up your textures like this will streamline things for you down the line and prevent visual bugs in your asset:
In the shader we are loading the two textures into texture blocks (you will assign your decal through code as you need to change it). The first thing I do is to divide the U coordinates by 0.3 for our decal texture to get it into the correct proportion. Next is to use the U coordinate of the mesh UVs to set up a step node with a break of 0.3. This is then used as the gradient in the lerp between the two textures. The resulting texture is:
We retain the proportion of the images correctly, but have now mixed them to correspond to our UV layout in the mesh. Again, this would then become the input for the base color of the PBRMetallicRoughness block and you would also do this for other inputs that need a switch on them. Another thing you may want to add to the shader is the ability to bypass the decal all together (for a deck with no decal) and to do that, you would just change the break point to 0.0 instead of 0.3. Or you could do something like multiplying the break float by a bool which can be set in code which would translate to multiplying it by 0 if false and 1 if true for your decal. This would prevent you from having to update a lot of code if your UV breaks change in the future.
I hope this helps, but if you have more questions, please feel free to ping me.