Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webgl Extension methods get renamed when required as glslify module #110

Open
kevzettler opened this issue Jun 4, 2018 · 0 comments
Open

Comments

@kevzettler
Copy link

kevzettler commented Jun 4, 2018

I have a frag shader that is dependant on the GL_OES_standard_derivatives extension

#extension GL_OES_standard_derivatives : enable
precision mediump float;
#pragma glslify: grid = require(glsl-solid-wireframe/barycentric/scaled)
varying vec2 b;
void main () {
  gl_FragColor = vec4(vec3(grid(b, 1.0)), 1);
}

When compiled through glslify the ouput looks like

"#extension GL_OES_standard_derivatives : enable
precision mediump float;
#define GLSLIFY 1
float gridFactor_1_0 (vec2 vBC_1_1, float width_1_2, float feather_1_3) {
  float w1 = width_1_2 - feather_1_3 * 0.5;
  vec3 bary = vec3(vBC_1_1.x, vBC_1_1.y, 1.0 - vBC_1_1.x - vBC_1_1.y);
  vec3 d = fwidth_1_4(bary);
  vec3 a3 = smoothstep(d * w1, d * (w1 + feather_1_3), bary);
  return min(min(a3.x, a3.y), a3.z);
}

float gridFactor_1_0 (vec2 vBC_1_1, float width_1_2) {
  vec3 bary = vec3(vBC_1_1.x, vBC_1_1.y, 1.0 - vBC_1_1.x - vBC_1_1.y);
  vec3 d = fwidth_1_4(bary);
  vec3 a3 = smoothstep(d * (width_1_2 - 0.5), d * (width_1_2 + 0.5), bary);
  return min(min(a3.x, a3.y), a3.z);
}

varying vec2 b;
void main () {
  gl_FragColor = vec4(vec3(gridFactor_1_0(b, 1.0)), 1);
}

The problem here is the GL_OES_standard_derivatives extension includes a fwidth function. glslify namepaces this as fwidth_1_4 which dosen't exist. The shader then fails to compile. I'm not sure if this is related to #46

@kevzettler kevzettler changed the title Extension methods renamed when required as glsl module Webgl Extension methods get renamed when required as glslify module Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant