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
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

States

State allows you to set a mode for rendering passes and a value for rendering options. States change a set of generated definitions passed to shaders, so any changes made to a state cause shaders recompilation. A material state generates defines for shaders only if the state meets the conditions. You can specify your own states or use and specify values for UNIGINE's internal states.

The syntax is the following:

ULON
StateType state_name = value(s)

You can acces states in the shader using the following defines:

UUSL
GET_STATE_<state name in uppercase> = value // for all states

STATE_<state name> // if the state value is bigger than 0 (for example, StateToogle)

STATE_<state name>_<name of an element from the items array> // for State and StateSwitch

To change the state's values use the corresponding API methods.

Types of States#

  • StateToggle (bool) — a switch that enables/disables the state
  • StateSwitch (integer) — a multiple-value switch based on array of items (mandatory argument)
  • StateInt (integer) — a state with an integer number (used to pass the state value via the API to the shader)
  • State — auto detection of the state type (if the items argument is present, then StateSwitch; otherwise StateToggle)

Usage Examples#

Suppose we got the base material with these states defined:

ULON
BaseMaterial 
{
	State my_state_switch = 4 <items = [a b c d e]> // or StateSwitch my_state_switch = 4 <items = [a b c d e]>
	State my_state_toggle = 1
	StateInt my_state_int = 256 <internal = true>
}

Then the following defines are available in the shaders:

UUSL
#define GET_STATE_MY_STATE_SWITCH 4
#define GET_STATE_MY_STATE_TOGGLE 1
#define GET_STATE_MY_STATE_INT 256

#ifdef STATE_MY_STATE_SWITCH_A
    /* some UUSL code */
#elif  STATE_MY_STATE_SWITCH_B
    /* some UUSL code */
#elif  STATE_MY_STATE_SWITCH_E
    /* some UUSL code */
#endif

#ifdef STATE_MY_STATE_TOGGLE
    /*some UUSL code*/
#endif

int my_state_int = GET_STATE_MY_STATE_INT;

Arguments#

editable#

Boolean

A flag indicating if state can be changed in the Parameters window or via API.

Available values:

  • false — unchangeable
  • true — changeable (by default)

title#

String

Title for the Editor.

tooltip#

String

Tooltip for the Editor.

switch_group#

String

Sets this state to be responsible for the toggle of the specified group.

hidden#

Boolean

A flag indicating if the state is hidden in the Editor.

Available values:

  • false — shows the state in the Editor
  • true — hides the state in the Editor

internal#

Boolean

A flag indicating if the state is hidden in the Editor and the state values are not saved for the inherited materials.

Available values:

  • false — shows the state in the Editor and saves the state values for the inherited materials
  • true — hides the state in the Editor and does not save the state values for the inherited materials

items#

Array of Strings

Items used for the StateSwitch type.

pass#

Array of Strings

Specifies what passes use this state.

Available values:

Notice

To make one or more passes use this state, write passes in square brackets and separate them with spaces. For example:

ULON
State wireframe_antialiasing <pass=[wireframe post custom_pass_name]>
Last update: 2022-04-06
Build: ()