This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
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
File Formats
Materials and Shaders
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
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unified Unigine Shader Language

The Unified UNIGINE shader language (UUSL) allows you to create a single shader file for both 3D graphics APIs: OpenGL and Direct3D11. The language brings pre-defined data types and implemented functions that simplifies and unifies shaders writing process.

This section of the Unigine documentation contains information about the UUSL syntax (unified data types, intrinsic functions, parameters, textures, semantics, etc.) and tutorials on creating shaders.

Frequently Asked Questions#

What is UUSL?#

The Unified UNIGINE shader language (UUSL) is a wrapper, which unifies the most part of GLSL and HLSL syntax. You can use the UUSL instructions to write shader code without graphic API defining: it will work on both APIs.

Should I write shaders by using UUSL only?#

Definitely not. UUSL is just a wrapper which facilitates the shader-writing process. You can also use an old-school approach by writing separately part of the shader for corresponding graphic API with GLSL and HLSL shading languages.

Which shader stages does the Unigine engine have?#

Unigine engine has the standard shaders pipeline: Vertex-Shader stageGeometry-Shader stageFragment-Shader stage. If you want to use tessellation, the pipeline will have 3 additional stages between vertex-shader and geometry-shader stages: Control-Shader stage, tessellation stage, Evaluation-Shader stage.

How are materials and shaders interrelated?#

Material specifies which shaders for defined rendering pass it will use to render. You can define vertex, geometry and fragment shaders for a material. When you assign the material, the engine starts using its shaders to render the image. A piece of cake!

Notice
Vertex and fragment shaders are mandatory for a material.

We have a neat article about the materials files formats, check it out.

How to start using UUSL?#

When you start writing shaders, include the UUSL headers and start coding!

Use the following commands to include the necessary headers:

USSL
// Include Unified Unigine Shader Language (UUSL) common header
#include <core/materials/shaders/api/common.h>

Do shaders need compilation?#

Yes, they do. But the engine does the job: just use the materials_reload console command if you made some changes in shader files. It is really handy: you don't need to compile the shader every time you made any changes, you see the result of the changes in runtime without engine restart!

Notice
If you made changes in the material .mat file, you should reload the engine.

Can I debug the UUSL shader code?#

Sure. If there is a shader error, the engine shows it in the console:

The message contains information about which file has errors and their description (including the number of line).

Export the shader file to the file and find this code line to figure out what's happen. Shader will be exported in a file with the graphic API shader format (.hlsl or .glsl) located relatively to the data folder.

How to create custom shader?#

Last update: 2022-06-01
Build: ()