Tried it, but I'm getting terrible flickering here. Might be some driver setting if it's just me.
Works fine otherwise, never drops below 60 FPS. Any chance of more info of how you did it? Does it support any shadows?
It is not a driver thing i get is sometimes but I think is because I threw this together really fast and may have done the buffering wrong or something.
Anyways when I say no shadows I mean I am basically drawing images with a specific alpha interpolation that takes the sources alpha and uses that for the destination. So you are not ever casting any rays or gradients or checking to see if you hit some wall.
The pipeline goes like this: Draw everything effected by light, draw lights to an image or lightmap (this is very slow on high resolutions), draw lightmap, draw anything else not effect by light. You can do this any number of times layering lighting effects.
Here is the core of the trick
Image light = drawLights();
The first draw call sets the light and should always be 1. You could lower it to lower all light values but that should not be done here. The second call is how much of the images color you are going to put on top of the light. You could use none but it would look a little strange.
The light map or image I use when I call drawLights() is a smaller resolution then the window/frame/canvas I am drawing on. This reduces the quality of the lights but greatly improves performance to the point where rendering lights cost almost nothing. ( I also like the pixelated effect at low resolutions) After the lights are drawn onto the image I render the image but stretch it to fit the window.
Here is the drawLights() method
public Image drawLights()
BufferedImage buff = BufferUtils.getCompatibleImage(pane.getWidth()/lightmapScale, pane.getHeight()/lightmapScale);
Graphics2D g = (Graphics2D) buff.getGraphics();
for(int i = 0; i <= lights.size()-1;i++)
g.fillRect(0, 0, pane.getWidth(), pane.getHeight());
There are a lot of optimizations you could do through all of the example but I just wanted to see if it would even work at some form of fps.
The problem is you really cant get cool looking shadows because if you say have a square block the light would go right through it or below it. I think I could come up with something so when the light hits those objects that block light it simply stops. Wont be really cool sharp shadows but it would be much more useable.
Even with this down side, the performance is great and it still can work in many games i think.