1

我尝试使用 Project > HLSL/CG > Compiler Options 字段在我的项目设置中向 FX Composer 添加宏定义。在两个 HLSL 字段中,我有 /DMYPROJECT 和 Cg -DMYPROJECT。

编译 Cg 着色器时,这按预期工作,但我无法让它为 HLSL 工作。在 fxc.exe 的命令行中使用相同的选项有效。

这是我用来测试的代码片段;

#ifndef MYPROJECT
#error ABC
#endif

我错过了什么?

4

1 回答 1

1

FX Composer appears to execute #error directives regardless of other preprocessor directives, at least for HLSL. If you try your test with some actual code, like setting the pixel color to black or something, I think you'll find that it works. It worked for me, anyway. Your question actually helped me figure out how to do this, although I ended up going to Assets, Effects, myeffect, myshader.fx, Properties, Compiler Options.

Also important: in the Compiler Options field, I entered the macro like MYPROJECT, not /DMYPROJECT and that worked. I'm using FX Composer 2.53.0524.1905 with a D3D9 HLSL shader.

于 2013-05-06T16:36:33.177 回答