Hi!
I am writing my own game/engine and I'm facing a problem. I have a lot of semi-transparent things such as the water surface, particles, (stained) glass, etc. They need to be lit like any opaque thing, otherwise you'll have e.g. glass that makes everything behind it brighter when it is lit while the rest is dark.
While I know the ambient and diffuse brightness of the scene before rendering it, I do not know whether you are in a dark cave or next to a light source, so just using the sun light for that does not work.
So I am pretty sure I need to do the same post processing lighting calculations (sun light, volumetric ambient lighting, etc.) for semi-transparent pixels that I do for opaque pixels.
However, when I do this I run into another problem. If there are 2 or more transparent things behind each other, this breaks when they are lit differently, e.g. by shining a flashlight at the rain in front of the water surface in the background. I implemented multiple render passes to solve this, but this still has a limitation (2, 3, or 4 transparent things, based on the settings) and it is pretty slow.
I am using order-independent transparency rendering (weighted sum of colors based on depth) because I cannot order everything by distance, especially not the particles.
The tutorials I could find are very basic and I don't know what to look for specifically. Can anyone point me in the right direction here?
I am basically out of ideas, the only thing I could think of would be rendering the semi-transparent objects grouped by type and do lighting calculations for each group, i.e. water first, then particles, and so on. But I don't know if this would be much faster or look better.