opengl - Normals move with model -
i wrote shader diffuse lighting.
normals rotate rotation of 3d model, , looks when rotate model, light rotate to.
vertex shader
position = gl_modelviewmatrix * gl_vertex; gl_position = gl_modelviewprojectionmatrix * gl_vertex; normal = vec4(gl_normal, 1.0); <--- gl_texcoord[0] = gl_multitexcoord0;
fragment shader
lightvector = normalize(vec4(lightposition + cameraposition, 1.0) - position); resultnormal = normalize(normal.xyz); <---
you don't seem transforming normals gl_normalmatrix
. also, line suspicious:
normal = vec4(gl_normal, 1.0);
normals directions, not positions, .w
component should 0.
Comments
Post a Comment