[Slick2D] Slick2D AlphaMap, what i do wrong?

Hello everyone. I can’t manage to make the alpha map to render correctly.

Here is what i have:

In the SpriteSheet, the sprites background is transparent and for tiles the same.

Here is my render code:

		g.resetTransform();
		
		g.clearAlphaMap();
		GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
		
		g.setDrawMode(Graphics.MODE_ALPHA_MAP);
		Image alphaMap = ImageLoader.getAlphaMap();
		
		alphaMap.drawCentered(Display.getWidth()/2, Display.getHeight()/2);
	      
		GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
		g.setDrawMode(Graphics.MODE_ALPHA_BLEND);

		g.translate(xOffset, yOffset);
		
		//RENDERING EVERITHING

This is a limitation of the technique – because your sprite has alpha it interferes with the alpha map you’re trying to create.

Anybody know a way to work around this with clever blending or some stencil buffer usage…? I haven’t looked too much into the problem; sadly this makes the technique not all that practical for lighting.

EDIT: One solution I proposed to this in this tutorial is to “bake” your game to a texture. i.e. Your whole game is rendered as per usual, however it’s rendered to an Image rather than to the screen. Then, once your game is rendered, you apply the lighting effect to the image, i.e. as a “post-process,” and render the processed image to the screen.

Or you can flip it around, and render the game to the screen, then render and accumulate lights to an image and then just draw the light map over the screen.

Oh my… This is the best idea, and the simplest. I can’t belive i didn’t think to this. I should simply make an image where i should place the “lights” and then i should only render it over everything.

Thanks to everyone. ;D