[Solved - request error message be added] Uncaught TypeError for script defined material

I solved the problem, turned out to just be a simple typo :frowning:

When creating a shader definition you pass an attributes array and then the vertex shader and fragment shader. I had written vShader and fShader rather than vshader and fshader.

Whilst this was a silly mistake on my part, it would be nice if the playcanvas devs could add an error to the shader constructor that could check for errors similar to this, as the vertex and fragment shader were undefined in the struct, yet the program had no errors, and still allowed me to attach the shader to a material.

I will probably (I hope? :smiley: ) not be the last person to run into this so I have left the title and question intact and will simply add a title tag and change the category so this can be seen as a suggestion.


Hi all, perhaps you can help with a shader problem I’ve been having.

I’ve written a very simple test shader for an app I am developing which converts geometry to screen space and then outputs red for all fragments. The shader is then applied to a material and that applied to some mesh instances, as is normal in playcanvas.

The problem is that once the setup scripts have run (error free), playcanvas is throwing errors on PC.render()

The errors are:

  • Uncaught TypeError: Cannot read property ‘split’ of undefined
  • Uncaught TypeError: Cannot read property ‘length’ of undefined

Another thing that might be of note is that the shader, when logged, says ready: false. I can’t find any documentation on that though…

Here is what the console is spitting out, firstly the shader log showing ready false, then the two errors. The second is repeated every frame by the looks of things.

Any help is much appreciated!

Edit: Forgot to mention this happens specifically with new pc.Material. When using pc.PhongMaterial the application correctly positions geometry but the geometry outputs whatever colour the ambient light is. This could be a fallback shader though for Phong?