Hi, I’ve been trying to find a way to disable Box2DLights for certain sprites, while still using Box2DLights for other bodies and sprites.
I have a starry background and a ship. It is a top down kinda game. The problem is where the lighting casts shadows over the background stars.
I can’t exactly set ambient lighting as I need the pitch black areas. I’ve looked around and bumped into a few things. Blending, filtering and shaders.
I have no idea how shaders/GLSL work but it seems to be what I should look more into
I’m actually already using filtering for certain bodies, the floor fixture for example.
Of course I don’t know what’s going on in the background, but to turn off Box2DLights for a texture seems like it would be a simple task :
I think blending is a good option also. My guess, from what I’ve discovered is there might be a way to render the lighting to a buffer or something
and then use blending to hide lights and shadows on certain sprite textures.
Otherwise I might have missed something I dunno.
My render loop goes like this
public void render(float delta){
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
cam2D.update();
camBG.update();
batchBG.setProjectionMatrix(camBG.combined);
batch2D.setProjectionMatrix(cam2D.combined);
ship1.update(Main.cameraZoom);
background.update();
character.update(cam2D.position.x, cam2D.position.y);
if(GameInputs.keyPressed(Keys.ESCAPE))
main.setScreen(new LaunchScene(main));
world.step(12, 80, 80);
shipLight.setPosition(ship1.body.getWorldCenter().x, ship1.body.getWorldCenter().y);
playerLight.setPosition(character.body.getWorldCenter().x+character.force.x*99999, character.body.getWorldCenter().y+character.force.y*99999);
batchBG.begin();
background.render(batchBG);
batchBG.end();
batch2D.begin();
ship1.render(batch2D);
character.render(batch2D);
batch2D.end();
rayHandler.updateAndRender();
rayHandler.setCombinedMatrix(cam2D);
}