Is it possible to change include path for shaders?

Let’s say we have some include in shaders like in this Playground
so the path is: src/Shaders/ShadersInclude/instancesDeclaration.fx.
Is it possible to change this path to some another?

Or maybe it can be included inside a final bundle when it’s done with ES6 tree-shaking?

If you’re using vite, vite-plugin-glsl lets you do that, it even minifies your shaders if you want : )

idk if you can do it w/o it tho

I am not sure to understand what you need.

If you want those to be present in es6 build, simply import the files for side effects so they end up in the shader store.

Oh, I didn’t know this. What should I import? .fx files those used in my shader-include directives?

If you need src/Shaders/ShadersInclude/instancesDeclaration.fx you should

import "@babylonjs/core/src/Shaders/ShadersInclude/instancesDeclaration";

.fx are converted to .ts automatically when developping in the Babylon repo so then end up as .js in the package:

1 Like

Strange, but it’s not work in my case:

Module not found: Error: Can't resolve '@babylonjs/core/src/Shaders/ShadersInclude/instancesDeclaration' in '/data/data/com.termux/files/home/mylab/gamedev/babylon/babylonjs0/src/engine'
resolve '@babylonjs/core/src/Shaders/ShadersInclude/instancesDeclaration' in '/home/babylonjs0/src/engine'
  Parsed request is a module
  using description file: /home/package.json (relative path: ./babylonjs0/src/engine)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module

oh sorry src/ should not be in the path, the correct one is visible on the npm page screencap :slight_smile:

2 Likes

Wow that worked, thanks! That’s very helpful info for me!