Thursday, April 14, 2011

Geometry Shader

This tutorial will demonstrate the use of geometry shader.

Interfaces used:

Here's a simple geometry shader procedure which simply reads the input triangle data and appends the output data to existing stream. Inputs and outputs are vertex position, normal, texture coordinate and material color

void GSProc(triangle SVS_Output oInput[3], inout TriangleStream<SVS_Output> triOutputStream)
SVS_Output oVSOutput = (SVS_Output) 0;

// Loop to read the input triangle data
for(uint uiCount = 0; uiCount < 3; uiCount++)
// Pass the input data as is
oVSOutput.m_vecPosition = oInput[uiCount].m_vecPosition; // Position
oVSOutput.m_fNormal = oInput[uiCount].m_fNormal; // Normal
oVSOutput.m_fTexture = oInput[uiCount].m_fTexture; // Texture
oVSOutput.m_fMaterialColor = oInput[uiCount].m_fMaterialColor; // Material color

triOutputStream.Append(oVSOutput); // Append output data to an existing stream

triOutputStream.RestartStrip(); // End the current primitive strip

No comments:

Post a Comment