Getting a strange error while using shader

Am getting a very strange error when I use shader in my sketch.

Uncaught TypeError: Cannot read property 'isP3D' of undefined (sketch: line 5)

and this is the code

let img;

function preload(){
   img = loadImage('');
  magnify = createShader('shader/MagnifyingShaderVert.vert', 'shader/MagnifyingShaderVert.frag');  
  antialias = createShader('shader/FXAAShaderVert.vert', 'shader/FXAAShaderVert.frag');

function setup() {
  createCanvas(innerWidth, innerHeight, WEBGL);

function draw() {
  image(img, 0, 0);

Any help appreciated.

1 Like

More on the JavaScript error:

1 Like

Looks like it could be a problem with loading the shader but it’s hard to tell just from the error. This is kind of a guess but you might need to use loadShader() instead of createShader() if the shader is in another file. I would recommend trying to get an example from this book working in p5js and then add your own shader.


Thanks for the info mate !

This is what I was looking for ! That template and docs for integrating shaders in P5 are just awesome !

However, I just noticed that am getting significantly low FPS on Firefox (16-20) compared to Chrome(60). I am making some computations on P5 side. Is P5 hindering FPS on Firefox ?


I would guess it has to do with the JavaScript engine in firefox rather than something you’re doing. You can read more about it here. I’ve found that the performance of WebGL is very dependent of the device you use, while it often works great on my laptop it hardly works on my old phone.