x


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!

more ▼

asked Aug 04 '10 at 02:53 AM

Jackey gravatar image

Jackey
16 1 1 4

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

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

more ▼

answered Aug 04 '10 at 04:33 AM

qJake gravatar image

qJake
11.6k 43 78 161

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.

Jul 07 '11 at 12:45 AM Barrett Fox
(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Jul 07 '11 at 01:43 AM

Waz gravatar image

Waz
6.4k 22 33 71

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?

Jul 07 '11 at 07:21 PM Barrett Fox
(comments are locked)
10|3000 characters needed characters left

Thanks SpikeX. There are only 4 options of clear flags I can select. Do you mean the "Don't clear" Flag?

more ▼

answered Aug 04 '10 at 06:57 AM

Jackey gravatar image

Jackey
16 1 1 4

Whichever one works for you, if there's only four it's not hard to test.

Aug 04 '10 at 08:15 AM qJake
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2199
x266
x178

asked: Aug 04 '10 at 02:53 AM

Seen: 4519 times

Last Updated: Jul 07 '11 at 07:21 PM