This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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 Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

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: ()