I’m getting this error in Firefox for a custom material extending pc.Material:
WebGL warning: drawElementsInstanced: Tex unit 0 referenced by samplers of different types: SAMPLER_2D (via sTopDiffuseMap) and SAMPLER_3D (via sGlobalAO)
and a similar one in Edge
GL_INVALID_OPERATION: Two textures of different types use the same sampler location.
and I can’t figure out why is this happening. I’m setting one of the textures sTopDiffuseMap directly on the material through material.setParameter and the other one sGlobalAO via the mesh instance (meshInstance.setParameter) as those are different per mesh.
What could cause this, something like this used to work for me? What part of code handles the texture unit assignments so that I can investigate?
Are you getting this on 1.57 engine, or 1.56 as well?
There were some changes to the sampler sharing done in 1.57 released just yesterday that could be related. See this line “Only add the shared sampler if the chunk uses the $SAMPLER macro.” in release notes for relevant PRs: Release v1.57.0 · playcanvas/engine · GitHub
It could also be caused perhaps by not having a required texture specified on the material, and so it will use whatever textures was assigned to that slot in for some previous draw calls perhaps. And that could be of different type.
Firefox and Microsoft Edge and Engine 1.57. I’ll have to check on 1.56 as well and come back later, our monorepo gets the latest version of PC when building and I’ll have to check with my colleagues to see how to use an older one.
I have found the issue eventually. I was loading one of the textures async and when I was creating the material and setting up the parameters that texture was not being added as a param.
When it was loaded, I was setting the new param to the material and that seemed to cause the issue.
The fix was to assign a placeholder texture until the real one is ready and that fixed the issue.