3
\$\begingroup\$

I'm trying to draw a background texture with tiles that I'll rotate and mirror to create a maze. Here is a sample tile:

sample tile

As you can see, I use an alpha gradient on the borders. If I'd use a sharp border instead, you'd notice the border between a tile and another because these shadows and glows are not perfectly symmetrical.

So far it works OK, but I've noticed there is a slightly darker spot where two tiles connect:

dark spot

I used Photoshop to create these gradients, and was very careful to make sure these gradients are linear and start exactly where the next gradient ends, so that the total alpha of every pixel add up to exactly one.

I'm using a SpriteBatch to draw these textures and use the default blending mode (I don't set any blend function at all). Apparently I'd need some blending function whose output will be the sum of both image's alphas and the average of their colors. Is this the default mode (if so, I guess my picture's alpha gradients are not perfectly linear)? And if not, what should I set my SpriteBatch's blend function to?

Edit: So I tried batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_DST_ALPHA) and it fixed the dark spot, but now the textures I draw on top look messed up, even if I revert it back to the old blending mode right after drawing my tiles.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.