This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
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
创建内容
Content Optimization
Materials
Art Samples
Tutorials

Shaders

This type of node is used to describe a UUSL shader in an ULON-based material file. Currently, the engine supports Vertex, Control, Evaluate, Geometry, Fragment, and Compute shaders.

The syntax is the following:

ULON
Shader name =
#{
	// UUSL code
#}

As a node’s value you must specify a UUSL-based code enclosed in "#{" and "#}".

See the SDK/data/core/shaders/common/ directory for the list of headers implementing common shaders’ functions which can be included and used in custom shaders. To start writing UUSL shaders, include the common header:

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

Types of Shaders#

The following types of shaders corresponding to their counterparts in different graphic APIs are available:

Unigine DirectX OpenGL
Vertex Vertex Vertex
Control Hull Control
Evaluate Domain Evaluate
Geometry Geometry Geometry
Fragment Pixel Fragment
Compute Compute Compute

Usage Examples#

The shader node is usually used as a shader value for the Pass node.

ULON
Shader shader_a =
#{
	// some UUSL code
#}

Pass ambient
{
	Vertex = shader_a
	Fragment = shader_a
}

The advantages of this shader setup method are:

  • It reduces the amount of identical code.
  • One shader code can be used in different render passes.

On the other hand, it is not the best approach for large shaders. Use includes for these cases:

  1. Write different shaders in separate files and then specify their paths as shader values in the pass:
    shaders/a.vert (UUSL)
    // some UUSL code
    shaders/b.frag (UUSL)
    // some UUSL code
    Source code (ULON)
    Pass deferred 
    {
    	Vertex = "shaders/a.vert"
    	Fragment = "shaders/b.frag"
    }
  2. Include the code of a different shader by using the marker: #shader shader_name.
    Source code (ULON)
    Shader a = 
    #{
            // shader code A
    }#
    
    Shader b = 
    #{
            // shader code B
            #shader a
    }#
    
    // the result shader b will look like this: 
    Shader b = 
    #{
            // shader code B
            // shader code A
    #}
Last update: 2021-09-17
Build: ()