• 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
Question by CaptainChristian · Sep 26, 2013 at 05:51 PM · mesh verticesmesh manipulationmesh color

Modular/Procedural Visibility of Meshes

Hi,

I would like to show/$$anonymous$$de parts of a mesh. As an example t$$anonymous$$nk of a building that is placed, w$$anonymous$$ch $$anonymous$$des 90% of the structure on placement. Each time the building is being worked on, some percentage is revealed. How do I ac$$anonymous$$eve somet$$anonymous$$ng like t$$anonymous$$s?

Best wishes.

Comment

People who like this

0 Show 0
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

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by robertbu · Sep 26, 2013 at 06:26 PM

There are a number of different possible solutions. If you are talking about a 3D object, then there is an additional hurdle to overcome. Meshes are one sided. Most shaders cull out back sides. So imagine you had a box with the top off. If you look down inside the box you won't see the insides...you will see through the box. A typical solution is to modify the shader to turn the culling off. T$$anonymous$$s will display both sides, but it will display both sides as lit from the front side. So you lighting may not look right.

Here are some ideas. Some are "in theory" since I've never written the specific code or used the specific concept.

1) Use a mask

There are shaders that use a mask and a cutoff. You can create a mask to along with your textures. In the shader you change the cutoff to reveal more the building. T$$anonymous$$s answer uses t$$anonymous$$s method in 2D for a circular progress bar:

http://answers.unity3d.com/questions/14770/creating-a-circular-progressbar-timer.html

2) Different materials

If you want your building to go up in stages, then you can define the different parts of your building to have different materials. Then at runtime, you modify the alpha of the main color for each material to expose different areas. T$$anonymous$$s requires a shader that supports transparency and has a main color.

3) Texture atlas and changing UV

T$$anonymous$$s one is a bit more complex. It assumes you are using a texture atlas for mapping the texture onto the building. You can dynamically change the uv in the material to point to different parts of the atlas. Parts that have not be exposed, point to a part of the atlas that is clear. As they are exposed, uvs are changed to another part of the texture.

4) Vertex colors

Using a shader that supports vertex colors and transparency, you can change the vertex colors in the material.

5) Custom shader

You can write a shader based on a parameter only show part of the pixels (based on height for example).

6) Direct manipulation of the texture.

You can directly modify the texture used in the material and alpha values.

I'm sure there are more ways.

Comment

People who like this

0 Show 5 · Share
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 CaptainChristian · Sep 27, 2013 at 08:40 AM 0
Share

Thank you.

I guess the first one is the easiest for me to do, since I am not a technical guy. I rather focus on game mechanics and logic. Number 2 is probably easy to do too, but got more overhead the more buildings I am using in my project. 5 and 6 are also worth looking into.

avatar image Hoeloe · Sep 27, 2013 at 08:50 AM 0
Share

If you are working with culling turned off, and want correct lighting, I have a shader pack on the asset store that renders only the faces that are usually culled, and does so with correct lighting. https://www.assetstore.unity3d.com/#/content/11351

avatar image CaptainChristian · Sep 27, 2013 at 08:57 AM 0
Share

Which steps do I need to take in order to get it fully working using your assets?

avatar image Hoeloe · Sep 27, 2013 at 09:02 AM 0
Share

Well, it's quite simple. Mesh renderers have a setting for a materials array. By setting that to length 2, you can assign two materials to the same mesh. One of these will be the normal material, and the other will be the Inverted version found in my shaders. This will draw both faces (note that the renderer will have to draw the object twice to do this, so it will be more expensive). My shader calculates the correct lighting for the back faces automatically, so it will look like a correctly lit, 2-sided object. There is an example of a two-sided mesh in the demo scene, which you can look at if you have any trouble.

avatar image CaptainChristian · Sep 27, 2013 at 09:09 AM 0
Share

Thanks. I will knock myself out given your asset and the answer from robertbu.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

How I can get InteractiveCloth vertices and apply to MeshFilter 0 Answers

Animating the Mesh Morpher on function call. 0 Answers

Line of Sight using Mesh ,Line of Sight Mesh 2 Answers

Perlin Noise on Torus Terrain? 0 Answers

How to simulate drilling/welding/cutting a mesh? 1 Answer


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