视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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

UUSL关键字和类型

This documentation article contains information about keywords, data types, pre-defined variables, constants and other features of the UUSL. This information can be used as the reference document for writing shaders.本文档文章包含有关UUSL的关键字,数据类型,预定义变量,常量和其他功能的信息。此信息可用作编写着色器的参考文档。

To start using UUSL, include the core/shaders/common/common.h file.要开始使用UUSL,请包含core/shaders/common/common.h文件。

UUSL
#include <core/shaders/common/common.h>

For fragment shader functions, use the core/shaders/common/fragment.h file.对于片段着色器功能,请使用core/shaders/common/fragment.h文件。

For scalar and double types and functions, use the core/shaders/common/double_math.h file.对于标量,双精度类型和函数,请使用core/shaders/common/double_math.h文件。

Data Types资料类型#

This articles contains different data types of UUSL.本文包含UUSL的不同数据类型。

UUSL OpenGL Direct3D 描述
int2 ivec2 int2 A vector with two 32-bit signed integer components.具有两个32位带符号整数分量的向量。
int3 ivec3 int3 A vector with three 32-bit signed integer components.具有三个32位有符号整数分量的向量。
int4 ivec4 int4 A vector with four 32-bit signed integer components.具有四个32位带符号整数分量的向量。
uint2 uvec2 int2 A vector with two 32-bit unsigned integer components.具有两个32位无符号整数分量的向量。
uint3 uvec3 uint3 A vector with three 32-bit unsigned integer components.具有三个32位无符号整数分量的向量。
uint4 uvec4 uint4 A vector with four 32-bit unsigned integer components.具有四个32位无符号整数分量的向量。
float float float float float float A 32-bit floating point value. 32位浮点值。
float2 vec2 float2 A vector with two 32-bit floating point value components.具有两个32位浮点值分量的向量。
float3 vec3 float3 A vector with three 32-bit floating point value components.具有三个32位浮点值分量的向量。
float4 vec4 float4 A vector with four 32-bit floating point value components.具有四个32位浮点值分量的向量。
float2x2 mat2 float2x2 A matrix with 2 rows, 2 columns of 32-bit floating point value components.具有2行,2列的32位浮点值分量的矩阵。
float3x3 mat3 float3x3 A matrix with 3 rows, 3 columns of 32-bit floating point value components.具有3行,3列的32位浮点值分量的矩阵。
float4x4 mat4 float4x4 A matrix with 4 rows, 4 columns of 32-bit floating point value components.具有4行,4列的32位浮点值分量的矩阵。
double2 dvec2 double2 A vector with two 64-bit double-precision floating point value components.具有两个64位双精度浮点值分量的向量。
double3 dvec3 double3 A vector with three 64-bit double-precision floating point value components.具有三个64位双精度浮点值分量的向量。
double4 dvec4 double4 A vector with four 64-bit double-precision floating point value components.具有四个64位双精度浮点值分量的向量。
double2x2 dmat2 double2x2 A matrix with 2 rows, 2 columns of 64-bit double-precision floating point value components.具有2行2列的64位双精度浮点值组成的矩阵。
double3x3 dmat3 double3x3 A matrix with 3 rows, 3 columns of 64-bit double-precision floating point value components.具有3行3列的64位双精度浮点值组成的矩阵。
double4x4 dmat4 double4x4 A matrix with 4 rows, 4 columns of 64-bit double-precision floating point value components.具有4行,4列的64位双精度浮点值组成的矩阵。
scalar float / double float / double A scalar value, which can be either float or double depending on precision (UNIGINE_DOUBLE flag).标量值,根据精度(UNIGINE_DOUBLE标志),可以为 float double
scalar2 vec2 / dvec2 float2 / double2 A vector consisting of two scalar components, which can be either float or double depending on precision (UNIGINE_DOUBLE flag).由两个标量分量组成的向量,根据精度(UNIGINE_DOUBLE标志),它们可以是 float double
scalar3 vec3 / dvec3 float3 / double3 A vector consisting of three scalar components, which can be either float or double depending on precision (UNIGINE_DOUBLE flag).由三个标量分量组成的向量,根据精度(UNIGINE_DOUBLE标志),它们可以是 float double
scalar4 vec4 / dvec4 float4 / double4 A vector consisting of four scalar components, which can be either double or float depending on precision (UNIGINE_DOUBLE flag).一个由四个标量分量组成的向量,根据精度(UNIGINE_DOUBLE标志),它可以是 double float


Use these variable aliases when working with textures to make your shader's code readable:

在使用纹理时,请使用这些变量别名,以使着色器的代码可读:

UUSL OpenGL Direct3D 描述
TYPE_R float float A 32-bit floating point value. 32位浮点值。
TYPE_RG float2 float2 A vector with two 32-bit floating point value components.具有两个32位浮点值分量的向量。
TYPE_RGB float3 float3 A vector with three 32-bit floating point value components.具有三个32位浮点值分量的向量。
TYPE_RGBA float4 float4 A vector with four 32-bit floating point value components.具有四个32位浮点值分量的向量。
TYPE_INT int int A 32-bit signed integer value.一个32位带符号整数值。
TYPE_UINT uint uint A 32-bit unsigned integer value. 32位无符号整数值。

Functions for type casting are the same for both DirectX and OpenGL: DirectX和OpenGL的类型转换功能相同:

功能 描述
int to_int(v) Create an integer from the value.从该值创建一个整数。
int2 to_int2(v) Create a two-component integer vector from the value.从该值创建一个包含两个分量的整数向量。
int3 to_int3(v) Create a three-component integer vector from the value.从该值创建一个三分量整数向量。
int4 to_int4(v) Create a four-component integer vector from the value.从该值创建一个四分量整数向量。
uint to_uint(v) Create an unsigned integer from the value.从该值创建一个无符号整数。
uint2 to_uint2(v) Create a two-component unsigned integer vector from the value.从该值创建一个两部分无符号整数向量。
uint3 to_uint3(v) Create a three-component unsigned integer vector from the value.从该值创建一个三分量无符号整数向量。
uint4 to_uint4(v) Create a four-component unsigned integer vector from the value.从该值创建一个四分量无符号整数向量。
float to_float(v) Create a float from the value.从该值创建一个浮点数。
float2 to_float2(v) Create a two-component floating-point vector from the value.从该值创建一个包含两个分量的浮点向量。
float3 to_float3(v) Create a three-component floating-point vector from the value.从该值创建一个三分量浮点向量。
float4 to_float4(v) Create a four-component floating-point vector from the value.从该值创建一个四分量浮点向量。
float4 to_gvec4(float v) Create a four-component floating-point vector from the value.从该值创建一个四分量浮点向量。
float4 to_gvec4(float2 v) Create a four-component floating-point vector from the two-component floating-point vector.从两分量浮点向量创建四分量浮点向量。
float4 to_gvec4(float3 v) Create a four-component floating-point vector from the three-component floating-point vector.从三分量浮点向量创建四分量浮点向量。
float4 to_gvec4(float4 v) Create a four-component floating-point vector from the four-component floating-point vector.从四分量浮点向量创建四分量浮点向量。
int4 to_gvec4(int v) Create a four-component integer vector from the integer value.从整数值创建一个四分量整数向量。
int4 to_gvec4(int2 v) Create a four-component integer vector from the two-component integer vector.从二分量整数向量创建四分量整数向量。
int4 to_gvec4(int3 v) Create a four-component integer vector from the three-component integer vector.从三分量整数向量创建四分量整数向量。
int4 to_gvec4(int4 v) Create a four-component integer vector from the four-component integer vector.从四分量整数向量创建四分量整数向量。
uint4 to_gvec4(uint v) Create a four-component unsigned integer vector from the unsigned integer value.从无符号整数值创建四分量无符号整数矢量。
uint4 to_gvec4(uint2 v) Create a four-component unsigned integer vector from the two-component unsigned integer vector.从两分量无符号整数向量创建四分量无符号整数向量。
uint4 to_gvec4(uint3 v) Create a four-component integer vector from the three-component unsigned integer vector.从三分量无符号整数向量创建四分量整数向量。
uint4 to_gvec4(uint4 v) Create a four-component unsigned integer vector from the four-component unsigned integer vector.从四分量无符号整数向量创建四分量无符号整数向量。
double to_double(v) Create a double-precision value from the value.从该值创建一个双精度值。
double2 to_double2(v) Create a two-component double-precision vector from the value.根据该值创建一个包含两个分量的双精度向量。
double3 to_double3(v) Create a three-component double-precision vector from the value.从该值创建一个三分量双精度向量。
double4 to_double4(v) Create a four-component double-precision vector from the value.从该值创建一个四分量双精度向量。
scalar to_scalar(v) Create a scalar value from the value.从该值创建标量值。
scalar2 to_scalar2(v) Create a two-component scalar value from the value.从该值创建一个包含两个分量的标量值。
scalar3 to_scalar3(v) Create a three-component scalar value from the value.根据该值创建一个三分量标量值。
scalar4 to_scalar4(v) Create a four-component scalar value from the value.从该值创建一个四分量标量值。

Defined Values定义值#

UUSL Value
float_isrgb 2.233333f
float4_zero float4(0.0f,0.0f,0.0f,0.0f)
float4_one float4(1.0f,1.0f,1.0f,1.0f)
float4_half float4(0.5f,0.5f,0.5f,0.5f)
float4_neg_one float4(-1.0f,-1.0f,-1.0f,-1.0f)
float4_isrgb float4(float_isrgb,float_isrgb,float_isrgb,float_isrgb)
float3_zero float3(0.0f,0.0f,0.0f)
float3_one float3(1.0f,1.0f,1.0f)
float3_half float3(0.5f,0.5f,0.5f)
float3_neg_one float3(-1.0f,-1.0f,-1.0f)
float3_up float3(0.0f,0.0f,1.0f)
float3_isrgb float3(float_isrgb,float_isrgb,float_isrgb)
float3_epsilon float3(EPSILON,EPSILON,EPSILON)
float3_luma float3(0.299f,0.587f,0.114f)
float2_zero float2(0.0f,0.0f)
float2_one float2(1.0f,1.0f)
float2_half float2(0.5f,0.5f)
float2_neg_one float2(-1.0f,-1.0f)
float2_isrgb float2(float_isrgb,float_isrgb)
int4_zero int4(0,0,0,0)
int4_one int4(1,1,1,1)
int4_neg_one int4(-1,-1,-1,-1)
int3_zero int3(0,0,0)
int3_one int3(1,1,1)
int3_neg_one int3(-1,-1,-1)
int2_zero int2(0,0)
int2_one int2(1,1)
int2_neg_one int2(-1,-1)
double3_zero double3(DF(0.0),DF(0.0),DF(0.0))
double3_one double3(DF(1.0),DF(1.0),DF(1.0))
float4x4_identity float4x4(1.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f,0.0f,0.0f,0.0f,1.0f)
PI 3.141592654f
PI2 6.283185308f
PI05 1.570796327f
LOG2 0.693147181f
LOG10 2.302585093f
SQRT2 1.414213562f
EPSILON 1e-6f
INT_MAX 4294967294
INFINITY 1e+9f
DEG2RAD PI / 180.0f
RAD2DEG 180.0f / PI
BYTE_UNORM_STEP 1.0f / 255.0f
WIREFRAME_DEPTH_BIAS -0.001f - if s_taa is 1.0f; otherwise, -0.0001f
STATICARRAY (float2,halton16,16) Array containing Halton sequence.
STATICARRAY (float2,halton8,8) Array containing Halton sequence.
STATICARRAY (uint,dither_pattern,16) Array containing disperced dither pattern.
STATICARRAY (float4,blue_noise_16x16,256) Array containing blue noise texture.

Use the following defined values in double-precision functions.双精度函数中使用以下定义的值。

PI_D DF(3.14159265358979323846)
PI2_D DF(6.28318530717958647693)
IPI2_D DF(0.15915494309189533576)
PI05_D DF(1.57079632679489661923)
DEG2RAD_D DF(0.01745329251994329577)
RAD2DEG_D DF(57.29577951308232087685)
EPSILON_D 1e-7

Bit masking defined values位屏蔽定义值#

The following defined values are reserved bits of the Material mask.以下定义的值是 Material掩码的保留位。

SSAO_BIT 1<<31
SSR_BIT 1<<30
SSS_BIT 1<<29
DOF_BIT 1<<28
MOTION_BLUR_BIT 1<<27
SHADOW_SHAFTS_BIT 1<<26
LIGHTMAP_WITH_AMBIENT_BIT 1<<25
SHORELINE_WETNESS_BIT 1<<24
FREE_MATERIAL_MASK 1<<0x00FFFFFF
RESERVED_MATERIAL_MASK 1<<0xFF000000

Main Function主功能#

Void Main Function虚空主要功能#

To start and end the void Main function of the fragment shader (when you don't need to provide the output color value but depth), use the following instructions:要开始和结束片段着色器的void Main功能(当您不需要提供输出颜色值但需要提供深度时),请使用以下说明:

UUSL
MAIN_VOID_BEGIN(STRUCT_IN)
	<your code here>
MAIN_VOID_END
警告
You should add a new line (press Enter) after closing the instruction.您应在关闭指令后添加新行(按Enter)。

This code is equivalent to:此代码等效于:

OpenGL
void main() {
	<your code here>
}
Direct3D
void main(STRUCT_IN IN) {
	<your code here>
}

Main Function with Return Value具有返回值的主要功能#

To start and end the Main function with return value, use the following instructions:要使用返回值开始和结束Main函数,请使用以下指令:

UUSL
MAIN_BEGIN(STRUCT_OUT,STRUCT_IN)
	<your code here>
MAIN_END
警告
You should add a new line (press Enter) after closing the instruction.您应在关闭指令后添加新行(按Enter)。

This code is equivalent to:此代码等效于:

OpenGL
void main() {
	<your code here>
}
Direct3D
STRUCT_OUT main(STRUCT_IN IN) { 
	STRUCT_OUT OUT;
	<your code here>
return OUT; }

Geometry Shader Main Function几何着色器主要功能#

To start and end the Main function of the geometry shader, use the following instructions:要启动和结束几何着色器的Main功能,请使用以下指令:

UUSL
MAIN_GEOM_BEGIN(STRUCT_OUT,STRUCT_IN)
	<your code here>
END_GEOM
警告
You should add a new line (press Enter) after closing the instruction.您应在关闭指令后添加新行(按Enter)。

This code is equivalent to:此代码等效于:

OpenGL
layout(TYPE_GEOM_IN) in;
layout(TYPE_GEOM_OUT,max_vertices = MAX_VERTICES_GEOM) out;
void main() {
	<your code here>
}
Direct3D
[maxvertexcount(MAX_VERTICES_GEOM)]
void main(TYPE_GEOM_IN STRUCT_IN IN[COUNT_GEOM_IN],inout TYPE_GEOM_OUT<STRUCT_OUT> stream) {
	STRUCT_OUT OUT;
	<your code here>
}

Global Variables全局变量#

To define a global variable, use the following syntax:要定义全局变量,请使用以下语法:

UUSL
GLOBAL <your var>

This is equal to the following GLSL and HLSL commands:这等于以下GLSL和HLSL命令:

OpenGL
uniform <your var>
Direct3D
uniform <your var>

Static Variables and Arrays静态变量和数组#

Static Variables静态变量#

To define a static variable, use the following syntax:要定义静态变量,请使用以下语法:

UUSL
STATICVAR <your var>

This is equal to the following GLSL and HLSL commands:这等同于以下GLSL和HLSL命令:

OpenGL
const <your var>
Direct3D
static const <your var>

Static Arrays静态数组#

To work with static arrays by using UUSL, use the following instructions:要使用UUSL处理静态数组,请使用以下说明:

UUSL
STATICARRAY(TYPE,NAME,SIZE)
	<your array members>
ENDARRAY
警告
You should add a new line (press Enter) after closing the instruction.您应在关闭指令后添加新行(按Enter)。
  • TYPE - the type of the array (float, etc.). TYPE-数组的类型(浮点型等)。
  • NAME - the name of the array. NAME-数组的名称。
  • SIZE - the size of the array. SIZE-数组的大小。

This code block is equivalent to:此代码块等效于:

OpenGL
TYPE NAME [SIZE] = TYPE[](<your array members>);
Direct3D
static const TYPE NAME [SIZE] = {<your array members>};

Blending Presets混合预设#

UUSL contains blending presets. When you specify the type of blending in material, the USSL wrapper automatically defines a new definition, that you can use in your shader: UUSL包含混合预设。当您指定材质中的混合类型时,USSL包装器会自动定义一个新定义,您可以在着色器中使用它。

Blending type UUSL
BLEND_SRC_FUNC_SRC_ALPHA && BLEND_DEST_FUNC_ONE_MINUS_SRC_ALPHA BLEND_ALPHABLEND
BLEND_SRC_FUNC_ONE && BLEND_DEST_FUNC_ONE BLEND_ADDITIVE
BLEND_SRC_FUNC_DEST_COLOR && BLEND_DEST_FUNC_ZERO BLEND_MULTIPLICATIVE
BLEND_SRC_FUNC_NONE && BLEND_DEST_FUNC_NONE BLEND_NONE

HLSL featuresHLSL功能#

HLSL Flow Control AttributesHLSL流控制属性#

UUSL OpenGL Direct3D 描述
branch - [branch] Performs branching using control flow instructions.使用控制流指令执行分支。
call - [call] Prevents inlining of a function.防止函数内联。
flatten - [flatten] Performs branching using conditional move instructions.使用条件移动指令执行分支。
ifAll - [ifAll] Executes the conditional part of an if statement when the condition is true for all threads on which the current shader is running.当运行当前着色器的所有线程的条件为true时,执行 if 语句的条件部分。
ifAny - [ifAny] Executes the conditional part of an if statement when the condition is true for any thread on which the current shader is running.当运行当前着色器的任何线程的条件为true时,执行 if 语句的条件部分。
isolate - [isolate] Optimizes the specified HLSL code independently of the surrounding code.独立于周围的代码优化指定的HLSL代码。
loop - [loop] Gives preference to flow control constructs.优先考虑流控制构造。
maxexports - [maxexports] Specifies the maximum number of export instructions that will execute along any path from the entry point to an exit.指定将在从入口点到出口的任何路径上执行的导出指令的最大数量。
maxInstructionCount - [maxInstructionCount] Sets the maximum number of instructions available to a shader.设置着色器可用的最大指令数。
maxtempreg - [maxtempreg] Restricts temporary register usage to the number of registers specified. Generates a compiler error if unsuccessful.将临时寄存器的使用限制为指定的寄存器数。如果失败,将生成编译器错误。
noExpressionOptimizations - [noExpressionOptimizations] Avoids optimization of expressions.避免表达式的优化。
predicate - [predicate] Performs branching by using predication.使用谓词执行分支。
predicateBlock - [predicateBlock] Performs branching by using predicated exec blocks.通过使用谓词 exec 块执行分支。
reduceTempRegUsage - [reduceTempRegUsage] Restricts temporary register usage to the number of registers specified. Generates a compiler warning if unsuccessful.将临时寄存器的使用限制为指定的寄存器数。如果失败,则生成编译器警告。
removeUnusedInputs - [removeUnusedInputs] Removes unused interpolator inputs from pixel shaders.从像素着色器中删除未使用的插值器输入。
sampreg - [sampreg] Sets the ranges of pixel sampler and vertex sampler registers used by the compiler.设置编译器使用的像素采样器和顶点采样器寄存器的范围。
unroll - [unroll] Avoids flow control constructs.避免使用流控制构造。
unused - [unused] Suppresses warnings about unused shader parameters.禁止显示有关未使用的着色器参数的警告。
xps - [xps] Specifies that all vertex fetch operations are done after the last vfetch instruction. This instruction is used to reduce the latency back to the command processor to free the vertex buffer.指定在最后一条vfetch指令之后完成所有顶点提取操作。该指令用于减少返回到命令处理器以释放顶点缓冲区的等待时间。
earlydepthstencil - [earlydepthstencil] Forces depth-stencil testing before a shader executes. Doesn't work with custom depth. 在着色器执行之前强制深度模板测试不适用于自定义深度。

Interpolation Modifiers插值修饰符#

UUSL OpenGL Direct3D 描述
MODIFER_LINEAR - linear Interpolate between shader inputs; linear is the default value if no interpolation modifier is specified.在着色器输入之间进行插值;如果未指定插值修饰符,则linear是默认值。
MODIFER_CENTROID - centroid Interpolate between samples that are somewhere within the covered area of the pixel (this may require extrapolating end points from a pixel center). Centroid sampling may improve antialiasing if a pixel is partially covered (even if the pixel center is not covered). The centroid modifier must be combined with either the linear or noperspective modifier.在像素覆盖区域内某处的样本之间进行插值(这可能需要从像素中心外推端点)。如果像素被部分覆盖(即使像素中心未被覆盖),质心采样也可以改善抗锯齿效果。质心修饰符必须与线性或非透视修饰符结合使用。
MODIFER_NOINTERPOLATION - nointerpolation Do not interpolate.请勿插值。
MODIFER_NOPERSPECTIVE - noperspective Do not perform perspective-correction during interpolation. The noperspective modifier can be combined with the centroid modifier.插值期间请勿执行透视校正。 noperspective修饰符可以与质心修饰符结合使用。
MODIFER_SAMPLE - sample Interpolate at sample location rather than at the pixel center. This causes the pixel shader to execute per-sample rather than per-pixel.在样本位置而不是像素中心进行插值。这将导致像素着色器执行每个样本而不是每个像素。

See Also也可以看看#

See also the article on Interpolation Modifiers.另请参见关于插值修饰符的文章

Constants and Structs常数和结构#

Structs结构#

In USSL structs is the way to organize the bunch of input and output data.在USSL结构中,是组织一堆输入和输出数据的方法。

To start using structs in your shader code, use the following instructions:要在着色器代码中开始使用结构,请使用以下说明:

UUSL
STRUCT(NAME)
	<your data>
END
警告
You should add a new line (press Enter) after closing the instruction.您应在关闭指令后添加新行(按Enter)。
  • NAME - the name of the struct. NAME-结构的名称。

Here is an example of vertex shader input struct:以下是顶点着色器输入结构的示例:

UUSL
// Input vertex data
STRUCT(VERTEX_IN)
	INIT_ATTRIBUTE(float4,0,POSITION)	// Vertex position
	INIT_ATTRIBUTE(float4,1,TEXCOORD0)	// Vertex texcoord (uv)
	INIT_ATTRIBUTE(float4,2,TEXCOORD1)	// Vertex basis tangent
	INIT_ATTRIBUTE(float4,3,TEXCOORD2)	// Vertex color
END
警告
You should add a new line (press Enter) after closing the instruction.您应在关闭指令后添加新行(按Enter)。

After that, you should pass the VERTEX_IN struct to the main function of the vertex shader. 之后,应将 _ VERTEX_IN结构传递给顶点着色器的主要功能。

Constants常数#

For using constant buffer in your shader code, use the following instructions:要在着色器代码中使用常量缓冲区,请按照以下说明进行操作:

UUSL
CBUFFER(NAME)
	<your data>
END
警告
You should add a new line (press Enter) after closing the instruction.您应在关闭指令后添加新行(按Enter)。
  • NAME - the name of the cbuffer. NAME-缓冲区的名称。

Here is an example of using constant buffer:以下是使用常量缓冲区的示例:

UUSL
CBUFFER(parameters)
	UNIFORM float grayscale_power;
END
警告
You should add a new line (press Enter) after closing the instruction.您应在关闭指令后添加新行(按Enter)。

If you defined this parameter in the material, you'll be able to specify this value.如果您在材料中定义了此参数,则可以指定此值。

See Also也可以看看#

  • How to use the CBUFFER instruction in the tutorial on shaders for post-process pass.如何在着色器上的CBUFFER instruction in the tutorial on shaders for post-process pass.

For Loop对于循环#

There is a for loop implemented in UUSL:在UUSL中实现了一个for循环:

UUSL
forloop(NAME,BEGIN,END)
UUSL
for(int NAME = (BEGIN); NAME < (END); NAME++)
警告
You should add a new line (press Enter) after closing the instruction.您应在关闭指令后添加新行(按Enter)。

The keyword for is used to describe a loop that is controlled by a counter (NAME). The parentheses enclose three expressions that initialize, check and update the variable used as counter. The body defined by curly braces encloses the statements that are executed at each pass of the loop.关键字for用于描述由计数器( NAME )控制的循环。括号内包含三个用于初始化,检查和更新用作计数器的变量的表达式。花括号定义的主体将在循环的每个遍次执行的语句括起来。

Here is an example of a for loop:这是一个for循环的示例:

UUSL
forloop(i, 0, 99)
{
	aFunction();
}

Shader Export着色器导出#

To export shader, use the following command:要导出着色器,请使用以下命令:

UUSL
EXPORT_SHADER(FILE)
  • FILE - The name of the file. FILE-文件名。

This command exports the shader program into a file: for Direct3D the file will have an .hlsl extension, for OpenGL the file will have an .glsl extension.此命令将着色器程序导出到文件中:对于Direct3D,文件将具有.hlsl扩展名,对于OpenGL,文件将具有.glsl扩展名。

The command expands all of the predefined UUSL syntax and creates shader files in native languages for both graphic APIs.该命令将扩展所有预定义的UUSL语法,并为两种图形API用本机语言创建着色器文件。

最新更新: 2020-11-11