How to use custom Shaders with a custom mesh, to apply textures

I am new to babylon and i am trying to apply a texture to my own custom mesh. I managed to apply the texture using on one of the built in meshes - .CreatePlane. I dont get any errors, and dont know where to start looking/debugging.

https://playground.babylonjs.com/#VG25E8#3 this playground shows what i have in my current project. I attached my two shaders at the bottom, commented out.

You need to declare the sampler in the samplers list when creating the mat:

   const mat = new BABYLON.ShaderMaterial("shader", scene, "./shader",
        {
            attributes: ["position", "color", "uv"],
            samplers: ["textureSampler"]
        });
1 Like

I guess … :slight_smile:

OMG! You are my hero! Thank you! This project is an expansion on an example i found, where they dont use a custom mesh. In that they dont have a sampler list - even though it has a textureSampler - and it works just fine. Is this something specific for custom meshes?

And are there some sort of errors that i am missing when bugs like that occur? Since i am so new i dont intuitively know what i have done wrong.

Nope no errors, you can basically only use what has been declared.

The other examples were probably about post process who all have a textureSampler by default :slight_smile: