본문 바로가기
Game Programming

컬러 믹싱 알고리즘

by 게임혼 2009. 7. 27.

구글을 돌아다니다 보니 좋은 내용이 있었다.

http://www.vanderlee.com/tut_fm_mixingmodes.html


Normal
color = top

Dissolve
Requires an alpha channel.

Multiple
color = ( bottom * top ) / 255

Screen
color = 255 - ( ( 255 - bottom ) * ( 255 - top ) ) / 255

Overlay
color = bottom < 128 ? ( 2 * bottom * top ) / 255
                     : 255 - ( 2 * ( 255 - bottom ) * ( 255 - top ) / 255 )

Soft light
The soft light algorithm is not perfect yet.

Hard light
color = top < 128 ? ( 2 * bottom * top ) / 255
                  : 255 - ( ( 2 * ( 255 - bottom ) * ( 255 - top ) ) / 255 )

Color burn
color = top <= 0? 0 : max(255 - ((255 - bottom) * 255 / top), 0)

Color dodge
color = top >= 255? 255 : min(bottom * 255 / (255 - top), 255)

Darken
color = min( bottom, top )

Lighten
color = max( bottom, top )

Difference
color = dif( bottom, top )

Exclusion
color = 255 - ( ( ( 255 - bottom ) * ( 255 - top ) / 255 ) + ( bottom * top / 255 ) )