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 /
avatar image
0
Question by vandrewm · Aug 11, 2011 at 07:37 PM · rendertexturealpha

Objects in RenderTexture render with black alpha value

I've come across a problem that I believe came up in the latest update, but I cannot be sure.

My RenderTexture from the camera has an alpha channel that is completely black, even though there are completely opaque objects (with diffuse shader applied) that is rendered into it. How can I get the RenderTexture to have an alpha channel that reflects what is really rendered? For example, If I have a diffuse sphere in the camera's view, I want the alpha channel to be white where the object is.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Waz · Aug 11, 2011 at 11:37 PM

The problem is that most of Unity's shaders do not write to Alpha channel at all. They have:

 ColorMask RGB

in them. I've had the same problem when rendering icons that should have alpha written, and rather than change all the shaders, I just render them a second time with a replacement shader that writes to the alpha, thus siloetting the object. The problem gets worse when you want to draw transparent stuff.

Comment
Add comment · Show 4 · 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 vandrewm · Aug 12, 2011 at 12:22 AM 0
Share

I guess that makes sense. I'm curious why Unity decided to change this to RGB from RGBA. Is there some sort of performance benefit to not rendering the alpha?

avatar image Waz · Aug 12, 2011 at 12:40 AM 0
Share

I don't think it's a recent change. I noticed it at least in 3.2. There would be a small performance advantage on some hardware. Personally, it seems a wrong optimization, but I'm no expert in Shader costs.

avatar image Owen-Reynolds · Aug 12, 2011 at 02:28 PM 0
Share

Someone wrote here that at least one of the cell-phone GPUs uses hardware scalars ins$$anonymous$$d of Vector4s. If so, a big 25% (speed and memory?) increase for them. Well, unless they have their own shaders?

avatar image DenisM · Aug 05, 2014 at 09:43 AM 0
Share

I have the same problem in 4.3 unity. Any solutions without replacing shaders? or at least some code of replacing shader?

avatar image
1

Answer by Molix · Aug 11, 2011 at 11:09 PM

This post may be what you need: http://forum.unity3d.com/threads/2065-Render-Texture-Alpha?p=23802&viewfull=1#post23802

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Shader to render RenderTexture plus alpha? 1 Answer

How do you get a rendertexture with the camera's alpha onto a GUItexture? 1 Answer

Alpha values not blending in RenderTexture 2 Answers

Transparent shader: final alpha value wrong 2 Answers

Unity RenderTexture displays transparency when the front-most sprite contains alpha 0 Answers


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