Archived

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

about water. >>>>

This topic is 5303 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

which way is usualy use to create water. 1.use transparence material + texture. 2.use texture with alpha channel. i think the first one is faster. i didn''t konw the diffent between using material or using texture.

Share this post


Link to post
Share on other sites
You can create water by use texture with alpha channel.
This is a easy way and can make high FPS

Show the effect screenshot:



-ÎÒ˼¹ÊÎÒÔÚ£¬ÄÔ´ü²»»á»µ-

[edited by - F_O_X on June 5, 2003 1:20:24 AM]

[edited by - F_O_X on June 5, 2003 1:20:55 AM]

Share this post


Link to post
Share on other sites
YES,it is animated.

void CLake::LoadTex()
{
D3DXCreateTextureFromFile(m_pD3DDevice,"water/water.bmp",&m_pWaterTex);
char path[255];
for( int i=0;i<32;i++ ){
sprintf(path,"%s%d%s","water1/caust",i,".tga");
D3DXCreateTextureFromFile(m_pD3DDevice,path,&m_pTexture[i]);
}
}

void CLake::Render()
{
m_pD3DDevice->SetRenderState(D3DRS_TEXTUREFACTOR,D3DCOLOR_ARGB(180,80,80,252));
m_pD3DDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(TREE_CUSTOMVERTEX));
m_pD3DDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX);
m_pD3DDevice->SetTexture(0, m_pTexture[m_pCurrentN]);
m_pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_ADDSIGNED);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_pD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );
m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
m_pD3DDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
m_pD3DDevice->SetTexture(1, m_pTexture[31-m_pCurrentN]);
m_pD3DDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pD3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED );
m_pD3DDevice->SetTextureStageState( 1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
m_pD3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TFACTOR );
m_pD3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );

m_pD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
m_pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
m_pCurrentN++;
if(m_pCurrentN>31){
m_pCurrentN=0;
}
m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 );
m_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
}


DEMO ONE URL:http://www.gamelab.ns.tc/a.rar This Demo not use ALPHAOP

DEMO TWO URL:http://www.gamelab.ns.tc/b.rar This Demo use ALPHAOP

GOOD LUCK

-ÎÒ˼¹ÊÎÒÔÚ£¬ÄÔ´ü²»»á»µ-

Share this post


Link to post
Share on other sites