Jump to content

Merge Modes


MakinMagic

Recommended Posts

Hi - could we please have more merge modes ?

These would do nicely :

color func Merge(color pbottom, color ptop)

if @p_modeselect=="MMF Merge Modes"

if @clamp

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if r<0.0

r = 0.0

elseif r>1.0

r = 1.0

endif

if g<0.0

g = 0.0

elseif g>1.0

g = 1.0

endif

if b<0.0

b = 0.0

elseif b>1.0

b = 1.0

endif

ptop = rgba(r,g,b,alpha(ptop))

r = red(pbottom)

g = green(pbottom)

b = blue(pbottom)

if r<0.0

r = 0.0

elseif r>1.0

r = 1.0

endif

if g<0.0

g = 0.0

elseif g>1.0

g = 1.0

endif

if b<0.0

b = 0.0

elseif b>1.0

b = 1.0

endif

pbottom = rgba(r,g,b,alpha(pbottom))

endif

if @p_mmfmergemode=="Exclusion"

return rgba(red(pbottom) + red(ptop) - 2*red(pbottom)*red(ptop), \

green(pbottom) + green(ptop) - 2*green(pbottom)*green(ptop), \

blue(pbottom) + blue(ptop) - 2*blue(pbottom)*blue(ptop), \

alpha(ptop) )

elseif @p_mmfmergemode=="Fade Down"

return rgba( red(ptop) * (1 - red(ptop) + red(pbottom)), \

green(ptop) * (1 - green(ptop) + green(pbottom)), \

blue(ptop) * (1 - blue(ptop) + blue(pbottom)), alpha(ptop) )

elseif @p_mmfmergemode=="Fade Up"

return rgba(red(pbottom) + red(ptop)*(red(ptop) - red(pbottom)), \

green(pbottom) + green(ptop)*(green(ptop) - green(pbottom)), \

blue(pbottom) + blue(ptop)*(blue(ptop) - blue(pbottom)), \

alpha(ptop) )

elseif @p_mmfmergemode=="Contrast Down"

return rgba( 0.5 + red(ptop)*(red(pbottom) - 0.5), \

0.5 + green(ptop)*(green(pbottom) - 0.5), \

0.5 + blue(ptop)*(blue(pbottom) - 0.5), alpha(ptop) )

elseif @p_mmfmergemode=="Contrast Up"

float r = red(pbottom)

float g = green(pbottom)

float b = blue(pbottom)

if r<0.5

r = r - 2.0*red(ptop)*r*(0.5 - r)

else

r = r + 2.0*red(ptop)*(1.0 - r)*(r - 0.5)

endif

if g<0.5

g = g - 2.0*green(ptop)*g*(0.5 - g)

else

g = g + 2.0*green(ptop)*(1.0 - g)*(g - 0.5)

endif

if b<0.5

b = b - 2.0*blue(ptop)*b*(0.5 - B)

else

b = b + 2.0*blue(ptop)*(1.0 - B)*(b - 0.5)

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Dodge"

; Here we clamp the maximum returned to 1.0 because of the special case

; when the color channel in ptop is one (or more).

float r = 1.0 - red(ptop)

float g = 1.0 - green(ptop)

float b = 1.0 - blue(ptop)

if red(pbottom)<=0

r = 0.0

elseif r<=0.0

r = 1.0

else

r = red(pbottom)/r

if r>1.0

r = 1.0

endif

endif

if green(pbottom)<=0

g = 0

elseif g<=0.0

g = 1.0

else

g = green(pbottom)/g

if g>1.0

g = 1.0

endif

endif

if blue(pbottom)<=0

b = 0

elseif b<=0.0

b = 1.0

else

b = blue(pbottom)/b

if b>1.0

b = 1.0

endif

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Burn"

; Here we clamp the minimum returned to 0 because of the special case

; when the color channel in ptop is zero (or less).

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if r<=0.0

r = 0.0

else

r = 1.0 - (1.0 - red(pbottom))/r

if r<0.0

r = 0.0

endif

endif

if g<=0.0

g = 0.0

else

g = 1.0 - (1.0 - green(pbottom))/g

if g<0.0

g = 0.0

endif

endif

if b<=0.0

b = 0.0

else

b = 1.0 - (1.0 - blue(pbottom))/b

if b<0.0

b = 0.0

endif

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Negation"

return rgba( 1.0 - abs(1.0 - red(ptop) - red(pbottom)), \

1.0 - abs(1.0 - green(ptop) - green(pbottom)), \

1.0 - abs(1.0 - blue(ptop) - blue(pbottom)), alpha(ptop) )

elseif @p_mmfmergemode=="Reflect"

; Here we clamp the maximum returned to 1.0 because of the special case

; when the color channel in ptop is one (or more).

float r = 1.0 - red(ptop)

float g = 1.0 - green(ptop)

float b = 1.0 - blue(ptop)

if red(pbottom)<=0

r = 0.0

elseif r<=0.0

r = 1.0

else

r = sqr(red(pbottom))/r

if r>1.0

r = 1.0

endif

endif

if green(pbottom)<=0

g = 0.0

elseif g<=0.0

g = 1.0

else

g = sqr(green(pbottom))/g

if g>1.0

g = 1.0

endif

endif

if blue(pbottom)<=0

b = 0.0

elseif b<=0.0

b = 1.0

else

b = sqr(blue(pbottom))/b

if b>1.0

b = 1.0

endif

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Freeze"

; Here we clamp the minimum returned to 0 because of the special case

; when the color channel in ptop is zero (or less).

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if r<=0.0

r = 0.0

else

r = 1.0 - sqr(1.0 - red(pbottom))/r

if r<0.0

r = 0.0

endif

endif

if g<=0.0

g = 0.0

else

g = 1.0 - sqr(1.0 - green(pbottom))/g

if g<0.0

g = 0.0

endif

endif

if b<=0.0

b = 0.0

else

b = 1.0 - sqr(1.0 - blue(pbottom))/b

if b<0.0

b = 0.0

endif

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Rev. Contrast Down"

return rgba( 0.5 + (1.0 - red(ptop))*(red(pbottom) - 0.5), \

0.5 + (1.0 - green(ptop))*(green(pbottom) - 0.5), \

0.5 + (1.0 - blue(ptop))*(blue(pbottom) - 0.5), alpha(ptop) )

elseif @p_mmfmergemode=="Rev. Contrast Up"

float r = red(pbottom)

float g = green(pbottom)

float b = blue(pbottom)

if r<0.5

r = r - 2.0*(1.0 - red(ptop))*r*(0.5 - r)

else

r = r + 2.0*(1.0 - red(ptop))*(1.0 - r)*(r - 0.5)

endif

if g<0.5

g = g - 2.0*(1.0 - green(ptop))*g*(0.5 - g)

else

g = g + 2.0*(1.0 - green(ptop))*(1.0 - g)*(g - 0.5)

endif

if b<0.5

b = b - 2.0*(1.0 - blue(ptop))*b*(0.5 - B)

else

b = b + 2.0*(1.0 - blue(ptop))*(1.0 - B)*(b - 0.5)

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Fade"

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if r<0.5

r = 2.0 * r * (0.5 - r + red(pbottom))

else

r = red(pbottom) + 2.0 * (r - 0.5)*(r - red(pbottom))

endif

if g<0.5

g = 2.0 * g * (0.5 - g + green(pbottom))

else

g = green(pbottom) + 2.0 * (g - 0.5)*(g - green(pbottom))

endif

if b<0.5

b = 2.0 * b * (0.5 - b + blue(pbottom))

else

b = blue(pbottom) + 2.0 * (b - 0.5)*(b - blue(pbottom))

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Reverse Fade"

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if r<0.5

r = red(pbottom) + 2.0 * r * (r - red(pbottom))

else

r = red(pbottom) + 2.0 * (1.0 - r)*(r - red(pbottom))

endif

if g<0.5

g = green(pbottom) + 2.0 * g * (g - green(pbottom))

else

g = green(pbottom) + 2.0 * (1.0 - g)*(g - green(pbottom))

endif

if b<0.5

b = blue(pbottom) + 2.0 * b * (b - blue(pbottom))

else

b = blue(pbottom) + 2.0 * (1.0 - B)*(b - blue(pbottom))

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Contrast" || @p_mmfmergemode=="Reverse Contrast"

float r1 = red(ptop)

float g1 = green(ptop)

float b1 = blue(ptop)

if @p_mmfmergemode=="Reverse Contrast"

r1 = 1.0 - r1

g1 = 1.0 - g1

b1 = 1.0 - b1

endif

if r1<0.5

r1 = 0.5 + 2.0 * r1 * (red(pbottom) - 0.5)

else

r1 = 2.0 * (r1 - 0.5)

float r = red(pbottom)

if r<0.5

r1 = r - 2.0*r1*r*(0.5 - r)

else

r1 = r + 2.0*r1*(1.0 - r)*(r - 0.5)

endif

endif

if g1<0.5

g1 = 0.5 + 2.0 * g1 * (green(pbottom) - 0.5)

else

g1 = 2.0 * (g1 - 0.5)

float g = green(pbottom)

if g<0.5

g1 = g - 2.0*g1*g*(0.5 - g)

else

g1 = g + 2.0*g1*(1.0 - g)*(g - 0.5)

endif

endif

if b1<0.5

b1 = 0.5 + 2.0 * b1 * (blue(pbottom) - 0.5)

else

b1 = 2.0 * (b1 - 0.5)

float b = blue(pbottom)

if b<0.5

b1 = b - 2.0*b1*b*(0.5 - B)

else

b1 = b + 2.0*b1*(1.0 - B)*(b - 0.5)

endif

endif

return rgba(r1,g1,b1,alpha(ptop))

elseif @p_mmfmergemode=="Quantize"

int nr = round(@qmax - (@qmax-@qmin)*(2.0/(1.0 + red(ptop)) - 1.0)) - 1

int ng = round(@qmax - (@qmax-@qmin)*(2.0/(1.0 + green(ptop)) - 1.0)) - 1

int nb = round(@qmax - (@qmax-@qmin)*(2.0/(1.0 + blue(ptop)) - 1.0)) - 1

return rgba(floor(red(pbottom)*(nr+0.999))/nr, \

floor(green(pbottom)*(ng+0.999))/ng, \

floor(blue(pbottom)*(nb+0.999))/nb,alpha(ptop))

elseif @p_mmfmergemode=="Reverse Quantize"

int nr = round(@qmax - (@qmax-@qmin)*(2.0/(2.0 - red(ptop)) - 1.0)) - 1

int ng = round(@qmax - (@qmax-@qmin)*(2.0/(2.0 - green(ptop)) - 1.0)) - 1

int nb = round(@qmax - (@qmax-@qmin)*(2.0/(2.0 - blue(ptop)) - 1.0)) - 1

return rgba(floor(red(pbottom)*(nr+0.999))/nr, \

floor(green(pbottom)*(ng+0.999))/ng, \

floor(blue(pbottom)*(nb+0.999))/nb,alpha(ptop))

elseif @p_mmfmergemode=="Gamma"

return rgba(red(pbottom)^(@mingamma+(@maxgamma-@mingamma)*red(ptop)), \

green(pbottom)^(@mingamma+(@maxgamma-@mingamma)*green(ptop)), \

blue(pbottom)^(@mingamma+(@maxgamma-@mingamma)*blue(ptop)), \

alpha(ptop))

elseif @p_mmfmergemode=="Inverse Gamma"

return rgba(red(pbottom)^(1.0/(@mingamma+(@maxgamma-@mingamma)*red(ptop))), \

green(pbottom)^(1.0/(@mingamma+(@maxgamma-@mingamma)*green(ptop))), \

blue(pbottom)^(1.0/(@mingamma+(@maxgamma-@mingamma)*blue(ptop))), \

alpha(ptop))

elseif @p_mmfmergemode=="Reverse Gamma"

return rgba(red(pbottom)^(@mingamma+(@maxgamma-@mingamma)*(1.0-red(ptop))), \

green(pbottom)^(@mingamma+(@maxgamma-@mingamma)*(1.0-green(ptop))), \

blue(pbottom)^(@mingamma+(@maxgamma-@mingamma)*(1.0-blue(ptop))), \

alpha(ptop))

elseif @p_mmfmergemode=="Rev. Inv. Gamma"

return rgba(red(pbottom)^(1.0/(@mingamma+(@maxgamma-@mingamma)*(1.0-red(ptop)))), \

green(pbottom)^(1.0/(@mingamma+(@maxgamma-@mingamma)*(1.0-green(ptop)))), \

blue(pbottom)^(1.0/(@mingamma+(@maxgamma-@mingamma)*(1.0-blue(ptop)))), \

alpha(ptop))

elseif @p_mmfmergemode=="Combined Gamma"

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if r<0.5

r = red(pbottom)^(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-red(ptop)))

else

r = red(pbottom)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(red(ptop)-0.5)))

endif

if g<0.5

g = green(pbottom)^(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-green(ptop)))

else

g = green(pbottom)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(green(ptop)-0.5)))

endif

if b<0.5

b = blue(pbottom)^(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-blue(ptop)))

else

b = blue(pbottom)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(blue(ptop)-0.5)))

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Rev. Comb. Gamma"

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if r<0.5

r = red(pbottom)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-red(ptop))))

else

r = red(pbottom)^(@mingamma+2.0*(@maxgamma-@mingamma)*(red(ptop)-0.5))

endif

if g<0.5

g = green(pbottom)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-green(ptop))))

else

g = green(pbottom)^(@mingamma+2.0*(@maxgamma-@mingamma)*(green(ptop)-0.5))

endif

if b<0.5

b = blue(pbottom)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-blue(ptop))))

else

b = blue(pbottom)^(@mingamma+2.0*(@maxgamma-@mingamma)*(blue(ptop)-0.5))

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Stamp"

float r = red(pbottom) + 2.0*red(ptop) - 1.0

float g = green(pbottom) + 2.0*green(ptop) - 1.0

float b = blue(pbottom) + 2.0*blue(ptop) - 1.0

if r<0.0

r = 0.0

elseif r>1.0

r = 1.0

endif

if g<0.0

g = 0.0

elseif g>1.0

g = 1.0

endif

if b<0.0

b = 0.0

elseif b>1.0

b = 1.0

endif

return RGBA(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Soft Dodge"

float r = red(pbottom)

float g = green(pbottom)

float b = blue(pbottom)

if r<=0

r = 0

elseif r+red(ptop)<=1.0

if red(ptop)>=1.0

r = 1.0

elseif (r = 0.5*r/(1.0 - red(ptop)))>1.0

r = 1.0

endif

elseif (r = 1.0 - 0.5*(1.0 - red(ptop))/r)<0.0

r = 0.0

endif

if g<=0

g = 0

elseif g+green(ptop)<=1.0

if green(ptop)>=1.0

g = 1.0

elseif (g = 0.5*g/(1.0 - green(ptop)))>1.0

g = 1.0

endif

elseif (g = 1.0 - 0.5*(1.0 - green(ptop))/g)<0.0

g = 0.0

endif

if b<=0

b = 0

elseif b+blue(ptop)<=1.0

if blue(ptop)>=1.0

b = 1.0

elseif (b = 0.5*b/(1.0 - blue(ptop)))>1.0

b = 1.0

endif

elseif (b = 1.0 - 0.5*(1.0 - blue(ptop))/b)<0.0

b = 0.0

endif

return RGBA(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Soft Burn"

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if r<=0

r = 0

elseif r+red(pbottom)<=1.0

if red(pbottom)>=1.0

r = 1.0

elseif (r = 0.5*r/(1.0 - red(pbottom)))>1.0

r = 1.0

endif

elseif (r = 1.0 - 0.5*(1.0 - red(pbottom))/r)<0.0

r = 0.0

endif

if g<=0

g = 0

elseif g+green(pbottom)<=1.0

if green(pbottom)>=1.0

g = 1.0

elseif (g = 0.5*g/(1.0 - green(pbottom)))>1.0

g = 1.0

endif

elseif (g = 1.0 - 0.5*(1.0 - green(pbottom))/g)<0.0

g = 0.0

endif

if b<=0

b = 0

elseif b+blue(pbottom)<=1.0

if blue(pbottom)>=1.0

b = 1.0

elseif (b = 0.5*b/(1.0 - blue(pbottom)))>1.0

b = 1.0

endif

elseif (b = 1.0 - 0.5*(1.0 - blue(pbottom))/b)<0.0

b = 0.0

endif

return RGBA(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Inverse Dodge"

; Here we clamp the maximum returned to 1.0 because of the special case

; when the color channel in ptop is one (or more).

float r = 1.0 - red(pbottom)

float g = 1.0 - green(pbottom)

float b = 1.0 - blue(pbottom)

if red(ptop)<=0

r = 0

elseif r<=0.0

r = 1.0

else

r = red(ptop)/r

if r>1.0

r = 1.0

endif

endif

if green(ptop)<=0

g = 0

elseif g<=0.0

g = 1.0

else

g = green(ptop)/g

if g>1.0

g = 1.0

endif

endif

if blue(ptop)<=0

b = 0

elseif b<=0.0

b = 1.0

else

b = blue(ptop)/b

if b>1.0

b = 1.0

endif

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Inverse Burn"

; Here we clamp the minimum returned to 0 because of the special case

; when the color channel in ptop is zero (or less).

float r = red(pbottom)

float g = green(pbottom)

float b = blue(pbottom)

if r<=0.0

r = 0.0

else

r = 1.0 - (1.0 - red(ptop))/r

if r<0.0

r = 0.0

endif

endif

if g<=0.0

g = 0.0

else

g = 1.0 - (1.0 - green(ptop))/g

if g<0.0

g = 0.0

endif

endif

if b<=0.0

b = 0.0

else

b = 1.0 - (1.0 - blue(ptop))/b

if b<0.0

b = 0.0

endif

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Glow"

; Here we clamp the maximum returned to 1.0 because of the special case

; when the color channel in ptop is one (or more).

float r = 1.0 - red(pbottom)

float g = 1.0 - green(pbottom)

float b = 1.0 - blue(pbottom)

if red(ptop)<=0

r = 0.0

elseif r<=0.0

r = 1.0

else

r = sqr(red(ptop))/r

if r>1.0

r = 1.0

endif

endif

if green(ptop)<=0

g = 0.0

elseif g<=0.0

g = 1.0

else

g = sqr(green(ptop))/g

if g>1.0

g = 1.0

endif

endif

if blue(ptop)<=0

b = 0.0

elseif b<=0.0

b = 1.0

else

b = sqr(blue(ptop))/b

if b>1.0

b = 1.0

endif

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Heat"

; Here we clamp the minimum returned to 0 because of the special case

; when the color channel in ptop is zero (or less).

float r = red(pbottom)

float g = green(pbottom)

float b = blue(pbottom)

if r<=0.0

r = 0.0

else

r = 1.0 - sqr(1.0 - red(ptop))/r

if r<0.0

r = 0.0

endif

endif

if g<=0.0

g = 0.0

else

g = 1.0 - sqr(1.0 - green(ptop))/g

if g<0.0

g = 0.0

endif

endif

if b<=0.0

b = 0.0

else

b = 1.0 - sqr(1.0 - blue(ptop))/b

if b<0.0

b = 0.0

endif

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Inv. Fade Down"

return rgba( red(pbottom) * (1 - red(pbottom) + red(ptop)), \

green(pbottom) * (1 - green(pbottom) + green(ptop)), \

blue(pbottom) * (1 - blue(pbottom) + blue(ptop)), alpha(ptop) )

elseif @p_mmfmergemode=="Inv. Fade Up"

return rgba(red(ptop) + red(pbottom)*(red(pbottom) - red(ptop)), \

green(ptop) + green(pbottom)*(green(pbottom) - green(ptop)), \

blue(ptop) + blue(pbottom)*(blue(pbottom) - blue(ptop)), \

alpha(ptop) )

elseif @p_mmfmergemode=="Inv. Contrast Down"

return rgba( 0.5 + red(pbottom)*(red(ptop) - 0.5), \

0.5 + green(pbottom)*(green(ptop) - 0.5), \

0.5 + blue(pbottom)*(blue(ptop) - 0.5), alpha(ptop) )

elseif @p_mmfmergemode=="Inv. Contrast Up"

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if r<0.5

r = r - 2.0*red(pbottom)*r*(0.5 - r)

else

r = r + 2.0*red(pbottom)*(1.0 - r)*(r - 0.5)

endif

if g<0.5

g = g - 2.0*green(pbottom)*g*(0.5 - g)

else

g = g + 2.0*green(pbottom)*(1.0 - g)*(g - 0.5)

endif

if b<0.5

b = b - 2.0*blue(pbottom)*b*(0.5 - B)

else

b = b + 2.0*blue(pbottom)*(1.0 - B)*(b - 0.5)

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Inv. Rev. Con. Down"

return rgba( 0.5 + (1.0 - red(pbottom))*(red(ptop) - 0.5), \

0.5 + (1.0 - green(pbottom))*(green(ptop) - 0.5), \

0.5 + (1.0 - blue(pbottom))*(blue(ptop) - 0.5), alpha(ptop) )

elseif @p_mmfmergemode=="Inv. Rev. Con. Up"

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if r<0.5

r = r - 2.0*(1.0 - red(pbottom))*r*(0.5 - r)

else

r = r + 2.0*(1.0 - red(pbottom))*(1.0 - r)*(r - 0.5)

endif

if g<0.5

g = g - 2.0*(1.0 - green(pbottom))*g*(0.5 - g)

else

g = g + 2.0*(1.0 - green(pbottom))*(1.0 - g)*(g - 0.5)

endif

if b<0.5

b = b - 2.0*(1.0 - blue(pbottom))*b*(0.5 - B)

else

b = b + 2.0*(1.0 - blue(pbottom))*(1.0 - B)*(b - 0.5)

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Inverse Fade"

float r = red(pbottom)

float g = green(pbottom)

float b = blue(pbottom)

if r<0.5

r = 2.0 * r * (0.5 - r + red(ptop))

else

r = red(ptop) + 2.0 * (r - 0.5)*(r - red(ptop))

endif

if g<0.5

g = 2.0 * g * (0.5 - g + green(ptop))

else

g = green(ptop) + 2.0 * (g - 0.5)*(g - green(ptop))

endif

if b<0.5

b = 2.0 * b * (0.5 - b + blue(ptop))

else

b = blue(ptop) + 2.0 * (b - 0.5)*(b - blue(ptop))

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Inv. Rev. Fade"

float r = red(pbottom)

float g = green(pbottom)

float b = blue(pbottom)

if r<0.5

r = red(ptop) + 2.0 * r * (r - red(ptop))

else

r = red(ptop) + 2.0 * (1.0 - r)*(r - red(ptop))

endif

if g<0.5

g = green(ptop) + 2.0 * g * (g - green(ptop))

else

g = green(ptop) + 2.0 * (1.0 - g)*(g - green(ptop))

endif

if b<0.5

b = blue(ptop) + 2.0 * b * (b - blue(ptop))

else

b = blue(ptop) + 2.0 * (1.0 - B)*(b - blue(ptop))

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Inverse Contrast" \

|| @p_mmfmergemode=="Inv. Rev. Contrast"

float r1 = red(pbottom)

float g1 = green(pbottom)

float b1 = blue(pbottom)

if @p_mmfmergemode=="Inv. Rev. Contrast"

r1 = 1.0 - r1

g1 = 1.0 - g1

b1 = 1.0 - b1

endif

if r1<0.5

r1 = 0.5 + 2.0 * r1 * (red(ptop) - 0.5)

else

r1 = 2.0 * (r1 - 0.5)

float r = red(ptop)

if r<0.5

r1 = r - 2.0*r1*r*(0.5 - r)

else

r1 = r + 2.0*r1*(1.0 - r)*(r - 0.5)

endif

endif

if g1<0.5

g1 = 0.5 + 2.0 * g1 * (green(ptop) - 0.5)

else

g1 = 2.0 * (g1 - 0.5)

float g = green(ptop)

if g<0.5

g1 = g - 2.0*g1*g*(0.5 - g)

else

g1 = g + 2.0*g1*(1.0 - g)*(g - 0.5)

endif

endif

if b1<0.5

b1 = 0.5 + 2.0 * b1 * (blue(ptop) - 0.5)

else

b1 = 2.0 * (b1 - 0.5)

float b = blue(ptop)

if b<0.5

b1 = b - 2.0*b1*b*(0.5 - B)

else

b1 = b + 2.0*b1*(1.0 - B)*(b - 0.5)

endif

endif

return rgba(r1,g1,b1,alpha(ptop))

elseif @p_mmfmergemode=="Inverse Quantize"

int nr = round(@qmax - (@qmax-@qmin)*(2.0/(1.0 + red(pbottom)) - 1.0)) - 1

int ng = round(@qmax - (@qmax-@qmin)*(2.0/(1.0 + green(pbottom)) - 1.0)) - 1

int nb = round(@qmax - (@qmax-@qmin)*(2.0/(1.0 + blue(pbottom)) - 1.0)) - 1

return rgba(floor(red(ptop)*(nr+0.999))/nr, \

floor(green(ptop)*(ng+0.999))/ng, \

floor(blue(ptop)*(nb+0.999))/nb,alpha(ptop))

elseif @p_mmfmergemode=="Inv. Rev. Quantize"

int nr = round(@qmax - (@qmax-@qmin)*(2.0/(2.0 - red(pbottom)) - 1.0)) - 1

int ng = round(@qmax - (@qmax-@qmin)*(2.0/(2.0 - green(pbottom)) - 1.0)) - 1

int nb = round(@qmax - (@qmax-@qmin)*(2.0/(2.0 - blue(pbottom)) - 1.0)) - 1

return rgba(floor(red(ptop)*(nr+0.999))/nr, \

floor(green(ptop)*(ng+0.999))/ng, \

floor(blue(ptop)*(nb+0.999))/nb,alpha(ptop))

elseif @p_mmfmergemode=="Inv. Gamma"

return rgba(red(ptop)^(@mingamma+(@maxgamma-@mingamma)*red(pbottom)), \

green(ptop)^(@mingamma+(@maxgamma-@mingamma)*green(pbottom)), \

blue(ptop)^(@mingamma+(@maxgamma-@mingamma)*blue(pbottom)), \

alpha(ptop))

elseif @p_mmfmergemode=="Inv. Inverse Gamma"

return rgba(red(ptop)^(1.0/(@mingamma+(@maxgamma-@mingamma)*red(pbottom))), \

green(ptop)^(1.0/(@mingamma+(@maxgamma-@mingamma)*green(pbottom))), \

blue(ptop)^(1.0/(@mingamma+(@maxgamma-@mingamma)*blue(pbottom))), \

alpha(ptop))

elseif @p_mmfmergemode=="Inv. Reverse Gamma"

return rgba(red(ptop)^(@mingamma+(@maxgamma-@mingamma)*(1.0-red(pbottom))), \

green(ptop)^(@mingamma+(@maxgamma-@mingamma)*(1.0-green(pbottom))), \

blue(ptop)^(@mingamma+(@maxgamma-@mingamma)*(1.0-blue(pbottom))), \

alpha(ptop))

elseif @p_mmfmergemode=="Inv. Rev. Inv. Gamma"

return rgba(red(ptop)^(1.0/(@mingamma+(@maxgamma-@mingamma)*(1.0-red(pbottom)))), \

green(ptop)^(1.0/(@mingamma+(@maxgamma-@mingamma)*(1.0-green(pbottom)))), \

blue(ptop)^(1.0/(@mingamma+(@maxgamma-@mingamma)*(1.0-blue(pbottom)))), \

alpha(ptop))

elseif @p_mmfmergemode=="Inv. Combined Gamma"

float r = red(pbottom)

float g = green(pbottom)

float b = blue(pbottom)

if r<0.5

r = red(ptop)^(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-r))

else

r = red(ptop)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(r-0.5)))

endif

if g<0.5

g = green(ptop)^(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-g))

else

g = green(ptop)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(g-0.5)))

endif

if b<0.5

b = blue(ptop)^(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-B))

else

b = blue(ptop)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(b-0.5)))

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Inv. Rev. Comb. Gamma"

float r = red(pbottom)

float g = green(pbottom)

float b = blue(pbottom)

if r<0.5

r = red(ptop)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-r)))

else

r = red(ptop)^(@mingamma+2.0*(@maxgamma-@mingamma)*(r-0.5))

endif

if g<0.5

g = green(ptop)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-g)))

else

g = green(ptop)^(@mingamma+2.0*(@maxgamma-@mingamma)*(g-0.5))

endif

if b<0.5

b = blue(ptop)^(1.0/(@mingamma+2.0*(@maxgamma-@mingamma)*(0.5-B)))

else

b = blue(ptop)^(@mingamma+2.0*(@maxgamma-@mingamma)*(b-0.5))

endif

return rgba(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Inverse Stamp"

float r = red(ptop) + 2.0*red(pbottom) - 1.0

float g = green(ptop) + 2.0*green(pbottom) - 1.0

float b = blue(ptop) + 2.0*blue(pbottom) - 1.0

if r<0.0

r = 0.0

elseif r>1.0

r = 1.0

endif

if g<0.0

g = 0.0

elseif g>1.0

g = 1.0

endif

if b<0.0

b = 0.0

elseif b>1.0

b = 1.0

endif

return RGBA(r,g,b,alpha(ptop))

elseif @p_mmfmergemode=="Brightness (Yiq)"

float btop = 0.299*red(ptop) + 0.587*green(ptop) + 0.114*blue(ptop)

float bbtm = 0.299*red(pbottom) + 0.587*green(pbottom) \

+ 0.114*blue(pbottom)

if bbtm==0

return RGBA(btop,btop,btop,alpha(ptop))

else

pbottom = pbottom*(btop/bbtm)

return RGBA(red(pbottom),green(pbottom),blue(pbottom),alpha(ptop))

endif

elseif @p_mmfmergemode=="Colour (Inverse Yiq)"

float btop = 0.299*red(ptop) + 0.587*green(ptop) + 0.114*blue(ptop)

float bbtm = 0.299*red(pbottom) + 0.587*green(pbottom) \

+ 0.114*blue(pbottom)

if btop==0

return RGBA(bbtm,bbtm,bbtm,alpha(ptop))

else

pbottom = ptop*(bbtm/btop)

return RGBA(red(pbottom),green(pbottom),blue(pbottom),alpha(ptop))

endif

elseif @p_mmfmergemode=="Brightness (Custom)"

float btop = (@redlvl*red(ptop) + @greenlvl*green(ptop) \

+ @bluelvl*blue(ptop))/(@redlvl + @greenlvl +@bluelvl)

float bbtm = (@redlvl*red(pbottom) + @greenlvl*green(pbottom) \

+ @bluelvl*blue(pbottom))/(@redlvl + @greenlvl +@bluelvl)

if bbtm==0

return RGBA(btop,btop,btop,alpha(ptop))

else

pbottom = pbottom*(btop/bbtm)

return RGBA(red(pbottom),green(pbottom),blue(pbottom),alpha(ptop))

endif

elseif @p_mmfmergemode=="Colour (Custom)"

float btop = (@redlvl*red(ptop) + @greenlvl*green(ptop) \

+ @bluelvl*blue(ptop))/(@redlvl + @greenlvl +@bluelvl)

float bbtm = (@redlvl*red(pbottom) + @greenlvl*green(pbottom) \

+ @bluelvl*blue(pbottom))/(@redlvl + @greenlvl +@bluelvl)

if btop==0

return RGBA(bbtm,bbtm,bbtm,alpha(ptop))

else

pbottom = ptop*(bbtm/btop)

return RGBA(red(pbottom),green(pbottom),blue(pbottom),alpha(ptop))

endif

elseif @p_mmfmergemode=="Pin Light"

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if (r>=0.5 && rred(pbottom))

r = red(pbottom)

endif

if (g>=0.5 && ggreen(pbottom))

g = green(pbottom)

endif

if (b>=0.5 && bblue(pbottom))

b = blue(pbottom)

endif

return RGBA(r, g, b, alpha(ptop))

elseif @p_mmfmergemode=="Reverse Pin Light"

float r = red(ptop)

float g = green(ptop)

float b = blue(ptop)

if (r>=0.5 && r>red(pbottom)) || (r<0.5 && r

r = red(pbottom)

endif

if (g>=0.5 && g>green(pbottom)) || (g<0.5 && g

g = green(pbottom)

endif

if (b>=0.5 && b>blue(pbottom)) || (b<0.5 && b

b = blue(pbottom)

endif

return RGBA(r, g, b, alpha(ptop))

elseif @p_mmfmergemode=="Inv. Pin Light"

float r = red(pbottom)

float g = green(pbottom)

float b = blue(pbottom)

if (r>=0.5 && rred(ptop))

r = red(ptop)

endif

if (g>=0.5 && ggreen(ptop))

g = green(ptop)

endif

if (b>=0.5 && bblue(ptop))

b = blue(ptop)

endif

return RGBA(r, g, b, alpha(ptop))

else;if @p_mmfmergemode=="Inv. Rev. Pin Light"

float r = red(pbottom)

float g = green(pbottom)

float b = blue(pbottom)

if (r>=0.5 && r>red(ptop)) || (r<0.5 && r

r = red(ptop)

endif

if (g>=0.5 && g>green(ptop)) || (g<0.5 && g

g = green(ptop)

endif

if (b>=0.5 && b>blue(ptop)) || (b<0.5 && b

b = blue(ptop)

endif

return RGBA(r, g, b, alpha(ptop))

endif ; @p_mmfmergemode

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...