590人阅读 评论(0)

A geometry-shader object processes entire primitives. Use the following syntax to declare a geometry-shader object.

 [maxvertexcount(NumVerts)]void ShaderName (  PrimitiveType DataType Name [ NumElements ],  inout StreamOutputObject  );

## Parameters

[maxvertexcount(NumVerts)]

[in] Declaration for the maximum number of vertices to create.

• [maxvertexcount()] - required keyword; brackets and parenthesis are required characters for correct syntax.
• NumVerts - An integer number representing the number of vertices.

[in] An ASCII string that contains a unique name for the geometry-shader function.

PrimitiveType DataType Name [ NumElements ]

PrimitiveType - Primitive type, which determines the order of the primitive data.

Primitive Type Description
point Point list
line Line list or line strip
triangle Triangle list or triangle strip

DataType - [in] An input data type; can be any HLSL data type.

Name - Argument name; this is an ASCII string.

NumElements - Array size of the input, which depends on the PrimitiveType as shown in the following table.

Primitive Type NumElements
point

[1]

You operate on only one point at a time.

line

[2]

A line requires two vertices.

triangle

[3]

A triangle requires three vertices.

[4]

A lineadj has two ends; therefore, it requires four vertices.

[6]

A triangleadj borders three more triangles; therefore, it requires six vertices.

StreamOutputObject

The declaration of the stream-output object.

None

## Remarks

The following diagram shows the various primitive types for a geometry shader object.

The following diagram shows geometry shader invocations.

## Examples

This example is from exercise 1 from the Direct3D 10 Shader Model 4.0 Workshop.

[maxvertexcount(3)]
void GSScene( triangleadj GSSceneIn input[6], inout TriangleStream<PSSceneIn> OutputStream )
{
PSSceneIn output = (PSSceneIn)0;

for( uint i=0; i<6; i+=2 )
{
output.Pos = input[i].Pos;
output.Norm = input[i].Norm;
output.Tex = input[i].Tex;

OutputStream.Append( output );
}

OutputStream.RestartStrip();
}



This object is supported in the following shader models.

1
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：536071次
• 积分：8058
• 等级：
• 排名：第2515名
• 原创：201篇
• 转载：155篇
• 译文：8篇
• 评论：171条
博客专栏
 游戏开发中的相机技术 文章：2篇 阅读：3109
 游戏开发设计模式 文章：5篇 阅读：12976
 游戏中人工智能的学习与应用 文章：6篇 阅读：14499