Yeah, but is it like a known bug of box2dlight or just me?
Let me show the code, hope you guys can pinpoint what am I doing wrong here. (please help!)
Box2dLight used.
The Application Listener:
public void create() {
testStage = new BaseStage(800, 480, true);
FileHandle backgroundPicture = Gdx.files.internal("assets/sampleBG.png");
texture = new Texture(backgroundPicture);
Image img = new Image("bg", texture);
img.x = 0;
img.y = 0;
testStage.addActor(img);
}
@Override
public void render() {
GLCommon gl = Gdx.gl;
gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
testStage.act(Gdx.graphics.getDeltaTime());
testStage.draw();
}
The Base Stage:
public class BaseStage extends Stage implements InputProcessor {
RayHandler rayHandler;
World world;
OrthographicCamera camera;
public BaseStage(float width, float height, boolean stretch) {
super(width, height, stretch);
Gdx.input.setInputProcessor(this);
camera = new OrthographicCamera(80, 48);
world = new World(new Vector2(0, 0), true);
rayHandler = new RayHandler(world);
rayHandler.setCulling(true);
rayHandler.setCombinedMatrix(camera.combined);
rayHandler.useDiffuseLight(true);
rayHandler.setAmbientLight(0.2f, 0.2f, 0.2f,1.0f);
}
@Override
public void draw () {
super.draw();
rayHandler.updateAndRender();
}
@Override
public void dispose() {
rayHandler.dispose();
}
public Vector2 gdxCoordinateToBox2D(float x, float y) {
float K = 10;
return new Vector2(x/K-width/(2*K), height/(2*K)-y/K);
}
@Override
public boolean touchUp(int x, int y, int pointer, int button) {
Vector2 coordinate = gdxCoordinateToBox2D(x, y);
Color clr3 = new Color(0.5f,0.8f,0.2f, 0.9f);
Light pt = new PointLight(rayHandler, 5, clr3, 30, coordinate.x, coordinate.y);
pt.setStaticLight(true);
return false;
}
}
The Problem:
So when lights overlap, instead of getting more greener, it kinda cancels itsef and get’s to original picture.
I guess I am using it wrong, any help will be so much appreciated!
Sorry for late answer.
Thats not a bug. Problem is related to low dynamic range rendering. You just overburn the color buffer and everything is solid white at those points where many light overlap.