met*_*eap 4 opengl macros shader glsl fragment-shader
考虑以下GLSL函数:
float Pow3 (const in float f) {
return f * f * f;
}
float Pow4 (const in float f) {
return f * f * f * f;
}
float Pow5 (const in float f) {
return f * f * f * f * f;
}
Run Code Online (Sandbox Code Playgroud)
... 等等.有没有一种方法,以#定义一个宏GLSL可以产生ñ乘法-OF- ˚F逐本身在编译的时候,不使用内置GLSL POW()当然功能?
GLSL预处理器"等于"标准C预处理器.实际上,您可以使用以下预处理器定义达到您想要的效果:
#define POW(a, b) Pow ## b ## (a)
Run Code Online (Sandbox Code Playgroud)
但要注意,因为连接运算符(##)仅从GLSL 1.30开始可用.确实使用以前的GLSL版本,此宏将生成编译器错误.
还在想你为什么不使用这个pow功能......