0
我知道,在頂點着色器,你做這樣的:?如何在DirectX11中的幾何着色器中實例化?
PixelInputType TextureVertexShader(VertexInputType input)
{
PixelInputType output;
// Change the position vector to be 4 units for proper matrix calculations.
input.position.w = 1.0f;
// Update the position of the vertices based on the data for this particular instance.
input.position.x += input.instancePosition.x;
input.position.y += input.instancePosition.y;
input.position.z += input.instancePosition.z;
// Calculate the position of the vertex against the world, view, and projection matrices.
output.position = mul(input.position, worldMatrix);
output.position = mul(output.position, viewMatrix);
output.position = mul(output.position, projectionMatrix);
// Store the texture coordinates for the pixel shader.
output.tex = input.tex;
return output;
}
什麼是在幾何着色器使用instancedPosition相當於就像當我想實例模型所做的1個頂點併爲每個實例在幾何着色器中創建一個四元組,並將四元組的位置設置爲實例緩衝區中相應實例的instancePosition的位置。