Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by daleran · Sep 13, 2016 at 03:23 PM · shadermaterialsdamageprocedural meshcg

Selectively drawing textures on a mesh to represent damage using a shader

I am working on a 2D tile based spaceship building game and I need to find the best way to model damage to the tiles. The ships are a basic procedural 3D mesh made up of quads of different basic shapes (slope, corner, flat, etc..) to allow semi-realistic lighting and shadows with the standard shader. It is textured using a single texture tile atlas material with all the different diffuse, normal, emissive, etc. maps. The tile graphic is picked by changing the vertices UV coordinates depending on tile type.

Now I need a way to simply model damage without having to draw a bunch of different damaged tiles for each bit of damage it can receive. I would like to use just one damaged tile texture and blend the two based on the health of the tile or have some kind of mask that would render one part of the texture transparent and display the damaged tile underneath. Here is a sample from my texture atlas for what I am trying to achieve:

The undamaged and damaged hull tiles: TileAtlasSample The effect I am trying to achieve: DamagedTile

Is this possible using a shader? Before I spend a significant amount of time learning CG I want to see if my line of thinking is correct. I would like to have a material with a custom modified standard shader that has a slot for a damage texture and damage normal map as well as a black and white damage mask/map texture that would tell the shader whether to draw the undamaged tile pixel, damaged tile pixel, or a transparent pixel. The mesh would store which damage mask uv to use in uv2 or uv3 or whichever uv set is available. This way the damage script in my game can select a damage graphic by just changing the uv2 for the damaged tile. Is this something that can be done in a unity shader or is they a better way of doing this?

78064-dmgexample-damaged.png (1.4 kB)
78063-dmgexample-tiles.png (2.3 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ByteSheep · Sep 13, 2016 at 04:52 PM 0
Share

Yep, sounds like a custom shader is the way to go. I'm not aware of any builtin features that would let you accomplish this effect on a 3d mesh, though it may be worth searching the web for existing solutions first.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

74 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Passing custom vertex attributes to cg shader 0 Answers

How to force the compilation of a shader in Unity? 5 Answers

TEXCOORD 0 1 2 3 for cg shader scripting? 1 Answer

Multiple tex2D commands in fragment shader needed, is there a workaround? 0 Answers

Custom ambient lighting color in a Cg shader 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges