Hello,
Using OpenGL ES 2.0 with shaders.
I just created a light source where the reflection from the light (the specular part) on my flat surface is following me so to speak. Like walking on a wet road with roadlights reflecting on the wet road. Or like a sunset, just that you can get close to the “sun”.
Now, in the vertex shader I have implemented this both from a world space point of view and an eye space point of view.
With worldspace I mean that just the various shapes are transformed into their positions in the world. It is in worldspace that I for example decided where the lightsource should be. (-3, 1, 0) and then I created a mesh from (0,0,0) extending in pos x and negative y. Translated the mesh (-3, 0, 0) so that the light is just above the corner of the mesh. The I fly of to the opposite corner (like pos x, neg z) to watch the reflections.
With eye space I mean that I have transformed worldspace to eye space with the View matrix which is my transposed camera matrix. (modelviewmatrix = viewmatrix * modelmatrix).
Any thoughts about prefered way?
In worldspace I need to pass in the players position to do the reflection calculations. Other than that it’s pretty neat to work in this space. I prefer this way.
However in eye space I can just check against the normalized negative vertex position in eye space. But instead I need to transform the lightposition from worldspace to eye space.
/p