x


Alpha Value of the Background Color

I've got a quick question.

alt text

I've tried changing the alpha value of the background to make my GUI semi-transparent, but it didn't work. Has anyone tried this before? Is the camera supposed to ignore this alpha value?

more ▼

asked Aug 27 '10 at 07:29 AM

Kijun gravatar image

Kijun
98 14 14 24

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

2 answers: sort voted first

An alpha value does not necessarily equate to transparency; it's just something that it's used for a lot. The camera does indeed use whatever you set as its background color's alpha value. Here's a shader you can use to prove this to yourself (the alpha value of the Scene View camera's background is black, so test this in the Game View):

Shader "Camera Background Alpha" {

SubShader 
{   
    Blend DstAlpha Zero
    Color (1,1,1)
    Pass {} 
}

}

You can't use this for transparency (blending). Blending would require a shader, and this is just a solid color, not something you can manipulate the blending of. Most likely, what you want to do is set your camera to "Depth Only", and use a transparent shader on your GUI items.

Here's something I use to make a solid-colored transparent overlay that goes behind GUI buttons, but blends into another camera (it "darkens" the main camera for the pause menu). It might be the kind of thing you're looking for, but may need to be tweaked for your purposes. My buttons are non-blended rectangles, for example. You'd need a slight alteration if your buttons need transparency, such as for rounded corners.

Shader "Pause Overlay" {

Properties 
{ 
    _Color ("Color", Color) = (0,0,0,.5)
} 

SubShader 
{
    Offset 0, 1 // behind the buttons
    Blend SrcAlpha OneMinusSrcAlpha
    Color [_Color]
    Pass {} 
}

}
more ▼

answered Aug 27 '10 at 08:31 AM

Jessy gravatar image

Jessy
15.6k 72 95 196

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

Just a quick one for no background

mySecondaryCamera.clearFlags = CameraClearFlags.Nothing;

This will leave colors and depth buffer from the previous frame or whatever was displayed before

more ▼

answered Feb 15 '11 at 04:43 PM

Jorge Solis gravatar image

Jorge Solis
1

(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:

x3692
x3008

asked: Aug 27 '10 at 07:29 AM

Seen: 3058 times

Last Updated: Aug 27 '10 at 07:29 AM