Jump to content
  • Advertisement
Sign in to follow this  
LagunaCloud

Sprite Programming question

This topic is 4674 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 have a question. It might seem ridiculously easy for some but I can't find any information on how to do it. I'm builing a 2-D RPG and I want my sprites to flash a bright white but I can't figure out how I'm going to do it. If I set D3DColor parameters any higher than 255 it will go to black and if I set it to 255, It only displays the sprite how it looks on the bitmap.

Share this post


Link to post
Share on other sites
Advertisement
Going for values higher than 255 and less than 0 will produce some wierd effects since the range of a D3DCOLOR component is 0 - 255,

If you really want a brighter sprite you will move to HDR (High dynamic range) lighting which will add some complexity. It all depends on what effect you want to achieve. If you are using sprites as your particle system then the range of 0 - 255 is fine. It all depends.

I hope this helps.

Share this post


Link to post
Share on other sites
I take it you are rendering quads to the screen?

If so, I'm thinking you could make use of the specular lighting system. This essentially adds brightness on after the texture/diffuse modulation, and can make your sprite completely white - either that or blend another totally white sprite over the top using the original sprite as the alpha information.

...Or do the same thing in a pixel/fragment shader.

Share this post


Link to post
Share on other sites
Internally, all colors are kept in some floating point format, so it wouldn't matter if you exceed the 255 (actually, 1.0). The only problem would be to pass the parameters to the driver as BYTE (or DWORD).

I think you could get away with using D3DTOP_MODULATE2X (or even 4X).

Basically, when you start the brightening process, you set D3DTOP_MODULATE2X instead of D3DTOP_MODULATE, and color channels to 128, instead of 255. Then you gradually increase the color channels from 128 to 255, being able to control the process.

Share this post


Link to post
Share on other sites
I personally think the easier way would be to use the emissive component of a d3d material...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
These answers are ridiculous. Don't listen to any of that. HDR and floating point color.... you are building a 2D sprite game. The easiest way to do this is to render your sprite a second time with different blending effects. Look at SetRenderState(D3DRS_SRCBLEND,

Think of it this way: render full color instance, first. The render the same with just the alpha channel and a blend color (like 255, 255, 255) and it will light up your sprite.

Share this post


Link to post
Share on other sites
It isn't working so I'm guessing I didn't fully understand what was said
The setup I have right now is:

Sprite->Draw();
id3dd8->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCCOLOR);//???????????
Sprite->Draw();

The question marks are there because I'm not sure what parameters are supposed to be there or if my setup is completely wrong to begin with.

Share this post


Link to post
Share on other sites
To detail AP's post:

The first render is done normally. The second is simply a quad of the same size as the original image in the same position as the original image with three properties:

1: only one color. Don't use any textures. Just a solid color -in your case full-white (alpha,255,255,255)

2: an alpha value -try 50% for starters(128,color,color,color)

3: set the render-states needed to perform additive blending to the backbuffer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!