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
0
Question by Dainiusss · Mar 31, 2015 at 06:03 PM · 2dshadermeshcolormixing

Problem with coloring mesh with shaders properly

Hello, everyone. I am making a 2d digging game. At this time I am trying to make an effect, which darkens my vertices of the mesh, by the distance they are from empty mesh squares (photos below). The problem is that I get some not proper color mixing in the corner squares. The soft diagonal line, seen in the corner squares can be the result of the squares division by two triangles (this is due to manualy (by script) generated mesh. I use Sprites/Default shader, because it can support this vertice coloring. ...Is there a way to solve this, to get a nice and smooth color mixing?

Notice the corner squares!

alt text

alt text

P.S. when I use different shader, which does not support this vertice coloring, console gives me a notification - "Shader wants tangents, but the mesh doesn't have them". I do not do any actions with tangents. Maybe I should do someting, to use other shaders? If you have some knowledge and expierence about this stuff, please, help me to solve this problem.

Thanks .

problemayra2.png (14.2 kB)
problemayra3.png (24.6 kB)
Comment
Add comment · Show 2
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 maccabbe · Apr 01, 2015 at 08:11 PM 1
Share

You could check adjacent cells and generate the triangles in a different orientation based on how they will be lit.

Another solution would be to use a shader which calculates the color per fragment ins$$anonymous$$d of per vertex.

avatar image Dainiusss · Apr 01, 2015 at 08:16 PM 0
Share

Thanks, today I did the first method you just said there, but it still does not look perfect, because on the corner square one triangle is colored, but another is not. Do you know something more about the second method you told? Some article or what to search for? It's first time I hear something about this type of shaders. Thanks again.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Dr_Who · Oct 26, 2015 at 09:43 AM

I'm very new to Unity but I have had some skill with modeling meshes. In my experience, when using vertex based shading, the only way to improve quality is to up the vertex count. So try subdividing your mesh a couple of times and it should look better. However, the only way to get a perfectly smooth line without major impact on performance is to use fragment shading like @maccabbe said which is unfortunately beyond my knowledge. I hope this is still of use to @Dainiusss or it helps someone.

Comment
Add comment · 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

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

20 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

Related Questions

Cancel out mesh alpha 1 Answer

Changing vertex colors and mesh leak fix 1 Answer

Material doesn't have a color property '_Color' 4 Answers

Hiding part of mesh 0 Answers

How to efficiently render a 2D grid? 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