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 /
  • Help Room /
avatar image
0
Question by sourav13 · Jul 15, 2016 at 12:52 PM · color changecolor.lerp

Can we colour a part of the Sprite .

I am having a white sprite of some shape what i want is to give different colour to half of it and different to half . which component i could use for doing that. Or if we can't do it with spriteRenderer ,any other component that would help me . I have never gone for colouring uv or vertices ,is that what is required , i just want a direction any tutorial or guide will be nice.

Comment
Add comment · Show 7
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 _Yash_ · Jul 15, 2016 at 01:15 PM 0
Share

Yes, you have to split UV in half and color both half saperately. This can be done by creating fragment shader. To get started copy the UnlitColorShader and change it's fragment function.

avatar image sourav13 _Yash_ · Jul 15, 2016 at 02:58 PM 0
Share

What other shader would best suite me , On mobile platform as my scene is not much effected by lighting .

avatar image sourav13 _Yash_ · Jul 15, 2016 at 03:11 PM 0
Share

@Yash Sorry ,for the silly question but how do i write this fragment function . I mean i gave the material an unlit shader , can get the shader component or i have to write some class for shader , Can you refer some resource or guide for that .

avatar image Owen-Reynolds · Jul 15, 2016 at 03:27 PM 0
Share

Are the halves always made the same way, like always left and right? If so, seems simpler to make a sprite for each half. Can custom color each version, to make it look nice (ex: green Sue has a green shirt and hair, but not green skin.)

Then, there are tricks, like putting a semi-transparent red square over one half.

avatar image sourav13 Owen-Reynolds · Jul 15, 2016 at 04:30 PM 0
Share

No the halves are not always made the same way . Infact i'm gonna try different proportions not just halves.

avatar image _Yash_ sourav13 · Jul 15, 2016 at 05:23 PM 0
Share

okey, so as you want your halves to be of any shape, you should use mask texture, it is a texture which will say which part will be of which color. for example if mask texture is black and white you can tell shader to effect all white part with red(or any color) and black with blue(or any color).
$$anonymous$$ching you about fragment shader will be out of scope for this comment but refer to unity's vertex shader documentation and start from there.
what you need to do in fragment shader is: get a color from real/sprite texture(sc) -> get a color from mask texture(mc) -> if mc is white multiply sc with your color1 else multiply sc with color2 -> return that color (fragment functions return color).

Good luck

avatar image Owen-Reynolds · Jul 15, 2016 at 05:42 PM 0
Share

I feel silly for not writing this before: searching for "unity color part of sprite" brings up other answered Qs about this.

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

49 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

Related Questions

How to change the camera background colour with player height. 1 Answer

Why Color.Lerp or Color32.Lerp doesnt work properly? 1 Answer

Is there any way to make a gradient within unity?,Is there any way to make a gradient? 1 Answer

Time.deltaTime getting faster each time 2 Answers

How to make RANDOM COLOR on 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