Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I'm currently creating a voxel game like Minecraft. To display the damage of blocks, I want to combine the alpha channel of one part of my texture map with the actual texture (like Minecraft does), how could I do that in Unity?
\$\begingroup\$shader code: final_color.rgb = lerp(block_texture_color.rgb,damage_texture_color.rgb,damage_texture_color.a * damage_factor) and damage_factor is a float 0 or 1 depending if you want to see the block damaged or not (you can pass it trough alpha color from vertex color or via a uniform\$\endgroup\$
\$\begingroup\$Thanks for the code!, My problem is that my world is divided into chunks, as far as I know, you can only attach shaders to the entire chunk gameobject, how could I target only the damaged block?\$\endgroup\$
final_color.rgb = lerp(block_texture_color.rgb,damage_texture_color.rgb,damage_texture_color.a * damage_factor)anddamage_factoris a float 0 or 1 depending if you want to see the block damaged or not (you can pass it trough alpha color from vertex color or via a uniform \$\endgroup\$