Archived

This topic is now archived and is closed to further replies.

kapru

im desperate

Recommended Posts

Zook    134
You could do something like this:

pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
pd3dDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);

This will take the result from the color op in stage 0, (which by default is to modulate diffuse with texture) and use it with the alpha value from the texture in stage 1.

[edited by - Zook on January 23, 2004 7:47:53 AM]

Share this post


Link to post
Share on other sites
kapru    100
Thats exactly what im doing maybe im not setting the right render states

this is what im doing

HRESULT CFrameWorkApplication::RenderTerrainTexture()
{
HRESULT hr;

LPD3DXRENDERTOSURFACE rendertargetsurface;
IDirect3DSurface8 *newsurface;


D3DSURFACE_DESC desc;
terrRenderTarget->GetSurfaceLevel(0, &newsurface);
newsurface->GetDesc(&desc);


if(FAILED(hr = D3DXCreateRenderToSurface(d3ddevice, desc.Width, desc.Height,
D3DFMT_A8R8G8B8, FALSE, D3DFMT_UNKNOWN, &rendertargetsurface)))
{
return hr;
}


rendertargetsurface->BeginScene(newsurface, NULL);


d3ddevice->SetStreamSource(0, rendertargetVB, sizeof(rendertargetvertex));
d3ddevice->SetVertexShader(RENDERTARGET_VERTEX);
d3ddevice->Clear( 0L, NULL, D3DCLEAR_TARGET,D3DCOLOR_ARGB(255,0,0,0), 0.0f, 0L );\



d3ddevice->SetRenderState(D3DRS_ZWRITEENABLE,false);

d3ddevice->SetRenderState(D3DRS_LIGHTING,false);
d3ddevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID );
d3ddevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
d3ddevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
d3ddevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
d3ddevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
d3ddevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);

d3ddevice->SetTextureStageState(0, D3DTSS_COLOROP,D3DTOP_SELECTARG1);
d3ddevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_CURRENT);
d3ddevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
d3ddevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);




d3ddevice->SetTexture(1,terrTexture[0]);
d3ddevice->SetTexture(0,terrBlendMap[0]);
d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2);

d3ddevice->SetTexture(1,terrTexture[1]);
d3ddevice->SetTexture(0,terrBlendMap[1]);
d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2);

d3ddevice->SetTexture(1,terrTexture[2]);
d3ddevice->SetTexture(0,terrBlendMap[2]);
d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2);

d3ddevice->SetTexture(1,terrTexture[3]);
d3ddevice->SetTexture(0,terrBlendMap[3]);
d3ddevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2);

rendertargetsurface->EndScene();

//Release the rendertosurface

SAFE_RELEASE(rendertargetsurface);
SAFE_RELEASE(newsurface);

return S_OK;
}

Share this post


Link to post
Share on other sites
Wavewash    202
Do you have a texture and then alpha that your getting from a black and white texture? You may want to combine them into one TGA. That way you don't waste a texture blending stage and it's so much easier too.

www.opticuslabs.com/alphatexgen

~Wave

[edited by - Wavewash on January 23, 2004 1:01:37 PM]

Share this post


Link to post
Share on other sites
treething    122
Add this..

d3ddevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
d3ddevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);

You need that to transfer the alpha to the end of the texture cascade, otherwise the alpha will just get lost.

Share this post


Link to post
Share on other sites
kapru    100
For some reason there is no blending happening at all they just overrite each other even if im just plotting grass its either drawing all or nothing. So my guess if im missing something that im too stupid to see

if any one want the code for the engine i can email it its only 300k with the 4 textures it needs

Share this post


Link to post
Share on other sites