Grand Nagus
Newcomer
- Joined
- Jan 7, 2004
- Messages
- 10
Hey guys. I knew I'd be back! Maybe I have a more challenging question than my last one...
I'm working on a 2d tile-rendering engine based on Direct3D and quads, and so far it's pretty impressive! (I'm a noob to DirectX, so it doesn't take much to impress me. ) It has a particle system that works (something blows up and it throws sparks - REALLY cool effect!), and you can assign a blendfunc to each individual tile instead of the whole shebang so it renders how you want it to look. WOW! ...Sorry, I didn't mean to carry on like that, I'm just excited about getting something to actually work! Programming my own game from the ground-up beats the heck out of modding somebody else's work (Quake3, Elite Force)! I can see why you guys have so much fun in what you're doing.
Anyways, here's my question...
I'm trying to make the texture on a quad 'fade' out using alpha blending. First, here's some stuff that I'm gonna reference later in my explanation of my problem:
You can see from that last part that I'm gradually adding the last value in 'color' from 0x00 (transparent) to 0xFF (opaque) in an effort to 'fade in' this quad. But after several days of research and tinkering, I found out that the last value isn't 'alpha' at all; it's OPACITY! So all I'm doing is affecting the 'opacity' of the texture, not the alpha channel... D'oh!
< color is a dword: 0x00(red) 00(green) 00(blue) 00(opacity) >
When the program with the above code is executed, a pic of a little ghost appears over a background, where it fades from 'black' to 'ghost texture' and repeats... But I want it to fade from totally transparent to totally opaque.
What the above code does (from opaque to... black?):
What I want (done in PaintShop Pro)(from opaque to transparent):
I tried to find what I could to change the texture's alpha opacity but had absolutely no luck... I think my above function would work if I knew where to find and change the alpha info, 'cause I'd just replace the above 'color fade' stuff to 'alpha fade'. Do any of you know where the 'alpha opacity' info is stored? I'm sure it's really simple, but I'm still quite the newbie so I'm not sure where to find it.
Thanks in advance for the help!
I'm working on a 2d tile-rendering engine based on Direct3D and quads, and so far it's pretty impressive! (I'm a noob to DirectX, so it doesn't take much to impress me. ) It has a particle system that works (something blows up and it throws sparks - REALLY cool effect!), and you can assign a blendfunc to each individual tile instead of the whole shebang so it renders how you want it to look. WOW! ...Sorry, I didn't mean to carry on like that, I'm just excited about getting something to actually work! Programming my own game from the ground-up beats the heck out of modding somebody else's work (Quake3, Elite Force)! I can see why you guys have so much fun in what you're doing.
Anyways, here's my question...
I'm trying to make the texture on a quad 'fade' out using alpha blending. First, here's some stuff that I'm gonna reference later in my explanation of my problem:
Code:
// this is my customvertex struct...
struct CUSTOMVERTEX2
{
float x, y, z, rhw; // The transformed position for the vertex
DWORD color; // The vertex color
float tu, tv; // The texture coordinates
};
...
// LOTS of stuff to create an array of quads
...
// this is a pointer to my struct...
CUSTOMVERTEX2 *pVertices;
...
// locked this vert buffer and actually changing and re-assigning the new color value...
oldColor = pVertices[0].color;
newColor = oldColor + 0x00000001;
if (newColor > 0xFFFFFFFF)
newColor = 0xFFFFFF00;
pVertices[0].color = newColor;
pVertices[1].color = newColor;
pVertices[2].color = newColor;
pVertices[3].color = newColor;
...
You can see from that last part that I'm gradually adding the last value in 'color' from 0x00 (transparent) to 0xFF (opaque) in an effort to 'fade in' this quad. But after several days of research and tinkering, I found out that the last value isn't 'alpha' at all; it's OPACITY! So all I'm doing is affecting the 'opacity' of the texture, not the alpha channel... D'oh!
< color is a dword: 0x00(red) 00(green) 00(blue) 00(opacity) >
When the program with the above code is executed, a pic of a little ghost appears over a background, where it fades from 'black' to 'ghost texture' and repeats... But I want it to fade from totally transparent to totally opaque.
What the above code does (from opaque to... black?):
What I want (done in PaintShop Pro)(from opaque to transparent):
I tried to find what I could to change the texture's alpha opacity but had absolutely no luck... I think my above function would work if I knew where to find and change the alpha info, 'cause I'd just replace the above 'color fade' stuff to 'alpha fade'. Do any of you know where the 'alpha opacity' info is stored? I'm sure it's really simple, but I'm still quite the newbie so I'm not sure where to find it.
Thanks in advance for the help!