This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

UUSL Tessellation

Since UUSL supports tessellation, there are additional functions, semantics and parameters for tessellation shaders.

Tessellation requires new shader types: hull (also known as control) shader and evaluation (also known as domain). Hull shaders have a *.hull extension, evaluation shaders have a *.eval extension.

The essential thing of the tessellation is SET_QUAD_DOMAIN define. It defines the type of tessellator input: if you use it the tessellator will have quads input, otherwise triangles.

Prior Knowledge
This article assumes you have prior knowledge of the tessellation. Also, read the following topics before proceeding:

Tessellation Attributes#

You should specify the tessellation attributes in both tessellation shaders (hull and evaluation). These attributes defines the type of patches, and primitive topologies.

Domain Patch Type#

If you have used the SET_QUAD_DOMAIN define, the engine will use the quad patches:

Direct3D
#define DOMAIN_PATCH [domain("quad")]
#define DOMAIN_PATCH_VERTICES 4

Otherwise, the engine will use triangle patches:

Direct3D
#define DOMAIN_PATCH [domain("tri")]
#define DOMAIN_PATCH_VERTICES 3

Partitioning Scheme#

Partitioning scheme of the tessellator is defined by the SET_PARTITIONING function:

SET_PARTITIONING ( value VALUE ) #

Specifies the partitioning scheme the tessellator should use for dividing patches.

Arguments

  • value VALUE - The partitioning attribute. The value can be one of the following:
    • PARTITIONING_FRAC_ODD - the tessellation factor is rounded to the next odd integer within the [min;max] range.

      Equivalents

      Direct3D
      [partitioning("fractional_odd")]
    • PARTITIONING_FRAC_EVEN - the tessellation factor is rounded to the next even integer within the [min;max] range.

      Equivalents

      Direct3D
      [partitioning("fractional_even")]
    • PARTITIONING_POW2 - the tessellation is rounded to the next greatest power of 2, yielding the effective range [1, 2, 4, 8, 16, 32, 64].

      Equivalents

      Direct3D
      [partitioning("pow2")]
    • PARTITIONING_INTEGER - the tessellation factor is always rounded up to the nearest integral value, in the range within the [min;max] range.

      Equivalents

      Direct3D
      [partitioning("Integer")]

Tessellation Output Primitive Type#

SET_TOPOLOGY_PRIMITIVE ( value VALUE ) #

Defines the output primitive type for the tessellator.

Arguments

  • value VALUE - The output primitive type attribute. The value can be one of the following:
    • TRIANGLE_CW means clockwise-wound triangles (vertices rotate clockwise around the triangle's center).

      Equivalents

      Direct3D
      [outputtopology("triangle_cw")]
    • TRIANGLE_CCW triangle_cw means counter-clockwise-wound triangles (vertices rotate counter-clockwise around the triangle's center).

      Equivalents

      Direct3D
      [outputtopology("triangle_ccw")]

Tessellation Semantics#

Redefined UUSL semantics allows you to create unified input\output shader structures for both graphics APIs.

Hull (Control) Shader Semantics#

Initialization semantics for hull (control) shader:

UUSL Direct3D Description
INIT_CONTROL_IN(TYPE,NUM) TYPE data_ ## NUM : TEXCOORD ## NUM; Adds (initializes) a control (hull) shader input semantic.
INIT_CONTROL_OUT TYPE data_ ## NUM : TEXCOORD ## NUM; Adds (initializes) a control shader output data semantic.

Here is a usage example of hull shader input and output structure:

UUSL
STRUCT(CONTROL_IN)
	INIT_POSITION
	INIT_CONTROL_IN(float4,0)
	INIT_CONTROL_IN(float3,1)
END

STRUCT(CONTROL_OUT)
	INIT_POSITION
	INIT_CONTROL_OUT(float4,0)
END

// end of structures

Use the following pre-defined variables to use the input\output control shader semantics:

UUSL Direct3D Description
OUT_PATCH_EDGE(INDEX) output.edges[INDEX] Defines the tessellation amount on each edge of a patch.
OUT_CONTROL_DATA(NUM) output.data_ ## NUM An output texture coordinates variable.
IN_CONTROL_DATA(NUM,ID) input[ ## ID ## ].data_ ## NUM An input texture coordinates variable.
OUT_CONTROL_POSITION output.position An output position system-value variable.
IN_CONTROL_POSITION(ID) input[ ## ID ## ].position An input position variable.
CONTROL_POINT_ID --- Contains the coordinate of the vertex within the current patch.

If you have used the SET_QUAD_DOMAIN define, you should specify the index for this output semantic:

UUSL Direct3D Description
OUT_PATCH_INSIDE(INDEX) output.inside[INDEX] Defines the tessellation amount within a patch surface.
OUT_PATCH_INSIDE output.inside Defines the tessellation amount within a patch surface.

Evaluation (Domain) Shader Semantics#

Initialization semantics:

UUSL Direct3D Description
INIT_EVALUATE_IN(TYPE,NUM) TYPE data_ ## NUM : TEXCOORD ## NUM; Adds an input data semantic.
INIT_EVALUATE_OUT(TYPE,NUM) TYPE data_ ## NUM : TEXCOORD ## NUM; Adds an output data semantic.

Here is a usage example of evaluation shader input and output structure:

UUSL
STRUCT(EVALUATE_IN)
	INIT_POSITION
	INIT_EVALUATE_IN(float4,0)
END

STRUCT(EVALUATE_OUT)
	INIT_POSITION
	INIT_EVALUATE_OUT(float2,0)
	INIT_EVALUATE_OUT(float3,1)
	INIT_EVALUATE_OUT(float3,2)
	INIT_EVALUATE_OUT(float3,3)
	INIT_EVALUATE_OUT(float,4)
END

// end of structures

Use the following pre-defined variables to use the input\output control shader semantics:

UUSL Direct3D Description
OUT_EVALUATE_DATA(NUM) output.data_ ## NUM An output texture coordinates variable.
IN_EVALUATE_PATCH_DATA(NUM,ID) input[ ## ID ## ].data_ ## NUM An input patch data semantic.
OUT_EVALUATE_POSITION(NUM,ID) output.position An output position system-value variable.
IN_EVALUATE_PATCH_POSITION(ID) input[ ## ID ## ].position An input patch data position semantic value.
DOMAIN_LOCATION patch_constant.coords Contains the coordinate of the vertex within the current patch. Defines the location on the hull of the current domain point being evaluated.

Tessellation Main Functions#

Control Shader Main Function#

Hull shader requires the main shader function and patch constant function.

Patch Constant Function#

To start and end the main function of the control patch constant data, use the following instructions:

UUSL
MAIN_PATCH_CONSTANT_BEGIN(CONTROL_IN)

	<your code here>

END_PATCH_CONSTANT

//end

This code is equivalent to:

Direct3D
CONTROL_CONSTANT_OUT patch_constant(InputPatch<CONTROL_IN,DOMAIN_PATCH_VERTICES> input) {
CONTROL_CONSTANT_OUT output = (CONTROL_CONSTANT_OUT)0;

	<your code here>

return output; }
//

Hull Shader Function#

To start and end the main function of the hull shader, use the following instructions:

UUSL
MAIN_CONTROL_BEGIN(CONTROL_OUT, CONTROL_IN)

	<your code here>

MAIN_CONTROL_END

//end

This code is equivalent to:

Direct3D
DOMAIN_PATCH
[maxtessfactor(64.0f)]
[outputcontrolpoints(DOMAIN_PATCH_VERTICES)]
[patchconstantfunc("patch_constant")]
CONTROL_PARTITIONING_TYPE
CONTROL_TOPOLOGY_PRIMITIVE_TYPE
CONTROL_OUT main(InputPatch<CONTROL_IN,DOMAIN_PATCH_VERTICES> input,uint CONTROL_POINT_ID : SV_OUTPUTCONTROLPOINTID) { 
	CONTROL_OUT output;

	<your code here>

return output; }

Evaluation Shader Main Function#

To start and end the main function of the evaluation shader, use the following instructions:

UUSL
MAIN_EVALUATE_BEGIN(EVALUATE_OUT, EVALUTATE_IN)

	<your code here>

MAIN_EVALUATE_END

//end

This code is equivalent to:

Direct3D
DOMAIN_PATCH
EVALUATE_OUT main(EVALUATE_CONSTANT_IN patch_constant,const OutputPatch<EVALUATE_IN,DOMAIN_PATCH_VERTICES> input) {
	EVALUATE_OUT output;

	<your code here>

return output; }
//
Last update: 2024-08-16
Build: ()