Sprite Programming question

Started by
15 comments, last by LagunaCloud 18 years, 5 months ago
You don't need any special render states or multiple passes or anything for this. Like somebody said, you just need to set the SPECULAR component of your vertices. Any color values in specular will BRIGHTEN your sprite. (The other choice, as you've discovered, is to reduce your diffuse values, which will fade the sprite toward black.)

Using multiple passes with alpha/renderstates is definitely NOT called for here.
Advertisement
Could it have anything to do with the Sprite->Begin() and Sprite->End()
functions cause I'm not using them and the light thing isn't working.
Laguna!!!
From what I know, if you use ID3DXSprite version of sprite, then it automatically bypasses render states and enables bilinear filters etc. That is because these sprites are rhw based, based on pure 2D. By using them, you are able to bypass most of, if not all, Transform and Lighting (T&L) pipeline. That means if you apply matrix calculations, they wont have any effect on sprites, they will continue to draw on their specified x,y position; similarly, lighting that applies every where else wont have any effect on sprites.

This might sound old-fashioned, but you can do the following:

- Have two copies of each bitmap on which you wish to apply this white-glowing effect.
- One would be the original, say bmp1, other would be the white version of exactly the same bitmap, say bmp2.
- When ever you need the white effect, you can draw bmp2 with some grey-effect color on top of bmp1.
- When you dont need that effect, either: dont draw bmp2 at all, or, draw it with color 0x00000000 (or was it 0xff000000 for transparency effect?) on top of bmp1.

If your rendering doesnt get very heavy, above solution should work fine, else the other solution would be to write your own customized sprite class, that supports T&L pipeline. But, personally, latter option is kind of more work to do.. :)
Thanks I believe that will work, I just got home from my 3rd shift job and plan to go to sleep when I wake up I'll try that and tell you guys if it works or not but I'm pretty sure that will work.
GoodNight!!
Laguna!!!
That worked wonders, it does the flashes that I wanted it to do.
Thanx to everyone else too, It gave me something to look up and find more info
on DirectX.
Laguna!!!
I don't know about D3DXSprite but you don't need a T&L pipeline to have flashing/brightened sprites. When you work with transformed and lit vertices, you can add a specular component to the FVF (and to each vertex for the quad, or only some of them if you want!) and it will brighten accordingly, including using the alpha information. I use this ALL the time so I'm sure it works... I'm sure your solution is fine for low sprite counts but doesn't it require twice as much work? Just FYI if you want to optimize in the future...
Are you talking about textured quads or the D3DXSprite, I want to use the sprites because of ease of working with 2D objects. When I looked at the code for setting up stuff it looked far too complicated for me at this point, so I'm going to take it slow, and work my way up.
Laguna!!!

This topic is closed to new replies.

Advertisement