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); <--- 

how fix it? enter image description here

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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -