首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络游戏 >

地形纹理混合有关问题

2012-02-15 
地形纹理混合问题我的问题如下我有四张纹理图,分四次进行渲染,然后得到了四层纹理的混合的地形效果。现在我

地形纹理混合问题
我的问题如下
  我有四张纹理图,分四次进行渲染,然后得到了四层纹理的混合的地形效果。现在我需要加上第五层渲染,这层渲染得功能 是让我拾取的地形三角形显示为红色。我先在第五层渲染得时候选择漫反射颜色为红色,但是实际效果上,并没有显示红色,而是 根据漫反射颜色的alpha通道的值进行了透明处理,如果这个值为ff就是纯黑色,不知道是什么问题,我把主要代码放在下面了

C/C++ code
device->SetTexture(0, Tex_1);    device->SetRenderState( D3DRS_ALPHABLENDENABLE,TRUE);    device->SetRenderState( D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);    device->SetRenderState( D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);    device->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX,0);    device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );    device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );     //device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTA_DIFFUSE );     device->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );    device->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1 );    device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,rowidth*colheight,0,(rowidth-1)*(colheight-1)*2);    device->SetTexture(0, Tex_2);    device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );    device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );    device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,rowidth*colheight,0,(rowidth-1)*(colheight-1)*2);    device->SetTexture(0, Tex_3);    device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );    device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );    device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,rowidth*colheight,0,(rowidth-1)*(colheight-1)*2);    device->SetTexture(0, Tex_4);        device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);    device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );        device->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );    device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,rowidth*colheight,0,(rowidth-1)*(colheight-1)*2);    MyTr->Lock(0,0,(void **) &mymap,0);    for (int i =0;i<64*64;i++){        //mymap[i]._color=(diffusevt[i]<<24);                        mymap[i]._color=0xccff0000;                    }    MyTr->Unlock();        device->SetTexture(0, Tex_4);    device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE );        device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1  );    device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,rowidth*colheight,0,(rowidth-1)*(colheight-1)*2);


[解决办法]
0xccff0000

看你这个颜色,alpha为0的吧
[解决办法]
用shader自己合成吧

热点排行