Best way to render cracks on blocks

I create 2.5D game based on blocks. blocks of materials will have different strength as in http://kag2d.com/en/. How to render cracks, if they have a common material (shader) with atlas texture, each block type has own mesh and texture tile in Atlas? My chunks have 8x8 blocks - I want use batch factory.

http://0fps.files.wordpress.com/2013/07/terrain.png bottom left corner

Or you could use two textures, one for the normal textures and one for the cracks.

The shader would use the first texture ignoring vertex colour and then it would use the second texture to render cracks into it by blending in the value from the cracks texture using the vertex colour to pick the opacity.

(You could atlas both the first and second texture independently by using textcoord1 and textcoord2)

1 Like

One way is clone mesh when block has any damage? example:
TextureAtlas has 2 texture maps - diffuseColor, normals, diffuseColorMap has all cracks step textures(4 step - for 25% hp each).

  1. block dirt,100 hp, next block dirt 100 hp - one mesh 2 geometry nodes - mesh has only textcoord1 sets to dirt texture coords on atlas,
  2. player addDamage on block one, block has 50 hp - clone mesh, sets textcoord2 to 2 step of cracks.

Maybe i must precreate all meshes for each block type and crack step, sets only textcoords? 5 meshes for one block type?

Or use plane mesh with crack step texture and alpha blending, place on each block faces, 4 plane mesh and clone geometry node for each block faces - can it work ?

If not clear, i can expand more.

@javagame said: http://0fps.files.wordpress.com/2013/07/terrain.png bottom left corner

In minecraft only one block is cracking by player - is not permanently cracked, my game has cracking logic like Home :: King Arthur's Gold or http://7daystodie.com/

@Mararok said: In minecraft only one block is cracking by player - is not permanently cracked, my game has cracking logic like http://kag2d.com/en/ or http://7daystodie.com/

So? Same principal still applies, just assign the first texture when block health is between 100 & 75, 2nd texture when block is between 75 & 50 health etc
@zarch 's way is still probably better, if not more convoluted
I guess you should do it properly though if its a big part of the game

@Mararok said: One way is clone mesh when block has any damage? example: TextureAtlas has 2 texture maps - diffuseColor, normals, diffuseColorMap has all cracks step textures(4 step - for 25% hp each). 1. block dirt,100 hp, next block dirt 100 hp - one mesh 2 geometry nodes - mesh has only textcoord1 sets to dirt texture coords on atlas, 2. player addDamage on block one, block has 50 hp - clone mesh, sets textcoord2 to 2 step of cracks.

Maybe i must precreate all meshes for each block type and crack step, sets only textcoords? 5 meshes for one block type?

Or use plane mesh with crack step texture and alpha blending, place on each block faces, 4 plane mesh and clone geometry node for each block faces - can it work ?

If not clear, i can expand more.

Also Iā€™m not sure if this is a good idea, you want to render two blocks in the same place, one with cracks on and one with normal textures on from what I understand. I believe this will cause terrible artifacts.

Just have one block, and set a different texture to it depending on the health, or do what zarch said and assign two textures, the cracks texture having a different opacity depending on the health.