GLSL how convert position value from app to good for GLSL?

Started by
0 comments, last by xerodsm 16 years, 10 months ago
Hi. I build multilight system and I create pseudo light data for per pixel point light: struct LightData { vec4 Diffuse; vec4 Ambient; vec3 Position; float constantAttenuation; float linearAttenuation; float quadraticAttenuation; }; LightData Light; I hame one problem with calculate position of light. I have this cos in shader: [VERTEX] varying vec4 ecPosition; ... ecPosition = gl_ModelViewMatrix * gl_Vertex; ... [FRAGMENT] uniform vec3 lightPosition; varying vec4 ecPosition; ... vec3 Aux; Aux = vec3(vec4(lightPosition,0.0)-ecPosition); // Here is my problem, because if I have: Aux = vec3(gl_LightSource[0].position-ecPosition); shader work good. In my apllication is one Light in position (Light.Position) vec3(-373,334,-11) and this value has lightPosition. How Can I convert my lightPosition to position good for my shader?
Advertisement
Don't multiply the ecPosition by the ViewMatrix.

This topic is closed to new replies.

Advertisement