pre-multiplied Alpha

reference-http://www.td-grafik.de/ext/xfrog/alpha/index.html

main reason for it's appearance:for the problem ----the alpha value resulting the  render color value wrong 

 

1) 1.we have a texture - its' alpha is 0.5  so we just blend the origial color of what we want to show and the background color of the texture.

in this texture , let's set the original color(0,255,0)(green) and the background color (255,255,255)(white)

so we can calculate the result(127,255,127)-----just use the alpha mutiplyied it and add them

       (0,255,0)*0.5+(255,255,255)*0.5 = (127,255,127)

the result is the format of the texture stored

2. for the  render process

we set the targetresource is (0,0,0),so we can calculate  the result

       (originalColor.R,originalColor.G,originalColor.B)*0.5 + (TargetColor.R,TargetColor.G,TargetColor.B)

 =    (127,255,127)*0.5 + (0,0,0)*0.5 = (63,127,63) 

 we want the result from (0,255,0) to (0,0,0)  just (0,127,0), but the result (63,127,63) has Red component and Blue component make the color wrong  . we just want make the originalColor and the TargetColor more Efficentive , not be confused by the BackgroundColor

so how can we get rid of it ?

2) pre-Muiltiplying 

   first of all we must set the texture background color (0,0,0)(black),so we can avoid the influence of the texture background color  

    so we can conclude the express

     (0,255,0)*0.5+(0,0,0)*0.5 = (0,127,0)

 then rendering 

     we can set the Target color (255,255,255)(white)

     (0,127,0)+(255,255,255)*0.5 = (127,255,127)

    the result is more  like the (0,255,0) and feelig so bright 

     this is the design of the preMutipying 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章