Skybox边线消除的解决办法

Skybox搞好后,发现在边线有很明显的裂缝。要采用纹理寻址的Clamp Texture Address Mode。再把纹理坐标改成是0.001到0.999。问题就完美解决了。
    渲染代码如下:
p3DDevice9 -> SetSamplerState( 0 , D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
    p3DDevice9
-> SetSamplerState( 0 , D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
    创建VB代码如下:
CUSTOMVERTEX_TXT cvVertices[]  =
    
{
        
//上面的点
        {vTBottomLeft, D3DCOLOR_XRGB(25500), 0.001f0.001f,}//Vertex 2 - Red
        {vTBottomRight, D3DCOLOR_XRGB(2552550), 0.999f0.001f,}//Vertex 3 - Green
        {vTTopLeft, D3DCOLOR_XRGB(255255255), 0.001f0.999f,}//Vertex 1 - Red 
        {vTTopRight, D3DCOLOR_XRGB(255255255), 0.999f0.999f,}//Vertex 0 - Blue 

        
//前面
        {vTTopLeft, D3DCOLOR_XRGB(255255255), 0.001f0.001f,}//Vertex 0 - Blue 
        {vTTopRight, D3DCOLOR_XRGB(255255255), 0.999f0.001f,}//Vertex 1 - Red 
        {vBTopLeft, D3DCOLOR_XRGB(255255255), 0.001f0.999f,}//Vertex 2 - Red 
        {vBTopRight, D3DCOLOR_XRGB(255255255), 0.999f0.999f,}//Vertex 3 - Green 

        
//右面
        {vTTopRight, D3DCOLOR_XRGB(255255255), 0.001f0.001f,}//Vertex 0 - Blue
        {vTBottomRight, D3DCOLOR_XRGB(02550), 0.999f0.001f,}//Vertex 3 - Green
        {vBTopRight, D3DCOLOR_XRGB(25500), 0.001f0.999f,}//Vertex 2 - Red 
        {vBBottomRight, D3DCOLOR_XRGB(255255255), 0.999f0.999f,}//Vertex 1 - Red 


        
//后面
        {vTBottomRight, D3DCOLOR_XRGB(255255255), 0.001f0.001f,}//Vertex 0 - Blue
        {vTBottomLeft, D3DCOLOR_XRGB(255255255), 0.999f0.001f,}//Vertex 0 - Blue
        {vBBottomRight, D3DCOLOR_XRGB(255255255), 0.001f0.999f,}//Vertex 1 - Red 
        {vBBottomLeft, D3DCOLOR_XRGB(255255255), 0.999f0.999f,}//Vertex 1 - Red 

        
//左面
        {vTBottomLeft, D3DCOLOR_XRGB(255255255), 0.001f0.001f,}//Vertex 0 - Blue 
        {vTTopLeft, D3DCOLOR_XRGB(255255255), 0.999f0.001f,}//Vertex 0 - Blue 
        {vBBottomLeft, D3DCOLOR_XRGB(255255255), 0.001f0.999f,}//Vertex 1 - Red 
        {vBTopLeft, D3DCOLOR_XRGB(255255255), 0.999f0.999f,}//Vertex 1 - Red

        
//下面
        {vBTopLeft, D3DCOLOR_XRGB(25500), 0.001f0.001f,}//Vertex 4 - Red 
        {vBTopRight, D3DCOLOR_XRGB(00255), 0.999f0.001f,}//Vertex 5 - Blue 
        {vBBottomLeft, D3DCOLOR_XRGB(02550), 0.001f0.999f,}//Vertex 6 - Green 
        {vBBottomRight, D3DCOLOR_XRGB(25500), 0.999f0.999f,}//Vertex 7 - Red 
    }
;

    
if (FAILED(p3DDevice9 -> CreateVertexBuffer( 24   *   sizeof (CUSTOMVERTEX_TXT),
        
0 , D3DFVF_CUSTOMVERTEX,
        D3DPOOL_DEFAULT, 
& m_pVertexBuffer, NULL)))
    
{
        
return FALSE;
    }


    VOID
*  pVertices  =  NULL;

    
if (FAILED(m_pVertexBuffer -> Lock( 0 sizeof (cvVertices), ( void ** ) & pVertices,  0 )))
    
{
        
return FALSE;
    }


    
// Copy our stored vertices values into the vertex buffer
    memcpy(pVertices, cvVertices,  sizeof (cvVertices));

    
// Unlock the vertex buffer
    m_pVertexBuffer -> Unlock();
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值