World Position in glsl for instanced mesh

I’m trying to get world space texture coordinate for instanced meshes, it works for individual objects but not for instanced meshes.

W_Pos = (modelMatrix * vec4(position,1.0)).xyz;

individual objects

instanced

Any Help?

Maybe this:

W_Pos = (modelMatrix * vec4(position,1.0)).xyz;
W_Pos = (instanceMatrix*vec4( W_Pos, 1.0 )).xyz;

Or this:

W_Pos = (instanceMatrix* vec4(position,1.0)).xyz;
W_Pos = (modelMatrix * vec4(W_Pos,1.0)).xyz;
1 Like

or this: W_Pos = vec3(modelMatrix * instanceMatrix * vec4(position, 1.)); :thinking:

1 Like

im super dumb lel
i remember reading it in the docs but completely forgot

Thnx for the answer!