In GIMP I switched to a sine-curve progression now to draw the light sprites. And in my code (see above) I scaled the lights with factor 8. Together with the stone textures from the image you posted I come to the following result (running at 800 frames per second with 20 moving lights!). With 1000 lights it is still running with over 70 FPS (!).
(Check against
http://slick.cokeandcode.com/wiki/doku. ... alpha_maps )
Cons: - I think the lights here don't look as realistic as the ones in the documentation
- You need to prepare all light colors and brightness levels in your graphics program (i.e. GIMP)
Pros:- Damn fast!
- Usage of offscreen images possible (but only offscreen-to-screen; offscreen-to-offscreen isn't possible; probably due to a SLICK bug)
Attachment:
lighttest_smallfly.jpg [ 161.87 KiB | Viewed 1126 times ]
And since I think this code could help some people which - like me - think the lighting is good enough. Here is the technique: (detailed code see above)
Code:
public void render(GameContainer gc, Graphics g)
{
int ambientLightLevel = 100; // 0 = black as the darkest night; 255 = as bright as day
// offscreen drawing
gOffscreenGame.clear();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColorMask(true, true, true, true);
// draw game elements
gOffscreenGame.flush()
gOffscreenLights.clear();
gOffscreenLights.setColor(new Color(255, 255, 255, ambientLightLevel));
gOffscreenLights.fillRect(0, 0, WIDTH, HEIGHT);
gOffscreenLights.setDrawMode(Graphics.MODE_ADD);
GL11.glColorMask(true, true, true, true);
// draw lights (white sprites on transparent background; tip: use sinosodial gradients;
// use slight white for places where a light color will be drawn above and strong white for lights that will be white in the end)
gOffscreenLights.flush();
gOffscreenLightColors.clear();
gOffscreenLightColors.setDrawMode(Graphics.MODE_NORMAL);
GL11.glColorMask(true, true, true, true);
// draw the light colors (colored sprites on transparent background; same size and shape as white lights)
// draw them exactly above slight white colored light sprites
gOffscreenLightColors.flush();
// on screen drawing
g.clear();
g.setDrawMode(Graphics.MODE_NORMAL);
g.drawImage(offscreenGame, 0, 0);
GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_SRC_ALPHA);
g.drawImage(offscreenLights, 0, 0); // here we draw the lights by using the light offscreen image as alpha map
g.setDrawMode(Graphics.MODE_ADD);
g.drawImage(offscreenLightColors, 0, 0); // here we add the light colors to the lights
g.setDrawMode(Graphics.MODE_NORMAL);
g.flush();
}
_________________
http://www.p1sim.org - Economy/Logistics simulaton based on Java and Slick2D