Currently making a game and trying to do get an overlay to cover the screen when the "menu" button is clicked - something that I would imagine should be fairly common/simple, but still having problems implementing it.
The current setup I have:
- TiledMapRenderer: to render TMX tiles (background/map)
- SpriteBatch: for various assets (eg. player image)
- Stage: to hold the menu buttons
- ShaderProgram: using GLSL to create the overlay/shading effect
- SpriteBatch and map are set to use the ShaderProgram
As suggested by many people, for performance, I am only using one SpriteBatch - so the same sprite batch is used by both the various assets and menu Stage.
The aim of the shader is to add a dark/semi-transparent overlay to grey out the screen so the menu will be easier to read when it is open.
The main issue I'm having is that because the assets and menu share the same SpriteBatch, they also share the same shader...so, when I enable the shading effect everything (background and menu buttons) is greyed out.
How can I use only one SpriteBatch but only apply the Shader to the background (and keep the menu buttons normal/unshaded)?
SpriteBatch
? Apply graying effect only after a certainz
threshold? – Stefan Hanke