This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Landscape Tool
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
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 Creation
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: ()