#[CLOSED] GLSL - how to move meshes in one direction?

6 messages · Page 1 of 1 (latest)

strange vale
#

i have 2 position variables: aPos and worldPos.
aPos - local pos relative to the model
worldPos - world pos relative to the world

vertex shader code: (sth like this)

#version 330 core
layout (location=0) in vec3 aPos;
// other stuff for fragment shader
// ...

out vec3 FragPos;
uniform mat4 camMatrix;
uniform mat4 model;
uniform mat4 translation;
uniform mat4 rotation;
uniform mat4 scale;
uniform vec3 worldPos;

void main()
{
   FragPos = vec3(model * translation * rotation * scale * vec4(aPos + worldPos, 1.0));
   
   // normal, colors, UVs, etc.
   // ...

   gl_Position = camMatrix * vec4(FragPos, 1.0);
}

how can i move the meshes in one direction relative to the world without rotation?

thorn juniper
#

You translate it in that direction?

strange vale
eager stone
#

It is not clear what you are asking.

strange vale
#

i fixed it. i just changed the order.
before:

FragPos = vec3(model * translation * rotation * scale * vec4(aPos + worldPos, 1.0));

after:

FragPos = vec3(model * translation * rotation * scale * vec4(aPos, 1.0)) + worldPos;