Changing sprite and screen colors using D3D

Started by
4 comments, last by Ivyn 21 years, 4 months ago
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.
-- Ivyn --
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

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.
-- Ivyn --
How is this done with ID3DXSprite?
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,
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
thanks Mickey, long time no see!

.lick

This topic is closed to new replies.

Advertisement