So uhm… I kinda “finished” my game Zombie Massacre and had nothing else to do, so I decided to add lights to it.
I have done that with shaders, and it seems to work pretty nicely. But the problem is that I’m calculating lights for vertices, not for pixels. If I make light really dim, there is no problem, because differences between vertices are pretty small, you can’t even see it. But when the light is really strong and shiny, you can see that the light is calculated between vertices, and the lighting is really squary.
So what is the “way” to do it per pixel? Calculate lighting in fragment shader?
The way I have done the lighting is just take the distance from vertex to light and convert it to some kind of color value. Is there some kind of GLSL function in fragment shader for getting the fragments position?
I tried looking in the web for per pixel lighting, but they all seem to be 3d tutorials…
Would be awesome if anyone could shine some light upon this topic