开发者

Turning a DirectX sprite Solid White

I have a sprite of my main character. I normally draw it with a color modulus of ARGB(255,255,255,255). However, I would like my sprite to be drawn more white. I can make the sprite be drawn any color by changing the color modulus, except for white. What can I do? I am开发者_开发知识库 using C++ with DirectX9 and using an LPD3DXSPRITE to draw my textures.


There are 2 way that I know, one inefficient, one more efficient :

Inefficient ) Draw another semitranparent white sprite using alphablending.

Efficient ) Use a shader to draw the quad. (a simple shader that add a value over the actual return value of the texture sample instead of multiplying it)


Try this:

IDirect3DDevice9* device = your_device;
LPD3DXSPRITE sprite = your_sprite;
LPDIRECT3DTEXTURE9 texture = your_texture;
D3DXVECTOR3 center;
D3DXVECTOR3 position;
unsigned char c = how_white_you_want;


sprite->Begin(D3DXSPRITE_ALPHABLEND);

device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_ADD );
device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );

sprite->Draw(texture, NULL, &center, &sprite, D3DCOLOR_RGBA(c,c,c,255));

sprite->End();

I think it's simple and efficient.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜