【问题标题】:Weird D3D9 Bug when drawing绘图时出现奇怪的 D3D9 错误
【发布时间】:2017-08-02 02:10:44
【问题描述】:

所以我正在制作一个挂钩到游戏 D3D9::Present 的程序来绘制时钟并遇到问题,有时,例如当我在游戏中时,颜色会显得非常明亮,它会看起来很糟糕。

这就是我的意思

正常:

错误:

这就是我在制作状态块后所说的......

    m_Device->SetRenderState(D3DRS_VERTEXBLEND, D3DVBF_DISABLE);
    m_Device->SetRenderState(D3DRS_INDEXEDVERTEXBLENDENABLE, 0);
    m_Device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, 0);
    m_Device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
    m_Device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    m_Device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
    m_Device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
    m_Device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
    m_Device->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
    m_Device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
    m_Device->SetTextureStageState(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
    m_Device->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
    m_Device->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
    m_Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
    m_Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
    m_Device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
    m_Device->SetTexture(3, nullptr);
    m_Device->SetTexture(0, nullptr);
    m_Device->SetTexture(1, nullptr);
    m_Device->SetVertexShader(nullptr);
    m_Device->SetPixelShader(nullptr);
    m_Device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); //D3DZB_TRUE
    m_Device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
    m_Device->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
    m_Device->SetRenderState(D3DRS_ZWRITEENABLE, 0);
    m_Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); //D3DCULL_CCW
    m_Device->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL);
    m_Device->SetRenderState(D3DRS_FOGENABLE, 0);
    m_Device->SetRenderState(D3DRS_SPECULARENABLE, 0);
    m_Device->SetRenderState(D3DRS_STENCILENABLE, 0);
    m_Device->SetRenderState(D3DRS_CLIPPING, 0); //1
    m_Device->SetRenderState(D3DRS_LIGHTING, 0);
    m_Device->SetRenderState(D3DRS_COLORVERTEX, 1);
    m_Device->SetRenderState(D3DRS_CLIPPLANEENABLE, 0); //1
    m_Device->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
    m_Device->SetRenderState(D3DRS_ALPHABLENDENABLE, 1);
    m_Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); //D3DBLEND_ONE
    m_Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); //D3DBLEND_ZERO
    m_Device->SetRenderState(D3DRS_ALPHATESTENABLE, 1);
    m_Device->SetRenderState(D3DRS_ALPHAREF, 0x08);
    m_Device->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);

我正在用 m_Device->DrawPrimitiveUP 用 D3DPT_TRIANGLEFAN 绘制时钟的东西

所以我的问题是...您如何找出导致此问题的原因?我该如何解决?

【问题讨论】:

    标签: direct3d


    【解决方案1】:

    通过添加此渲染状态修复:D

        //Dis is fix for d3d9 appearing brighter??? or * 2.2 tha color orsoemthing called gammar correction
        m_Device->SetRenderState(D3DRS_SRGBWRITEENABLE, 0);
    

    【讨论】:

      猜你喜欢
      • 2020-12-27
      • 2021-08-27
      • 2011-01-08
      • 2020-05-26
      • 1970-01-01
      • 2013-02-25
      • 1970-01-01
      • 2023-04-08
      • 2019-03-10
      相关资源
      最近更新 更多