zoukankan      html  css  js  c++  java
  • Skybox边线消除的解决办法

        Skybox搞好后,发现在边线有很明显的裂缝,一开始时不知道如何解决,后来问了人,有人说把纹理采样改成Point,有人说纹理坐标改成0.001到0.999,这两样我都试过,发现改成Point裂缝是消除了,但看起来很不好看,改成0.001到0.999也有裂缝。
        后来再问了一位高手,他就说了句,把Texture Addressing改了就行了。然后叫我直接查看DX SDK,我看了几种texture的address模式,终于领悟了,要采用纹理寻址的Clamp Texture Address Mode,可查看SDK。再把纹理坐标改成是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(0sizeof(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();
  • 相关阅读:
    【LeetCode】两个有序数组合成一个有序数组(NEW)
    swiftmonkey 源码剖析及二次开发思路
    CentOS7 + Python3 + Django(rest_framework) + MySQL + nginx + uwsgi 部署 API 开发环境, 记坑篇
    Vue 5小时学习小教程
    【LeetCode】两数相加
    (vue.js)vue中引用了别的组件 ,如何使this指向Vue对象
    Monkey for Mac 环境配置
    [Vue] 初识Vue-常用指令
    利用Tkinter做的自动生成JSONSchema的小工具
    Linux下如何删除非空目录
  • 原文地址:https://www.cnblogs.com/lancidie/p/1987261.html
Copyright © 2011-2022 走看看