Hey everyone, I'm having some trouble figuring how to properly transform my vectors to perform lighting in eye space.
Right now I'm trying to do a directional light in glsl/ opengl.
What I'm doing now:
- Transform light position by the inverse view matrix, as to transform it to eye space. This is sent as a uniform to glsl.
- In vertex shader, transform normal by mat3(view) * mat3(world). (I know i could send this as a uniform)
- The vertex in eye space is transformed by view * world and sent over the fragment shader along with the normal vector.
- In the fragment shader, the vector from eye to vertex is calculated as just (-position).
Would really appreciate some help on this.