Original Post
Dear community, I want to fade in/out a mesh and can't get it to work the way I want to. ;) I have a 3ds mesh (shockwave) which has his own texture without alpha (as it's a jpeg). I want to display this mesh using an additiv method combined with vertex alpha. The darker the texture is, it should be more transparent (black = complete transparent), which works great using an additiv method with the following renderstates: Please see this image:
Ok, now I want to fade out this mesh, which (of course) does not work using this additiv thing. So I have to use vertex alpha with which I can fade it out. Please take a look:
As you can see, the black color has the same priority as all the other colors, which is (of course again) ok for the used vertex alpha. ;) I use the following render- and texturestagestates for vertex alpha: Please take a look again:
Ok. Now blending works fine. But I would need a combination between adding colors and vertex alpha. Is this even possible? I use the following renderstates: I know, I have to use some texturestagestates, something like pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); (which does not work) but I don't get the point. Do you have an idea? 1. I don't want to use shaders. 2. I don't want to use textures with alpha channel. In my mainloop I set the alpha of the vertices (which is not very performant). I guess I have to set the diffuseColor component and create my own material? I know it is possible, even Blitzbasic can do this, using a texture without an alpha channel, set something like ADD_COLOR and fade it in and out. ;) Thanks a lot, thanks for reading and best regards - Xaron
pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);
material.ZWriteEnable = false;
Ok, now I want to fade out this mesh, which (of course) does not work using this additiv thing. So I have to use vertex alpha with which I can fade it out. Please take a look:
As you can see, the black color has the same priority as all the other colors, which is (of course again) ok for the used vertex alpha. ;) I use the following render- and texturestagestates for vertex alpha:
pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
material.ZWriteEnable = false;
Ok. Now blending works fine. But I would need a combination between adding colors and vertex alpha. Is this even possible? I use the following renderstates:
pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
pID3DDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );

