This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
Engine-Related Classes
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

UUSL Semantics

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

Vertex Shader Semantics

Vertex shader semantics contain necessary input and output data for shader. You should initialize variables first and then use them.

UUSLOpenGLDirect3DDescription
INIT_ATTRIBUTE(TYPE,NUM,SEMANTICS)in TYPE s_attribute_ ## NUM;TYPE attribute_ ## NUM : SEMANTICS;Adds a semantic to a vertex shader variable.
INIT_OUT(TYPE,NUM)out TYPE s_texcoord_ ## NUM;TYPE data_ ## NUM : TEXCOORD ## NUM;Adds an output data semantic.
INIT_POSITION-float4 position : SV_POSITION;Adds a position system-value semantic.
INIT_INSTANCE-uint instance : SV_INSTANCEID;Adds a per-instance identifier system-value semantic.

Here is an example of vertex shader input and output structures:

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

// Our output vertex data
STRUCT(VERTEX_OUT)
	INIT_POSITION		// Out projected position
	INIT_OUT(float4,0)	// Texcoord (uv)
	INIT_OUT(float3,1)	// Vertex direction
END
Warning
You should add a new line (press Enter) after closing the instruction.

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

UUSLOpenGLDirect3DDescription
IN_INSTANCEgl_InstanceIDinput.instanceAn input per-instance identifier system-value variable.
IN_ATTRIBUTE(NUM)s_attribute_ ## NUMinput.attribute_ ## NUMAn input shader variable.
OUT_DATA(NUM)s_texcoord_ ## NUMoutput.data_ ## NUMAn output texture coordinates variable.
OUT_POSITIONgl_Positionoutput.positionAn output position system-value variable.

Fragment Shader Semantics

Fragment shader semantics contain necessary input and output data for shader. You should initialize variables first and then use them.

UUSLOpenGLDirect3DDescription
INIT_IN(TYPE,NUM)in TYPE s_texcoord_ ## NUM;TYPE data_ ## NUM : TEXCOORD ## NUM;Adds an input texture coordinates semantic.
INIT_COLOR(TYPE)out TYPE s_frag_color;TYPE color : SV_TARGET;Add an output diffuse or specular color semantic (single RT).
INIT_DEPTH-float depth : SV_DEPTH;Add an output depth system-value semantic.
INIT_MRT(TYPE,NUM)out TYPE s_frag_data_ ## NUM;TYPE color_ ## NUM : SV_TARGET ## NUM;Add an output color system-value semantic (some RTs).
INIT_FRONTFACE---bool frontface : SV_ISFRONTFACE;Adds an input semantic indicates primitive face (frontface or not).

To use the variables in the code, use the following variables:

UUSLOpenGLDirect3DDescription
IN_POSITIONgl_FragCoordinput.positionAn input position value.
IN_DATA(NUM)s_texcoord_ ## NUMinput.data_ ## NUMAn input texture coordinates variable.
IN_FRONTFACE!gl_FrontFacinginput.frontfaceFloating-point scalar that indicates a back-facing primitive. A negative value faces backwards, while a positive value faces the camera.
OUT_COLORs_frag_coloroutput.colorAn output color value (single RT).
OUT_DEPTHgl_FragDepthoutput.depthAn output depth value.
OUT_MRT(NUM)out TYPE s_frag_data_ ## NUM;output.color_ ## NUMAn output color value for MRTs.

Here is a simple example of using the variable in the main function of the shader:

USUL
MAIN_BEGIN(FRAGMENT_OUT,FRAGMENT_IN)
	
	float4 texcoord = IN_DATA(0);

	/* ... other code ... */
END
Warning
You should add a new line (press Enter) after closing the instruction.

Geometry Shader Semantics

UUSLOpenGLDirect3DDescription
INIT_GEOM_IN(TYPE,NUM)in TYPE s_geom_texcoord_ ## NUM[];TYPE data_ ## NUM : TEXCOORD ## NUM;Add an input texture coordinates semantic for the geometry-shader stage.
INIT_GEOM_OUT(TYPE,NUM)out TYPE s_geom_texcoord_ ## NUM;TYPE data_ ## NUM : TEXCOORD ## NUM;Add an output texture coordinates semantic for the geometry-shader stage.
UUSLOpenGLDirect3DDescription
IN_GEOM_DATA(NUM,INDEX)s_geom_texcoord_ ## NUM ## [INDEX]input[INDEX].data_ ## NUMAn input texture coordinates value.
IN_GEOM_POSITION(INDEX) gl_in[INDEX].gl_Positioninput[INDEX].positionAn input position value.
OUT_GEOM_DATA(NUM)s_geom_texcoord_ ## NUMoutput.data_ ## NUMAn output texture coordinates value.
TRIANGLE_INtrianglestriangleInput primitive type: triangle list or triangle strip.
TRIANGLE_OUTtriangle_stripTriangleStreamOutput primitive type: a sequence of triangle primitives
LINE_INlineslineInput primitive type: line.
LINE_OUTline_stripLineStreamOutput primitive type: a sequence of line primitives
Last update: 03.07.2017
Build: ()