I am trying to use smooth normal and normal mapping together. And I made a test. In this test I draw a cube and man.

They are using same vertex shader and fragment.

I load them same md5loader because after i want to use skeletal animation.

They have same lighting source. And only different positions.

cube x=15 y=0 z=0 man x=0 y=0 z=0

I am not sure i did it right ?

Also i did just "normalize(vertex)" for smooth normal instead using "normalFlat" did i right ? :D

And My vertex shader:

in vec3 vertex;
in vec2 UV;
in vec3 normalFlat; // I won't use this it is standart normal
out vec3 tangentSurface2light;
out vec3 tangentSurface2view;

void main()


    vec3 lightPos2=vec3(ModelViewMatrix*vec4(lightPos,1.0));

    vec3 tangent;
    vec3 v1=cross( normalize(vertex) ,vec3(0.0,0.0,1.0));
    vec3 v2=cross( normalize(vertex) ,vec3(0.0,1.0,0.0));


    vec3 n=normalize(NormalMatrix* normalize(vertex) );
    vec3 t=normalize(NormalMatrix*tangent);
    vec3 b=cross(n,t);
    mat3 mat=mat3(t.x,b.x,n.x,t.y,b.y,n.y,t.z,b.z,n.z);

    vec3 vector=normalize(lightPos2-vertexPositionWorld);



enter image description here


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.