stevensona/shader-toy

can't run glslify example

Opened this issue · 5 comments

Most examples in the demos directory run smoothly without any issue. However, the glslify.glsl example:

#pragma glslify: snoise = require('glsl-noise/simplex/2d')

float noise(in vec2 pt) {
    return snoise(pt) * 0.5 + 0.5;
}

void main () {
    float r = noise(gl_FragCoord.xy * 0.01);
    float g = noise(gl_FragCoord.xy * 0.01 + 100.0);
    float b = noise(gl_FragCoord.xy * 0.01 + 300.0);
    gl_FragColor = vec4(r, g, b, 1);
}

The noise function in the above code gives error:

'snoise' : no matching overloaded function found

I checked the glslify package was installed in the node_modules folder.

Did you enable the glslify option in the settings?

Sorry. I just enabled it. However, I got a different error:

 Line numbers are not available because the glslify option is enabled
THREE.WebGLShader: gl.getShaderInfoLog() fragment WARNING: 0:153: 'glslify' : unrecognized pragma
'snoise' : no matching overloaded function found

That sounds like perhaps you didn't install the noise module?

I took a closer look at this just now and it seems that glslify uses the working directory as the root for finding modules, which is the folder where the extension is installed, so that's gonna do no good. Idk when that changed, but I'm pretty sure it worked once in the past. Either way I'll fix that.

Fixed it, if a folder is open it will use that as a base directory, otherwise the folder that the file being rendered is in. That fix will be part of the next release.