Skip to content

glslify how to share a struct between modules? #127

@kevzettler

Description

@kevzettler

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 docs how to structure this dependency

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions