Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

468
Visualizações
ThreeJS: Shader UVs not defined if glTF model contains no texture

I'm importing a glTF model that contains a UV set, and I want to assign a texture to it dynamically in ThreeJS by injecting shader code into the existing using onBeforeCompile().

So far everything works, however if I remove the test texture from the model in Blender and re-export it, then the shader refuses to compile with a vUv undeclared identifier error. When viewing the geometry buffer attributes in the debugging console, the UV maps seem to be defined, but aren't getting defined in the shader for some reason.

I don't want to export the model with a texture, that would mean loading the texture twice (once when the model was loaded, once when the texture is loaded dynamically).

Does anyone know how to get around this?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

the UV maps seem to be defined, but aren't getting defined in the shader for some reason.

That happens because built-in materials only define the vUv varying if maps are sampled in the fragment shader. Since you have removed all maps from your asset, no varying is defined.

One solution to solve the problem is to define the varying manually via onBeforeCompile() by overwriting the uv_pars_fragment shader chunk with just varying vec2 vUv;.

about 4 years ago · Juan Pablo Isaza Relatório

0

After quite a bit of digging I found I can just set

material.defines.USE_UV = '';

And it will enable the UVs for the model

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda