Color Inverting in D3D

Started by
1 comment, last by ms291052 20 years, 6 months ago
Does anyone know if/how to invert colors in D3D? I would tend to think there''s some obscure renderstate somewhere to set, but I''m not quite sure. By "invert" I mean changing black to white, red to teal, green to purple, and so forth.
Advertisement
You can use the D3DTA_COMPLEMENT modifier in your SetTextureStageState() setup to invert what''s being rendered during multitexture blending.


You could alternatively use frame buffer (alpha) blending with the INV***COLOR blending factors to achieve a number of inverse effects. For example if you wanted to invert the contents of what was already in the frame buffer you could render a white quad to those portions with a blend like INVDESTCOLOR:ZERO or INVDESTCOLOR:INVSRCCOLOR to achieve the inversion *.


It can of course also be achieved with pixel shaders instead of the texture stage state setup.


[*]<br><br>–<br>Simon O''Connor<br>3D Game Programmer &<br><a href="http://mvp.support.microsoft.com/">Microsoft DirectX MVP</a><br>

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Thanks. g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE | D3DTA_COMPLEMENT); seems to work perfectly.

This topic is closed to new replies.

Advertisement