Thursday, 18 April 2019

glslify how to share a struct between modules

I am using https://github.com/glslify/glslify to share code between glsl shaders.

I have a vert shader that is trying to include a module at the top the vert has:

#pragma glslify: JointAndPalette = require('./JointAndPalette.glsl');
#pragma glslify: decodeJointAndPalette = require('./decodeJointAndPalette.glsl');

JointAndPalette jointAndPalette = decodeJointAndPalette(inputProps);

decodeJointAndPalette is also dependent on the JointAndPalette struct as its return definition

JointAndPalette looks like:

struct JointAndPalette
{
  int jointId;
  int paletteId;
};

#pragma glslify: export(JointAndPalette)

decodeJointAndPalette looks like:

JointAndPalette decodeJointAndPalette(float jointPaletteSplit) {
  // implementation

  JointAndPalette JandP;
  JandP.jointId = int(x);
  JandP.paletteId = int(y);

  return JandP;
}

#pragma glslify: export(decodeJointAndPalette)

Its not clear to me from the glslify docs how to structure this dependency



from glslify how to share a struct between modules

No comments:

Post a Comment