Jump to content
Sign in to follow this  

glsl world space to local space

Recommended Posts

I am trying to transform an geometry from world space to local space in glsl shader, but not get an expected result.


What i'm looking for is like what i get in unreal editor.




As described in HDK_ViewportGL3_Intro: "glH_InvObjectMatrix (mat4) - inverse transform matrix for the current object (world->local)".

I thought it may help to accomplish the transform task, but failed.


Any help is appreciated!

Thanks in advance!!



in vec3 P;

uniform mat4    glH_ObjectMatrix;
uniform mat4    glH_ViewMatrix;
uniform mat4    glH_ProjectMatrix;
uniform mat4    glH_InvObjectMatrix;

out parms
    vec4  pos;
} vsOut;                       
void main()
    vec4 pos;   
    pos = vec4(P, 1.0);
    vsOut.pos = glH_InvObjectMatrix * pos;
    gl_Position  = glH_ProjectMatrix * glH_ViewMatrix * pos;


in wparms
    vec4 pos;
} fsIn;

uniform mat4 glH_InvObjectMatrix;

out vec4 color;

void main()
    color = vec4(fsIn.pos.xyz, 1.0);


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this