关于DirectX11 Tessellation的问题。
在Hull Shader中,可设置的最大曲面细分因子为64(不确定原因)。现在虽然这对于小型飞机来说足够了,但对于大型飞机来说,它还不够,所以我想知道如何渲染大型飞机?
以下代码生成我的四边形,其中R
是半径:
vertices[0] = D3DXVECTOR3(-R, 0.0f, R); //Top left
vertices[1] = D3DXVECTOR3( R, 0.0f, R); //Top right
vertices[2] = D3DXVECTOR3( R, 0.0f, -R); //Bottom right
vertices[3] = D3DXVECTOR3(-R, 0.0f, -R); //Bottom left
vertices[4] = D3DXVECTOR3(-R, 0.0f, R); //Top left
vertices[5] = D3DXVECTOR3( R, 0.0f, -R); //Bottom right
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 3;
indices[4] = 4;
indices[5] = 5;
我确实通过将它放在循环中来修改它,以在3x3网格中生成多个四边形。然而,当我将它传递给曲面细分着色器时,它适用于第一个四边形但其他人搞砸了。
vector<D3DXVECTOR3> verts;
vector<D3DXVECTOR2> tex;
float R = 1000;
for(int z = 0; z < 4; z++)
{
for(int x = 0; x < 4; x++)
{
float xOffset = x * (2*R);
float zOffset = z * (2*R);
// Load the vertex array with data.
verts.push_back( D3DXVECTOR3(-R+ xOffset, 0.0f, R+ zOffset) ); //Top left
verts.push_back( D3DXVECTOR3( R+ xOffset, 0.0f, R+ zOffset) ); //Top right
verts.push_back( D3DXVECTOR3( R+ xOffset, 0.0f, -R+ zOffset) ); //Bottom right
verts.push_back( D3DXVECTOR3(-R+ xOffset, 0.0f, -R+ zOffset) ); //Bottom left
verts.push_back( D3DXVECTOR3(-R+ xOffset, 0.0f, R+ zOffset) ); //Top left
verts.push_back( D3DXVECTOR3( R+ xOffset, 0.0f, -R+ zOffset) ); //Bottom right
tex.push_back( D3DXVECTOR2(0.0f, 0.0f) );
tex.push_back( D3DXVECTOR2(1.0f, 0.0f) );
tex.push_back( D3DXVECTOR2(0.0f, 1.0f) );
tex.push_back( D3DXVECTOR2(0.0f, 1.0f) );
tex.push_back( D3DXVECTOR2(1.0f, 0.0f) );
tex.push_back( D3DXVECTOR2(1.0f, 1.0f) );
}
}
// Set the number of vertices in the vertex array.
m_vertexCount = verts.size();
// Set the number of indices in the index array.
m_indexCount = verts.size();
// Create the vertex array.
vertices = new VertexType[m_vertexCount];
if(!vertices)
{
return false;
}
// Create the index array.
indices = new unsigned long[m_indexCount];
if(!indices)
{
return false;
}
for(int i = 0; i < m_vertexCount; i++)
{
vertices[i].position = verts[i];
vertices[i].texture = tex[i];
indices[i] = i;
}
这是我渲染循环平面时的样子:
使用多个四边形时怎么没有正确镶嵌? 我应该通过在我的图形类中创建一个循环来解决这个问题,然后我翻译并一遍又一遍地渲染相同的四边形以创建网格吗?
希望这是有道理的。