通用指令
no_dynstcode
no_dynstcode 不允许着色器在其主体中使用任何类型的动态 stcode。
这意味着着色器只能访问 material 变量或着色器支持的着色器块 着色器块 中定义的变量。
请看下面的示例:
float4 some_global_var;
float4 another_global_var;
block(scene) common_scene_block
{
(vs) { some_global_var@f4 = some_global_var; }
}
shader test_shader
{
no_dynstcode;
texture tex = material.texture.diffuse;
(ps) { diffuse_tex@static = tex; }
// 现在可在 hlsl(ps){...} 块内访问 diffuse_tex
supports common_scene_block;
// 现在可以在 hlsl(vs){...} 块中访问 some_global_var
// 会导致编译错误
(vs) { another_global_var@f4 = another_global_var; }
}
dont_render
dont_render 用于禁用着色器变量。
最常见的使用情况是禁用着色器的冗余变体,这些变体正在使用某些共享的 interval.
将为具有 dont_render 的着色器变量分配一个特殊的 NULL 值,并且不会对其进行编译。
如果在运行时选择了动态变量 NULL,则不会进行渲染或分派(如果是计算着色器)。
如果从一个 NULL 静态着色器变量创建了一个 ShaderElement,它将只返回 NULL。
include "render_pass_modes.dshl"
shader decals_shader
{
if (render_pass_mode == render_pass_impostor)
{ dont_render; }
// ...
}
Note
dont_render 并不会直接减少着色器变量的数量。
虽然不会对 NULL 着色器进行编译,也不会为它们创建 stcode,但它们仍然存在于着色器变量查找表中。
no_ablend
no_ablend``强制关闭混合。
指定 ``blend_src, blend_dst 或 blend_asrc, blend_adst 不会产生任何效果。