我正在使用https://github.com/glslify/glslify在glsl着色器之间共享代码。
我有一个vert着色器,它试图在vert的顶部包含一个模块:
#pragma glslify: JointAndPalette = require('./JointAndPalette.glsl');
#pragma glslify: decodeJointAndPalette = require('./decodeJointAndPalette.glsl');
JointAndPalette jointAndPalette = decodeJointAndPalette(inputProps);
Run Code Online (Sandbox Code Playgroud)
decodeJointAndPalette也依赖于该JointAndPalette结构作为其返回定义
JointAndPalette看起来像:
struct JointAndPalette
{
int jointId;
int paletteId;
};
#pragma glslify: export(JointAndPalette)
Run Code Online (Sandbox Code Playgroud)
encodeJointAndPalette看起来像:
JointAndPalette decodeJointAndPalette(float jointPaletteSplit) {
// implementation
JointAndPalette JandP;
JandP.jointId = int(x);
JandP.paletteId = int(y);
return JandP;
}
#pragma glslify: export(decodeJointAndPalette)
Run Code Online (Sandbox Code Playgroud)
从glslify文档对我来说还不清楚如何构造这种依赖关系