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 Jacktang · Feb 07, 2012 at 08:03 PM · shaderrendertextureblit

Graphics.Blit with an additive shader

Hey, I'm trying to implement the ability to paint on a texture with a particle effect. What I've done is I've set up a camera that renders my particle effect to a renderTexture. What I want to do is copy the contents of that RenderTexture to a secondary texture, without clearing what has been rendered in previous frames from that secondary texture, so in effect, wherever I paint with my particle is permanently baked into my secondary texture.

I've tried setting my cameras clear flags to "Don't clear", but that doesn't seem to work for some reason. I may need to revisit that option down the road. But the other option I'm more interested in is using Graphics.Blit with a custom shader for an additive post processing effect. I'm not sure if this option will function the way I want it to though. When using Graphics.Blit, is it possible for me to combine the source texture and the dest texture using an additive shader?

Thanks!

Comment
Add comment · Show 4
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 Jessy · Feb 07, 2012 at 08:08 PM 0
Share

I don't understand why you'd need a fixed function blending operation. If you have two textures, add them in the shader.

avatar image Jacktang · Feb 07, 2012 at 08:36 PM 0
Share

I confess I know very very little about shaders, so forgive my ignorance on these things. I guess I was ultimately asking how to go about doing what you suggest. I've tried digging into some shader operations a bit, and I've discovered that it seems to be quite easy to add two textures together, but I don't know how to gain a reference to the source and dest textures that I pass into the Graphics.Blit function, and then store the results in the destination texture. Am I going about this in the wrong way? I ultimately need to use the destination texture as an alpha mask.

avatar image Jessy · Feb 07, 2012 at 08:50 PM 0
Share

Sounds like you're on the right track. I only have experience running post process effects on the entire screen, though, so can't offer up any code, presently. For fullscreen effects, it's basically as simple as using the + operator.

avatar image Jacktang · Feb 07, 2012 at 09:21 PM 0
Share

I'm just not entirely sure what I stick that + operator between. I create a brand new shader, but I don't know how to get a reference to my two textures into the shader so that I can add them together.

1 Reply

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

Answer by Jacktang · Feb 24, 2012 at 04:34 PM

I figured out that I can use Material.SetTexture to make them available in the shader

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

dynamic hole in layer / texture / camera 0 Answers

Blit isn't writing to render texture 1 Answer

Multiple Blit problem 2 Answers

Blit shader to RenderTexture results in solid black 0 Answers

Prevent Render Texture clearing 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