Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 morelek337 · Apr 06, 2021 at 05:30 PM · coloralphadocumentationbehaviourbehavior

Using Color's alpha channel with value greater than one provides odd result

Hello everybody.

I have stumbled upon non-documented issue (as far as I searched documentation, internet, and this answers.unity.com page).

When a cube (in my case it's a cube) is given alpha bigger than one, its colours change. This is odd, because documentation states: "alpha component (a) defines transparency - alpha of one is completely opaque, alpha of zero is completely transparent." So I would expect alpha bigger than one to be truncated to one or at least provide me with error. However what happens is the cube changes its colour.

Please look at provided screenshots. 1) Renderer.material.color = new Color(0.5f, 1.0f, 0.3f, 1f); https://ibb.co/KXTwNC1 2) Renderer.material.color = new Color(0.5f, 1.0f, 0.3f, 2f); https://ibb.co/5FJbVfj 3) Renderer.material.color = new Color(0.5f, 1.0f, 0.3f, 275f); https://ibb.co/LkGLKLS

Could someone provide me with insight if is that some behaviour described anywhere? Or what is it? Thank you

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
0
Best Answer

Answer by Namey5 · Apr 07, 2021 at 08:30 AM

The alpha channel isn't automatically truncated because some uses may require values outside of a [0,1] range, even though that may not be required here. As for why the colour changes as the alpha moves outside of the expected range, you would need to look at the blending operation in use that is giving you transparency in the first place.

In the case of a general 'fade' transparency, the blending operation would be;

 Blend SrcAlpha OneMinusSrcAlpha

What this translates to behind the scenes is;

 // Where;
 // - SourceColour: the colour of our object
 // - SourceAlpha: the alpha of our object
 // - DestinationColour: the colour of the scene behind our object
 (SourceColour * SourceAlpha) + (DestinationColour * (1 - SourceAlpha))

 // or alternatively
 Lerp (SourceColour, DestinationColour, SourceAlpha)

If you have a value between [0,1] you can see that the colour resulting from the blend would lie somewhere between the two inputs. However if the alpha has a value outside of that range, then an imbalance in colour would be introduced and you would start extrapolating beyond the input colours.

Comment
Add comment · Show 1 · 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 morelek337 · Apr 07, 2021 at 06:23 PM 0
Share

Oh, thanks a lot @Namey5 , that explains it to me. And, for anybody else, there is info in documentation apparently; I haven't yet read through, but here is something: https://docs.unity3d.com/Manual/SL-Blend.html

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

115 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 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

Unity documentation says to use StartCoroutine() method for visible fading of renderer alpha but the following method works fine without StartCoroutine() with visible intermediate values. Is this way also right ? 1 Answer

Why does the script act completely wrong? 0 Answers

Renderer.material not cloning? 3 Answers

guiTexture color half alpha White? 1 Answer

Acces the secondary colors in the shaders. 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