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 jthomCMM · May 30, 2014 at 07:14 PM · rendertexturepaintunlittransparent-texture

How to Alpha Blend a RenderTexture with objects behind it?

I have seen some similar questions asked but none of them seem to have quite this issue. I'm hoping I can get some insight into this. Basically, I'm trying to make a little paint program where a user can select a background and paint over the top of it (not into it). So far I have been able to successfully write to a render texture and apply that to a quad over the top of my background quad. The painting works ok but I can't seem to figure out the alpha blending. I apologize if this isn't clear. I'm quite new to shader programming but I'll try to explain anything that isn't clear.

So a quick rundown of the process I'm using:

1) Using Graphics.Blit() I blit a fully transparent texture into the RenderTexture once at the start of the app.

2) When paint is applied with the mouse I set my RenderTexture as active.

3) Then I draw the brush textures into RenderTexture using Graphics.DrawTexture() and reset the active render texture to null.

4) Finally I apply an Unlit shader to blend the RenderTexture with the background image.

I'm using an unlit shader with alpha blending using:

 Blend SrcAlpha OneMinusSrcAlpha

I can post the full shader if needed but it's basically Unity's standard Transparent Unlit Shader. The problem seems to be that when I blend the RenderTexture I'm getting very low alpha values and the paint appears much more transparent than it should be.

I also tried using AlphaTest:

 AlphaTest Greater 0

This has a slightly better result but it seems to produce black outlines around the paint textures which I'm guessing also has to do with the low alpha values.

The thing that puzzles me is that the RenderTexture preview in Unity looks correct. Here is an image of my results and one of the brush I'm using.

Blending

alt text

Brush

alt text

If anyone can provide some insight on how to properly blend a RenderTexture I would greatly appreciate it, thanks!

brush.png (2.7 kB)
alphablendingrendertexture.jpg (333.8 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
0

Answer by AKWolf · Jun 27, 2014 at 05:46 PM

Check out this answer: http://answers.unity3d.com/questions/525188/transparent-shader-final-alpha-value-wrong.html

I was having the same problem. Using a separate blending mode for the alpha as suggested above worked for me!

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

21 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

Related Questions

How can I draw persistent trails with particles? 1 Answer

Painting on Textures at Runtime? 2 Answers

RenderTexture.active for a non-VR camera in a VR project 0 Answers

Performant Alternative to render texture? 1 Answer

Cube-type RenderTexture (NOT the Cubemap) to png file 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