I’m trying to re-use a texture loaded in a gltf loader getting the texture from associations.
When rendering the object with the standard material everything looks fine but when using the shader compiled in Unity it looks like the texture format is wrong.
See the following example (left Unity, right in threejs with a stripped down fragment shader)
when loading the texture all I do is forward it from the gltf file as a uniform value (getTexture only does some plumbing finding the correct texture using a guid from unity)
and using a RawShaderMaterial:
const material = new THREE.RawShaderMaterial({
uniforms: this.uniforms,
vertexShader: bundle.vertexShader,
fragmentShader: bundle.fragmentShader
});
This looks like a gamma issue – see Color management in three.js. Normally three.js does sRGB decoding in the shader, but Unity would do that in graphics hardware instead so that’s probably why it’s not included in the generated shader.
Perhaps. Try texture.flipY = false maybe? If these are default spheres in three.js and Unity, rather than the same GLB model of a sphere, then they might have different texture coordinate / UV conventions too.
Hello, found my stupid mistake. I was still flipping the tex coord because of an test few days ago when I tried loading the textures from disc and was flipping the sampler state y on export in codegen and didnt realize using a checkerboard texture