Jump to content
  • Advertisement

Archived

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

88er

about water. >>>>

This topic is 5554 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
Advertisement
Yann L hosted a lecture on the #Lecture channel on AfterNET about Realistic Water Rendering a while back. It''s a good read. Here is the log.


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
thx,but why not use material,
I didn''t know when shoule i use material,
Use material will get low performance??

Share this post


Link to post
Share on other sites
Because use texture with alpha channel only define four vectex.
use transparence material + texture must need define N vectex.

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
Can''t get the links to work...
would really like to see the water in action...
i have done an animated water in my game, just 5 frames and setTexture when changing but its not that exciting looking

Share this post


Link to post
Share on other sites
You can download it late,the web server might idle now.

Could you upload the screenshot of your water-effect? THX

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!