Is it possible to use perpixel lighting in combination with transparent surfaces? And if yes, how can I do that?
I’m storing the attenuation and (N dot L) result in the alpha buffer. Then I’m multiplying the diffuse texture map with the alpha buffer using this blend equation: glBlendFunc(GL_DST_ALPHA, GL_ONE); but all the surfaces are solid now.
The normal blend equation for transparent surfaces is (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) but I can’t use that equation because it doesn’t include the perpixel lighting results from the alpha buffer.
Ok, it is possible…using glBlendFunc(GL_DST_ALPHA, GL_SRC_ALPHA) for example…
Once you understand how the OpenGL blending equation is working, it isn’t that hard any more. For everyone else who has problems with the equation, here is the great tutorial that helped me: http://www.bigpanda.com/trinity/article2.html
You’re right, transparency with several passes could really become a problem. My idea is to draw already the ambient pass of transparent faces with blending enabled and to add the lighting results using (GL_DST_ALPHA, GL_SRC_ALPHA). I haven’t tested it yet; might be that won’t work at all but it is the only way I can figure out at the moment.