Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ms291052

Color Inverting in D3D

This topic is 5365 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.


[* off the top of my head - don''t have the DXSDK installed on this machine]

--
Simon O''Connor
3D Game Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites
Thanks. g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE | D3DTA_COMPLEMENT); seems to work perfectly.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!