So I Implemented a texture splatting technique which I found in this very forum.
Basically I am replacing the default map_fragment shader code with the following:
'vec4 tbBlend=texture2D( texBlendMap, vUv );', 'float tbBaseWeight=1.0 - max(tbBlend.r, max(tbBlend.g, tbBlend.b));', 'vec4 base = tbBaseWeight * texture2D( texBaseColor, vUv * repeatBase );', 'vec4 color1 = tbBlend.r * texture2D( texTile1Color, vUv * repeatTile1 );', 'vec4 color2 = tbBlend.g * texture2D( texTile2Color, vUv * repeatTile2 );', 'vec4 color3 = tbBlend.b * texture2D( texTile3Color, vUv * repeatTile3 );', 'vec4 newColor = (vec4(0.0, 0.0, 0.0, 1.0) + base + color1 + color2 + color3) / (tbBaseWeight+tbBlend.r+tbBlend.g+tbBlend.b);', 'newColor.a = tbBlend.a;', 'diffuseColor = mapTexelToLinear( newColor );',
This produces exactly what I want, however on mobile the performance is pretty bad. What would otherwise be a 60fps scene will drop to 20fps and my phone gets HOT.
I was a bit surprised to see such a strong impact, on the other hand, shader programming is not something I have a ton of experience with.
Is there something wrong with this shader code? Is there a way to optimize it? I really like the result as I can simply paint trails and such, but ouch, the performance hit is just too strong.
Any help would be greatly appreciated.