Shader includes and threeshaking

Hello together,
I have one big project here where I heavily use thin instances with own shaders materials etc. I am now in the process of splitting this project apart into smaller projects and I face a problem in one of the new small projects regarding shader includes:

  • I use #include<instancesDeclaration> in on of my shaders and this is working perfectly fine in my big project. However, in my small project, babylon is missing all shader imports. I had to manually import @babylonjs/core/Shaders/ShadersInclude/instancesDeclaration in order to get my application to run.

I checked in my big application, a total of 59 shader included are imported automatically

So my question is:

  • Is it advised to manually import shader includes or is there something wrong going on here? If this is the way to go, why are there so many shader includes in my big app? Maybe they are automatically included as I am using StandardMaterial there?

Best regards,
Axel

cc @sebavan and @RaananW

Every material imports its shaders which results in importing there includes.

for instance in pbrMaterial we have:

which result in importing this file, which imports its includes:

Importing shaders simply copy them in the shader store. So if you use custom shaders which are relying on includes, yes you need to import them for sideeffects.

1 Like