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

245
Vistas
Apply a vertex shader on a mesh, independently of its position

I'd like to apply some movements on my meshes using a vertex-shader. I noticed that when I translate my meshes in my scene it also moves the position of my simple sinus wave. I'd like to have the same sinus wave on both my meshes even if I translate my meshes in my scene.

I had a first lead with this post : Keep movement of vertexShader despite of its mesh rotation

I tried to reproduce this solution but I'm missing something. Here's my shader :

        uniform float uTime;
        
        void main()
        {
            mat4 translate = mat4(1.0);

            vec4 modelPosition = modelMatrix * vec4(position, 1.0);
            
            translate[3].y = sin(uTime * 2. + modelPosition.x *1.);

            vec4 modelPosition2 = modelMatrix * translate * vec4(position, 1.0);

            gl_Position = projectionMatrix * viewMatrix * modelPosition2;
        }

I think I shoudn't apply my modelPosition.x on the translate[3].y line but I don't know what to call instead. As you can see on this codepen, my planes look different : https://codepen.io/michaelgrc/pen/GRMxYBm

Does anyone see what I'm missing ? Thanks a lot

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I needed to use position.x instead of modelPosition.x to solve my issue :

translate[3].y = sin(uTime * 2. + position.x);
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