- Home /
Something about Render Texture Transparent..
I want to use a second camera to draw my character into a render texture. And whatever I set the background colorsI always get the texture that is my character with white background colors. How can I set my background colors to be transparent,and only show my character in the texture, which for my the GUI Showing. Thanks! And Sorry for my poor English!
Answer by qJake · Aug 04, 2010 at 04:33 AM
I think you want to set the Clear Flags of the RT Camera to not clear everything. This should only make it draw your character, and not the background, too.
Clear Flags
Each Camera stores color and depth information when it renders its view. The portions of the screen that are not drawn in are empty, and will display the skybox by default. When you are using multiple Cameras, each one stores its own color and depth information in buffers, accumulating more data as each Camera renders. As any particular Camera in your scene renders its view, you can set the Clear Flags to clear different collections of the buffer information.
http://unity3d.com/support/documentation/Components/class-Camera.html
Thanks SpikeX. There are only 4 options of clear flags I can select. Do you mean the "Don't clear" Flag?
Whichever one works for you, if there's only four it's not hard to test.
So I'm attempting exactly the same thing. I'm trying all settings of the Clear Flags field but none are removing the background from my render texture. If I set the alpha value of the render camera's background color, I can only make the entire texture, including objects the cam is rendering, uniformly transparent.
If I use the "Depth Only" setting, I get garbage in the render texture during playback.
Have done thorough searching on Answers and Forum but not finding anything helpful.
Did you ever find a solution for this?
I'm in the same situation myself right now.
This may not help you now, but it may help someone else.
I turned off HDR and it made it work, though the texture was a little blurry. Not sure how that works, but it gave me the effect I needed.
Answer by Waz · Jul 07, 2011 at 01:43 AM
I've had problems with this and one issue is that some shaders have a Colormask of RGB only, not RGBA. Certainly you need to start with clear flags of SolidColor and the color having alpha of zero.
In my specific case, I also rendered my camera twice, once with a custom replacement shader that only wrote to alpha channel, but you might not need this, depending what shaders you are already using.
But if you happen to be using the render texture in a GUItexture, then you're stuck with whatever the Clear Flags options give you, right?
Your answer
Follow this Question
Related Questions
Rendering issue on iPhone 1 Answer
Trees in distance show as black without texture 1 Answer
Generating UVs for a scripted mesh 4 Answers
Tiled GPU perf warning? 1 Answer
transparent texture problem 3 Answers