earlygrey / shapedrawer

A library for libGDX that draws simple shapes using a batch.
MIT License
185 stars 32 forks source link

A way to make gradients smoother #60

Open Klemms opened 1 year ago

Klemms commented 1 year ago

Hi,

This is more an help request post than a real issue, but I was wondering if there was any way to make gradients smoother ? Maybe there is a way and I didn't find it ^^

This is the example of a gradient and as you can see, the different colors are very visible. image

Frosty-J commented 1 year ago

You can apply dithering. I used ShapeRenderer but it's probably much the same process for shapedrawer. This is from an abandoned project and I don't remember if the end result looked any good.

ShaderProgram shader = new ShaderProgram(Gdx.files.internal("dither.vert"), Gdx.files.internal("dither.frag"));
Texture bayer16 = new Texture(Gdx.files.internal("blueTri64_0.png"), Pixmap.Format.RGBA8888, false);
bayer16.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);

Download shader/texture files