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

241
Visualizações
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 Respostas
Responde à pergunta

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 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