Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by 7toni7 · Oct 21, 2014 at 06:00 PM · shadermeshcolorinterpolation

How to colour a mesh according a temperature/heat map?

Hi folks,

I have a mesh and my aim is to color it according a temperature/heat map. Specifically, I have a color value per each centroid of the different triangles in the mesh (the centroid of a triangle is its mean point). Therefore, I'd like to know how to properly color the entire mesh according these values, of course, interpolating between the different color values. Something similar to this effect:

alt text

Should I use any particular shader to represent this temperature map? Thank you very much for your help

$ramp.png (105.6 kB)
Comment
Add comment
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
1

Answer by robertbu · Oct 21, 2014 at 06:02 PM

Consider having a color per vertex instead of a color per triangle. Then you can use Vertex colors. The following answer has a section on vertex colors:

http://answers.unity3d.com/questions/795049/oafathow-do-i-changer-the-color-of-a-game-object.html

Comment
Add comment · Show 8 · 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 7toni7 · Oct 21, 2014 at 06:49 PM 0
Share

I understand robertbu...so, I should do 2 things: 1 - To specify the colors for each of the vertices in my mesh: link text 2 - To asign a material to my mesh that uses, for example, this shader: link text

Is this correct? Thank you very much!!

avatar image robertbu · Oct 21, 2014 at 07:02 PM 0
Share

Yes. You've got it. I'm not sure this specific shader is the one you need, but it is a place to start. If all you want is color, then the shader in the answer I gave you will work, but there are a number of other shader that support vertex colors around.

avatar image 7toni7 · Oct 21, 2014 at 09:57 PM 0
Share

Ok robertbu. The problem now is that I need it to be done per triangle, ins$$anonymous$$d of vertex. Is there any way to interpolate colors per triangles?

$$anonymous$$ind regards!!!

avatar image robertbu · Oct 21, 2014 at 10:24 PM 0
Share

Don't take my thoughts as gospel since this is not my area of expertise, but I don't know of anything in Unity that would allow you to map color to a triangle. Color is mapped to the vertices.

Some untried thoughts:

  • You could identify all the triangles that share each vertex. Then you could set the color of that vertex based on the average color of the triangles that share that vertex. If your mesh is irregular, you may have to weigh the color based on the distance the center of each triangle is from the vertex.

  • You could subdivide each triangle into three triangles using the center point of each triangle. This would give you a vertex at the center to assign a color to. You'd still have to interpolate the colors for the other (original) vertices.

avatar image 7toni7 · Oct 22, 2014 at 06:33 AM 0
Share

Thank you very much for your ideas robertbu. Do you know if any of the following codes will achieve what I need?

  • link text

  • link text

Thank you!

Show more comments

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

2 People are following this question.

avatar image avatar image

Related Questions

Change mesh color with shader or Mesh.colors? 1 Answer

colorize mesh based on dot product 1 Answer

Mesh brigthness changes depending on camera angle 1 Answer

Problem with coloring mesh with shaders properly 1 Answer

Need help with using world position in shader 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