Geometry-Shader Object

130 篇文章 5 订阅
57 篇文章 5 订阅

Geometry-Shader Object

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.
ShaderName

[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
lineadj Line list with adjacency or line strip with adjacency
triangleadj Triangle list with adjacency or triangle strip with adjacency

 

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.

lineadj

[4]

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

triangleadj

[6]

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

 

StreamOutputObject

The declaration of the stream-output object.

Return Value

None

Remarks

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

Illustration of the various primitive types for a geometry shader object

The following diagram shows geometry shader invocations.

Illustration of 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();
}


Minimum Shader Model

This object is supported in the following shader models.

Shader Model Supported
Shader Model 4 and higher shader models yes
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值