Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

460
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda