UV morphing results in "Two textures of different types use the same sampler location"

I have a simple glTF model for testing UV2 morphing. When opening it with the sandbox, a morph target is created. When changing the target weight to anything but 0, a GL_INVALID_OPERATION is fired with the message “Two textures of different types use the same sampler location”, and the mesh cannot be rendered.

The test model can be found on GitHub chubei-urus/Assets/blob/uv2-morph/meshes/UV2Morph. The forum won’t let me to post links.

With the current sandbox, the UV2 morphing would be ignored and the morph target would have no attribute. I’ve tried to change the morphed attribute from TEXCOORD_1 to TEXCOORD_0 so the morph target has one attribute, and the result is the same.

Attaching the Python script used to generate the buffer data here for easier debugging.

from PIL import Image
import numpy as np
import struct

gradient = np.zeros((256, 256, 3), dtype=np.uint8)
for i in range(256):
  gradient[:, i, :] = i
Image.fromarray(gradient).save('gradient.png')

positions = [-0.5, -0.5, -1, 0.5, -0.5, -1, 0, 0.5, -1]
texcoords1 = [0, 0, 0, 0, 0, 0]
texcoords2 = [0, 0, 1, 0, 0.5, 0]
indices = [0, 1, 2]
texcoord_offsets = [1, 0, -1, 0, 0, 0]
positions = struct.pack(f'{len(positions)}f', *positions)
texcoords1 = struct.pack(f'{len(texcoords1)}f', *texcoords1)
texcoords2 = struct.pack(f'{len(texcoords2)}f', *texcoords2)
indices = struct.pack(f'{len(indices)}I', *indices)
texcoord_offsets = struct.pack(f'{len(texcoord_offsets)}f', *texcoord_offsets)
with open('uv2.bin', 'wb') as f:
  f.write(positions + texcoords1 + texcoords2 + indices + texcoord_offsets)

cc @bghgary

Just to make sure we have the right context, this is coming from a draft PR that hasn’t merged yet: Add UV2 morph support and load UV and UV2 morph targets from glTF by chubei-urus · Pull Request #15602 · BabylonJS/Babylon.js

cc @Evgeni_Popov @Deltakosh @sebavan

@chubei-urus do you repro in our production sandbox ? or only your branch ?

Reproduced on production sandbox

Just realized TEXCOORD_0 is not loaded either, so it may be related to the morph target having no attribute.

The problem is that there is no data associated with the morph target. I’ve updated the inspector so that such targets are no longer displayed, to avoid starting targets without data:

Hi @Evgeni_Popov I think the root cause is that morph target doesn’t have positions attribute. If the morph target only has UV attribute, the same error is fired. See Babylon.js Playground. If we uncomment line 32, the scene renders fine.

Yes, a morph target without positions is invalid, the shader code always expect positions to exist.

I’m going to create a PR so that the “positions” target is optional later, but I don’t think that should block you from your own PR?

2 Likes

It’s not blocking. I can add position morphing to the test model

1 Like