Grand Nagus
Member
- Joined
- Jan 7, 2004
- Messages
- 10
Hey guys. I knew Id be back! Maybe I have a more challenging question than my last one...
Im working on a 2d tile-rendering engine based on Direct3D and quads, and so far its pretty impressive! (Im a noob to DirectX, so it doesnt 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 didnt mean to carry on like that, Im just excited about getting something to actually work! Programming my own game from the ground-up beats the heck out of modding somebody elses work (Quake3, Elite Force)! I can see why you guys have so much fun in what youre doing.
Anyways, heres my question...
Im trying to make the texture on a quad fade out using alpha blending. First, heres some stuff that Im gonna reference later in my explanation of my problem:
You can see from that last part that Im 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 isnt alpha at all; its OPACITY! So all Im doing is affecting the opacity of the texture, not the alpha channel... Doh!
< 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?):
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/start.jpg
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/color_1.jpg
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/color_3.jpg
What I want (done in PaintShop Pro)(from opaque to transparent):
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/start.jpg
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/fade_1.jpg
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/finish.jpg
I tried to find what I could to change the textures 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 Id just replace the above color fade stuff to alpha fade. Do any of you know where the alpha opacity info is stored? Im sure its really simple, but Im still quite the newbie so Im not sure where to find it.
Thanks in advance for the help!
Im working on a 2d tile-rendering engine based on Direct3D and quads, and so far its pretty impressive! (Im a noob to DirectX, so it doesnt 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 didnt mean to carry on like that, Im just excited about getting something to actually work! Programming my own game from the ground-up beats the heck out of modding somebody elses work (Quake3, Elite Force)! I can see why you guys have so much fun in what youre doing.
Anyways, heres my question...
Im trying to make the texture on a quad fade out using alpha blending. First, heres some stuff that Im 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 Im 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 isnt alpha at all; its OPACITY! So all Im doing is affecting the opacity of the texture, not the alpha channel... Doh!
< 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?):
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/start.jpg
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/color_1.jpg
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/color_3.jpg
What I want (done in PaintShop Pro)(from opaque to transparent):
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/start.jpg
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/fade_1.jpg
[Broken External Image]:http://www.nagusmaps.com/hotlinx/d3d_probs/finish.jpg
I tried to find what I could to change the textures 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 Id just replace the above color fade stuff to alpha fade. Do any of you know where the alpha opacity info is stored? Im sure its really simple, but Im still quite the newbie so Im not sure where to find it.
Thanks in advance for the help!