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
1
Question by Sevdanski · Aug 12, 2014 at 04:09 AM · post processingimage effectsblendingmultiple cameras

How do I apply an Image Effect to only one camera?

I'm working on the interface for a game and I want to apply a post effect to the UI elements whilst leaving the image in the background unaffected.

I have set up the background and the UI elements to use separate cameras with different depths. That all looks fine. When I apply an image effect using OnRenderImage like this:

 void OnRenderImage(RenderTexture source, RenderTexture destination)
 {
     Graphics.Blit(source, destination, material);
 }

The shader / effect also distorts the background. This makes sense when you consider that the output of all the previous cameras are probably being fed in.

Next I tried manually calling the UI Camera's Render() method manually from a script I put on the background, and then blitting it to the destination like this:

 // Called by camera to apply image effect
 void OnRenderImage(RenderTexture source, RenderTexture destination)
 {
     // render the background in straight away
     Graphics.Blit(source, destination);
 
     // user temporary texture
     if(rt!=null)
     {
         RenderTexture.ReleaseTemporary(rt);
         rt=null;
     }
     rt =  RenderTexture.GetTemporary(Screen.width, Screen.height, 16);
     UICamera.targetTexture = rt;
     UICamera.Render();
 
     Graphics.Blit(rt, destination, material);
      
 }

At a glance that looked like it was working, but on closer inspection the blending didn't look right. I have some semi transparent black boxes that seem to disappear when I do this. I believe that the Clear Flags are having an effect on this, but I can't quite figure it out.

Other things I have tried was trying to render the background to a Render Texture and then feeding that texture into the shader I am using to process the foreground. I was blending it based on the alpha value of the UI, but I ended up getting the exact same result as my earlier code.

I've tried using different combinations of blend modes as well, but nothing seems to work the way I want.

Any help would be greatly appreciated.

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

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

22 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

Related Questions

Best approach for alpha blending multiple webcamtexture is renderTexture? 0 Answers

Cutting a hole in the camera 0 Answers

Render Splitscreen to RenderTexture 0 Answers

In FastBloom(Bloom Optimized) shader, what's the difference between Standard and Sgx blur type? 0 Answers

Multiple cameras blur effect problem 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