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

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#

  • 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 (bool) — hides the state in the Editor
  • internal (bool) — hides the state in the Editor and the state values ​​are not saved 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: 2021-12-13
Build: ()