Jump to content
  • Advertisement

Archived

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

Ivyn

Changing sprite and screen colors using D3D

This topic is 5800 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

I''m using Direct3D for my 2D engine and I want to know a method of changing the color of a sprite, for example say I wanted a fighter to flash red when he gets hit. Also I want to know how to change the hue of the screen, for example make the screen black&white or brown&green, et cetera et cetera. I''m looking for methods that almost all video cards can support since this engine is so multipurposeful. Please if you can lend a hand please do, thank you for your time. Please note that I am not using 8-bit (256 colors), I am using Direct3D 16-bit and/or higher.

Share this post


Link to post
Share on other sites
Advertisement
Hi-

There are probably many, many ways to do this, but one very easy way to do this is to use materials - make a standard material and a h-lite material. When you want to hi-lite an object, just set the material to your hi-lite material, render the object, and reset the material to the normal material.

For example, billboards rendered using the standard material:




and the same image again, only one of the billboards has been rendered using a ''hi-lite'' material:


Here, the only differences between the two materials is that the first has its ambient.red, .green, .blue values set to 1.0 (meaning that ambient light gets applied exactly as it''s defined by the scene''s lighting) and the second - the ''hi-light'' material - has its blue and green ambient values set to 0 and its red value set to 1 (meaning that only the scene''s red ambient light gets applied to the billboard).

Again - this is a fairly simple way to do what you asked about - it would be interesting to know how the more advanced forum users have acheived the same effect.

Hope this helps-

BM

Share this post


Link to post
Share on other sites
Hah! Thanks alot for showing me that method, that''s pretty much what I had in mind. I''ll test it out myself on a few machines.



I''m still interested to know other methods for achieving the same effect.

Share this post


Link to post
Share on other sites
hi Pipo,

ID3DXSprite::Draw(..)/DrawTransform(..), has it''s last param that asks for the color to modulate with the texture, this is what you want,

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!