I have a exercise in my book that says draw a circle with a LineStrip then make a cylinder with the geometry shader with no caps.
Here is what I want in the image.
So far I have worked on making the like the image above but no luck
Here is what I got.
Here is my code.
My geometry shader code is
[maxvertexcount(2)]
void GS(line VertexOut gin[2],
inout LineStream<GeoOut> stream)
{
float3 up = float3(0.0f, 1.0f, 0.0f);
float3 look = gEyePosW - gin[0].CenterW;
look.y = 0.0f; // y-axis aligned, so project to xz-plane
look = normalize(look);
float3 right = cross(up, look);
float halfWidth = 0.5f*gin[0].SizeW.x;
float halfHeight = 0.5f*gin[0].SizeW.y;
float4 v[3];
v[0] = float4(gin[0].CenterW + halfHeight*up*10, 1.0f);
v[1] = float4(gin[0].CenterW - halfHeight*up*10, 1.0f);
GeoOut gout;
[unroll]
for(int i = 0; i < 2; ++i)
{
gout.PosH = mul(v[i], gViewProj);
gout.PosW = v[i].xyz;
gout.NormalW = look;
gout.Tex = gTexC[i];
stream.Append(gout);
}
}
My vertex code is
void TreeBillboardApp::BuildCylinder()
{
Vertex::Cyl v[vertexcount];
UINT count = 20;
for(UINT i = 0; i < count; ++i)
{
v[i].Pos = XMFLOAT3(5 * cosf(i),1.0f, 5 * sinf(i));
}
D3D11_BUFFER_DESC vbd;
vbd.Usage = D3D11_USAGE_IMMUTABLE;
vbd.ByteWidth = sizeof(Vertex::Cyl) * count;
vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vbd.CPUAccessFlags = 0;
vbd.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA vinitData;
vinitData.pSysMem = v;
HR(md3dDevice->CreateBuffer(&vbd, &vinitData, &CylinderVB));
}
How can I make mine like the first image? Need some ideas.