【发布时间】:2011-04-04 07:07:20
【问题描述】:
我最近开始在 directX10 中进行原始渲染。我需要它,因为我想将我的游戏内聊天从 directx9 转换为 10,因为游戏弱 dx9 支持迫使我存在巨大的性能滞后。这些线条在我想要的位置上渲染得很好。我的实际问题是它们看起来不像directX9(1像素宽度)那样薄。它们似乎比像素还要厚。我已经阅读了一些信息,发现一些信息可以使用某种几何着色器来解决这个问题。有谁知道这将如何工作以及它在代码方面的表现如何?我没那么深入。
附加的是drawLine方法(我相信不需要初始化,如果需要我会立即发布)
void drawLine(int x1, int y1, int x2, int y2, D3DCOLOR lineColor) {
VERTEX Vertices[] = {
/*p1*/{getScreenPercentage(x1, y1), lineColor}, //getScreenPercentage puts the given screencoords into the rasterized state
/*p2*/{getScreenPercentage(x2, y2), lineColor}
};
pDevice->IASetInputLayout(pVertexLayout);
UINT stride = sizeof(VERTEX);
UINT offset = 0;
pDevice->IASetVertexBuffers(0, 1, &p2pBuffer, &stride, &offset);
VERTEX* pVoid;
p2pBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&pVoid);
pVoid[0] = Vertices[0];
pVoid[1] = Vertices[1];
p2pBuffer->Unmap();
pDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_LINELIST);
pPass->Apply(0);
pDevice->Draw(2, 0);
}
还有我的影响
char szEffect[] =
"struct DATA"
"{"
" float4 Pos : SV_POSITION;"
" float4 Color : COLOR;"
"};"
"DATA VS(float4 Pos : POSITION, float4 Col : COLOR)"
"{"
" DATA Data;"
" Data.Pos = Pos;"
" Data.Color = Col;"
" return Data;"
"}"
"float4 PS(DATA Data) : SV_TARGET"
"{"
" return Data.Color;"
"}"
"technique10 T0"
"{"
" pass P0"
" {"
" SetVertexShader(CompileShader(vs_4_0, VS()));"
" SetGeometryShader(NULL);"
" SetPixelShader(CompileShader(ps_4_0, PS()));"
" }"
"}";
Bad Company 2 中在窗口模式下以最高设置运行的输出示例(也已在 AA 关闭的情况下尝试最低)
【问题讨论】:
-
您想要屏幕宽度固定的 3D 线条吗? (如使用 glLineWidth 命令)
-
我想画 2D。 DX9 工作正常,1px 细线:img828.imageshack.us/img828/8417/lolwf.png DX10 是我的问题,没有一条 px 细线:img828.imageshack.us/img828/346/screenshotvg.png
-
我已经在我的 DX10 测试环境中测试了代码。那里的线条看起来很好。所以我很确定它的某些 renderState 或其他东西在游戏环境中运行时会强制该错误。我尝试使用 ->ClearnState() 重置设备状态,但没有成功。
标签: directx drawing primitive directx-10 drawing2d