I am about to develop a game completely in shades of grey using libGDX and just for testing purposes, i created two textures in photoshop:
- 2048 x 2048 plain white png image with RGB color mode of size 19.1KB
- 2048 x 2048 plain white png image with grayscale color mode of size 7.67KB
... so basically both are just plain white images to look at, but the GREY.png one takes comparatively less space than the RGB.png. While rendering the both the images one at a time, RGB image renders perfectly but the grayscale one does not render at all and the output is completely black. My code:
@Override
public void create() {
texture = new Texture (Gdx.files.internal ("GREY.png")); // ...just change to "RGB.png" to render RGB.png image..
batch = new SpriteBatch ();
}
@Override
public void render() {
Gdx.gl.glClearColor (0, 1, 0, 1);
Gdx.gl.glClear (GL20.GL_COLOR_BUFFER_BIT);
batch.begin ();
batch.draw (texture, 0, 0);
batch.end ();
}
@Override
public void dispose() {
texture.dispose ();
}
This is all it...No cameras are used, just 2 lines in create() and 5 lines in render() method and 1 line in dispose() method, nothing fancy at all...
Also it will be really stupid to load 19.1KB texture and render it in greyscale using shader when you can directly load same looking image of 7.67KB size.
I don't understand why libGDX does not render the image with grayscale color mode, is it not supported?
UPDATE: grayscaled images are supported by libGDX and
texture = new Texture (Gdx.files.internal ("gs.png"), Pixmap.Format.LuminanceAlpha, true);
solved my problem.