BRL.Max2D - INVERTBLEND

BlitzMax Forums/BlitzMax Module Tweaks/BRL.Max2D - INVERTBLEND

Red(Posted 2005) [#1]
This blend invert pixel color value. ( negative image )

driver.bmx ( BRL.max2D )
-------------
At line 13, insert lines :
Const INVERTBLEND=6
d3d7max2D.bmx ( BRL.d3d7max2D )
-------------
At line 243, insert lines :
		Case INVERTBLEND
			device.SetRenderState D3DRS_ALPHATESTENABLE,False  
			device.SetRenderState D3DRS_ALPHABLENDENABLE,True  
			device.SetRenderState D3DRS_SRCBLEND,D3DBLEND_INVDESTCOLOR
			device.SetRenderState D3DRS_DESTBLEND,D3DBLEND_ZERO
glmax2D.bmx ( BRL.Glmax2D )

-------------
At line 299, insert lines :
	Case INVERTBLEND
		glEnable GL_BLEND
		glBlendFunc GL_ONE_MINUS_DST_COLOR, GL_ZERO
		glDisable GL_ALPHA_TEST



TartanTangerine (was Indiepath)(Posted 2005) [#2]
Nice, Mark - Stick it in the official mods please.


Robert Cummings(Posted 2005) [#3]
Yep, I second this, if it is well compatible!


xlsior(Posted 2005) [#4]
Would be a nice addition -- the more blend modes, the better.


Jay Kyburz(Posted 2005) [#5]
You guys rock.


Ferminho(Posted 2005) [#6]
Nice one! Cool blend ;)

I made a minor change, hope you don't mind:

glBlendFunc GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR

so the inversion is gradual (black doesn't invert, white inverts 100%), I think it may be good for some distortion fx!

for dx version (I'm not sure, haven't tested) the change would be something like...

device.SetRenderState D3DRS_SRCBLEND,D3DBLEND_INVDESTCOLOR
device.SetRenderState D3DRS_DESTBLEND,D3DBLEND_INVSRCCOLOR

(well in fact, I made a new blend; I think both of them are useful)


Red(Posted 2005) [#7]
At start,I wanted to invert source image color without using pixmap pixel pointer.