This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

状况

For each ULON node a logical condition can be specified using a state value. If the condition fails the node with all its children is ignored. Thus you can dynamically build the flexible hierarchy of ULON nodes. This can be useful when the contents of the node depends on certain parameters, e.g. a shader to be used is defined by the rendering pass.对于每个 ULON 节点,可以使用状态价值。如果条件失败,则忽略该节点及其所有子节点。因此,您可以动态构建 ULON 节点的灵活层次结构。当节点的内容取决于某些参数时,这可能很有用,例如,要使用的着色器由渲染通道定义。

Conditions are specified after the node's name, starting with the if keyword, the condition itself is enclosed in brackets [ ... ].条件在节点名称之后指定,以 if 关键字开头,条件本身包含在括号 [ ... ] 中。

The syntax is the following:语法如下:

ULON
Node name if [condition]

The Group nodes support the nested conditions:团体节点支持嵌套条件:

ULON
Group parent if [condition]
{
	Group child if [condition]
}

Condition of the parent node is added to the condition of the child like so: (parent_conditon) && (child_conditon).父节点的条件被添加到子节点的条件中,如下所示: (parent_conditon) && (child_conditon)

You can write complex conditions using logical operations:您可以使用逻辑运算编写复杂的条件:

ULON
Node name if [(state1 == 1 || state2 == 1) && !state3]

Preprocessor Auto Generation for Shaders
着色器的预处理器自动生成#

In the UUSL code all conditions are enclosed in #if and #endif preprocessor on shader compilation, for instance:UUSL 代码中,所有条件都包含在着色器编译时的 #if#endif 预处理器中,例如:

ULON
StateInt do_a_thing = 1

Slider do_a_thing = 0.5 if [do_a_thing == 2]
Texture do_a_thing = black if [do_a_thing == 3]

Shader example =
#{ 
   // the following UUSL preprocessors are inlined on shader compilations
   #if GET_STATE_DO_A_THING == 2
          UNIFORM float var_do_a_thing;
   #endif

   #if GET_STATE_DO_A_THING == 3
          INIT_TEXTURE(0, tex_do_a_thing);
   #endif

   // the variable or the texture is available only when the corresponding condition is met 
   color.r = var_do_a_thing; // valid only when do_a_thing = 2
   color.gb = TEXTURE(tex_do_a_thing, IN_UV); // valid only when do_a_thing = 3
#}

Usage Examples
使用示例#

ULON
Int some_var = 1 <min=0 max=1>
		
Pass deferred if [some_var == 0]
{
	Vertex = "shaders/a.vert"
	Fragment = "shaders/a.frag"
}

Pass deferred if [some_var == 1]
{
	Vertex = "shaders/b.vert"
	Fragment = "shaders/b.frag"
}

Based on the value of some variable you can specify different shaders for the same render pass (deferred in our example).根据某些变量的值,您可以为同一渲染通道指定不同的着色器(在我们的示例中延迟)。

最新更新: 2024-08-16
Build: ()