TypeError: vertex.substr is not a function

I am trying to create a custom shader:

Effect.ShadersStore['tilemapVertexShader'] = [...].join('\n')
Effect.ShadersStore['tilemapFragmentShader'] = [...].join('\n')
let material = new ShaderMaterial('tileShader', scene,
        {vertext: 'tilemap', fragment: 'tilemap'},
        {attributes: ['position']})

But this throws:

Uncaught TypeError: vertex.substr is not a function
    at Effect../node_modules/@babylonjs/core/Materials/effect.js.Effect._loadVertexShader (effect.js:431)
    at new Effect (effect.js:257)
    at Engine../node_modules/@babylonjs/core/Engines/engine.js.Engine.createEffect (engine.js:2426)
    at ShaderMaterial../node_modules/@babylonjs/core/Materials/shaderMaterial.js.ShaderMaterial.isReady (shaderMaterial.js:373)
    at GroundMesh../node_modules/@babylonjs/core/Meshes/mesh.js.Mesh.render (mesh.js:1363)
    ...

This works in the playground… What am I doing wrong?
I’m using v4.0.3.

In your shaderPath object you have vertext instead of vertex, maybe that’s it?

2 Likes

:man_facepalming: Doh!