Geometry-Shader Object

转载 2015年11月18日 20:37:39

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  );




[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
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


You operate on only one point at a time.



A line requires two vertices.



A triangle requires three vertices.



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



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



The declaration of the stream-output object.

Return Value



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


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

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 );

Minimum Shader Model

This object is supported in the following shader models.

Shader Model Supported
Shader Model 4 and higher shader models yes

基于几何着色器的模型“爆炸”效果(Geometry Shader)【OpenGL】【GLSL】


Unity5 Compute && Geometry Shader

Compute ShaderCompute Shader技术是微软DirectX 11 API新加入的特性,在Compute Shader的帮助下,我们可以直接利用GPU的并行运算能力进行大量数据的运...
  • winchyy
  • winchyy
  • 2016年11月04日 15:29
  • 753

OpenGL学习脚印:几何着色器(geometry shader)

写在前面 一直以来我们使用了顶点着色器(vertex shader)和片元着色器(fragment shader),实际上OpenGL还提供了一个可选的几何着色器(geometry shad...

OpenGL 几何着色器 Geometry Shader 初探

在顶点和片段着色器之间有一个可选的着色器,叫做几何着色器(Geometry Shader)。几何着色器以一个或多个表示为一个单独基本图形(primitive)的顶点作为输入,比如可以是一个点或者三角形...
  • yulinxx
  • yulinxx
  • 2016年12月26日 00:35
  • 625

Geometry Shader

Geometry Shader(几何元着色器)是继Vertex Shader和Fragment Shader之后,由Shader Model 4(第四代显卡着色架构)正式引入的第三个着色器。在Open...

Geometry Shader Concepts & Examples

From 前言:Shader Model 4给我们带...

Geometry Shader 几何着色渲染

前言:Shader Model 4给我们带来了Geometry Shader这个玩意儿。其实这个东西早就在一些3D动画制作软件中存在了,比如Maya 8。我参考了以前DX10的哪一篇Preview与C...

【OpenGL4.0】GLSL-几何着色器详解和实例(GS:Geometry Shader)

一、什么是几何着色器(GS:Geometry Shader) Input Assembler(IA)从顶点缓冲区上的输入流中接收顶点数据,并且把数据项转换为规范的格式。vertex shad...

Geometry Shader 概念和实例

前言:Shader Model 4给我们带来了Geometry Shader这个玩意儿。其实这个东西早就在一些3D动画制作软件中存在了,比如Maya 8。我参考了以前DX10的哪一篇Preview与C...

OpenGL学习:几何着色器(geometry shader)

除了顶点着色器(vertex shader)和片元着色器(fragment shader),实际上OpenGL还提供了一个可选的几何着色器(geometry shader)。几何着色器位于顶点和片元着...
您举报文章:Geometry-Shader Object