shader-toy icon indicating copy to clipboard operation
shader-toy copied to clipboard

can't run glslify example

Open mikeny07 opened this issue 1 year ago • 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.

mikeny07 avatar Sep 18 '23 20:09 mikeny07

Did you enable the glslify option in the settings?

Malacath-92 avatar Sep 19 '23 05:09 Malacath-92

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

mikeny07 avatar Sep 19 '23 16:09 mikeny07

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

Malacath-92 avatar Sep 28 '23 18:09 Malacath-92

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.

Malacath-92 avatar Sep 29 '23 09:09 Malacath-92

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.

Malacath-92 avatar Sep 29 '23 10:09 Malacath-92