B
B
Badou2015-03-03 17:49:25
Shaders
Badou, 2015-03-03 17:49:25

Shader in Unity3D, what is the point of multiplying rgb by alpha?

I'm looking at an article on shaders (I myself am a complete novice in this matter), there the following line is given as an example:

half3 starAlbedo = smallStars.rgb * smallStars.a 
                 + mediumStars.rgb * mediumStars.a 
                 + bigStars.rgb * bigStars.a;

I tried to remove the multiplication by alpha, I got an image in strange, multi-colored stains. Can anyone explain in simple terms the physical meaning of this work? or share a link where this issue is covered?
PS
smallStars, mediumStars, bigStars - half4 variables that store, as I understand it, information about the rgba channels of the texture pixel that is currently passing through the shader (there are 4 textures, one of which is not important for the question)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Basmanov, 2015-03-03
@Badou

Alpha itself has no meaning, it's just another channel for transmitting information. As the author of the shader wanted, such a meaning will be. In general, multiplying an rgb channel by a number affects the intensity of the color. White color multiplied by 0.5 will turn into gray, by zero - into black. Judging by the name of the variable, the formula considers the brightness of the starry sky, and alpha stores the weights of stars of different types, that is, the degree of their influence on the overall brightness.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question