Jump to content

How to create a custom shader?


Recommended Posts


I'm new to babylon.js and have worked with Unity3d before. I was used to write my own shader code there and the material still received lighting and shadows.

What is the correct way to do it here? When I use the ShaderMaterial, only my shaders are used. I could probably copy&paste all the stuff from the default material in there, but I didn't have much success as I would have to set some defines and bind some stuff during the onBind call, if I understood it correctly.

I could also write a whole new material. Then at least everything would be a little bit more clean, but I would still have to copy&paste a lot of things.

Did I miss something entirely? What's with this ShaderBuilder I read a little bit about but doesn't seem to be bundled to BJS? What is the recommended way of creating a new shader with lights and shadows?



Link to comment
Share on other sites

Hello and welcome!

The best option if you want to get all features (including bones, shadows,etc..) would be to create a custom material. We have the material library for that :)


I would suggest to start from the Simple Shader which is already set up and then add what you need :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...