2
\$\begingroup\$

I'm messing around with XNA in a very simple Minecraft-esque world I'm making and I'm wondering how I can do the "breaking the block" visuals in XNA.

If you're unfamiliar with the game, you begin interacting with the cube and based one what tool you're using, the block will take X amount of time to break. There's about 10 different stages of cracking that the cube will display before the cube breaks. I'm curious about how to display those 10 stages of cracking on top of the original skin of the block.

I know the game works using a Sprite sheet to color the blocks. This sprite sheet does not include every possible design at every possible stage of breaking the block, each stage is a different sprite with some transparency.

In short, how can I quickly and efficiently overlay a texture on a surface that already has a texture?

Do I have to combine them? If so, how?

\$\endgroup\$

2 Answers 2

5
\$\begingroup\$

Use XNA's DualTextureEffect when drawing your block. It's a standard shader that lets you overlay one texture in top of another. Just use the same base texture and overlay different cracking textures in top of the other.

\$\endgroup\$
3
\$\begingroup\$

If you want to do it in an effect of your own, there's two common ways of doing it.

  • Bind two textures and make a sample from both of them, followed by multiplying or adding them together in the pixel shader while computing the output colour.
  • Write an effect with multiple passes (assuming that XNA supports it), where the first pass draws the base opaque texture and the second pass draws the overlay texture with multiplicative or additive blending.
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .