I’m trying to use the same simple custom shader on two different entities but with different UV values.
varying vec2 vUv1;
uniform sampler2D uDiffuseMap;
void main(void)
{
vec4 color = texture2D(uDiffuseMap, vUv1);
gl_FragColor = color;
}
- but it seems that the same set of UVs (
aUv1: pc.SEMANTIC_TEXCOORD1
) is shared between the shaders, using the same value - I’ve tried creating a second identical shader that uses
aUv2: pc.SEMANTIC_TEXCOORD2
and tried usingmesh.setUvs(2, textureCoords);
to set it. But when I check the vertex buffer, it seems that the new attribute isn’t being added.
A minimal test is here https://playcanvas.com/editor/scene/1757000.
- Is it possible to re-use the same shader but with different attribute values?
- How can I add and use new attributes?