This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Basics
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
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
Animations-Related Classes
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
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Custom Code Sample

This material graph sample demonstrates how to create and use nodes containing a custom shader code.

Albedo RGB value for the material of the Mesh Opaque PBR type is specified directly using a Float node (casting to float3 is performed automatically).

The Function node has two float input ports (A and B) and two float output ports (return value Out and C output). They are automatically added according to the function signature:

Source code (Shader)
float function_1(in float a, in float b, out float c)
{
	c = lerp(a, b, 0.5f);
	return a+b;
}

A and B values for the custom function node are provided by Slider parameter nodes (adjustable via the Parameters panel in UnigineEditor) connected to it.

The result of linear interpolation between A and B values is connected to the Roughness input port of the master material node, while the sum of A and B — to Metalness.

Finally, the data output is passed to the Final node.

Last update: 2024-08-16
Build: ()