LibGDX darken screen for nighttime cycle

My new “game” has a day and night cycle. I want to overlay the screen with a transparent black rectangle. I have tried and tried using this for when it’s “nighttime”:


if (!NightAndDayCycle.isDayTime()) {
	Gdx.gl.glEnable(GL20.GL_BLEND);
	Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}

and in the render method:


if (!NightAndDayCycle.isDayTime()) {
	screenShader.renderObject(myGame.renderer.shapeRenderer);
}

^ that loads a transparent black square overlayed on the screen.

The problem is, I also have a home made particle emitter that uses shape renderer as well, that draws a fire effect. Whenever it is “nighttime” and that transparent black square is drawn, it cuts off the fire effect (so it is no longer visible at all).

So my question is, am I doing this the correct way? Or should I be using an actual image with the sprite batch that is transparent? I wanted to use the shaperenderer so I could fade it in and out eventually, but I want to figure out if I’m doing this correctly before I move on with it.

lol nevermind guys. I just did something I had never tried in since I began trying to do this, which is putting that blend function in the actual ‘screenShader’ class, and now it works. Sorry. It’s funny trying to fix this for so long and cant, ask the question, then figure it out within 2 minutes.

Np :slight_smile:

It’s normal: