This page has been translated automatically.
Видеоуроки
Interface
Essentials
Advanced
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Landscape Tool
Sandworm
Использование инструментов редактора для конкретных задач
Extending Editor Functionality
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World Nodes
Звуковые объекты
Объекты поиска пути
Players
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
Унифицированный язык шейдеров UUSL
Плагины
Rebuilding the Engine Tools
GUI
Двойная точность координат
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
Работа с контентом
Оптимизация контента
Материалы
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: 17.09.2021
Build: ()