Separate blend modes for alpha and color

Hi. In the unity documentation here http://docs.unity3d.com/Documentation/Components/SL-Blend.html it says you are able to set different blend factors for alpha and color channels. When I try giving the shader more factors nothing changes. The first two factors are used but the second two are ignored completely. Blend SrcAlpha OneMinusSrcAlpha, DstAlpha OneMinusDstAlpha is no different from Blend SrcAlpha OneMinusSrcAlpha. I can't find any examples of this being used and have no idea what I could be doing wrong. Has anyone come across similar problems?

more ▼

asked Aug 19, 2013 at 11:09 AM

avatar image

11 4 5 8

I'm seeing the same rendering results with Blend SrcAlpha OneMinusSrcAlpha, SrcAlpha OneMinusSrcAlpha and Blend SrcAlpha OneMinusSrcAlpha, Zero Zero.  I think it's broken.

Sep 13, 2014 at 06:24 AM slippdouglas
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The specific values you're using won't ever show a difference. You'd have to be using DestAlpha for the colors, and have three+ overlapping textures. The third one would have the change. A rundown:

Commonly you ignore the alpha of the screen pixel, which means there's no point caring about alpha blend factor. Using SrcAlpha OneMinusSrcAlpha means that a fog pixel with an alpha of 20% will blend 20/80 with the background pixel. That's normally what you want. Even if the background was a complex combo of glass and fog, yellow 20% fog over it will tint it 20% towards yellow.

Now, the new alpha probably be 100%*80% + 20%*20% = 84%. That's a stupid value, but who cares, since no one will ever look at it. The next fog plane will use it's own alpha/1-alpha.

Say you were using DestAlpha OneMinusDestAlpha for the blend. Then the base pixel's alpha would control the final color. It's hard to think of a time you'd want that. Since, look at any transparent texture and think about swapping in a different alpha channel. Ick.

But, if you did, then after blending two textures, you'd have a new Alpha in that pixel, which the next DestAlpha OneMinusDestAlpha would look at. So you might use DA OmDa Sa OmSa, to make a chain letter: "I ignore my alpha when I blend with something (I use yours,) but the next guy has to use mine."

more ▼

answered Aug 19, 2013 at 01:39 PM

avatar image

Owen Reynolds
27.9k 5 39 105

(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



Answers and Comments



asked: Aug 19, 2013 at 11:09 AM

Seen: 903 times

Last Updated: Sep 13, 2014 at 06:24 AM