Vite shadowOnly shaders

@Kruptein while we are tryin to help you, you can copy the shaders from the zip to your client project so you can move on with your project.

public.zip (451.9 KB) - unzip to client, contains dir structure

I’ve tested this, works well.

There are two shader stores in this project. Could be the way vite is optimizing the babylonjs/core package, because it is spread across two projects. I assume that if you move the code from the 2nd project directly into the main project, or have a single project with everything babylon-related, it will work as expected.

In general, the problem is that the shader is loaded to one shader store, but when rendered, there is a different shader store that is being used to load the shaders from. Didn’t dive too deep into why it is happening, mainly because I had to debug the production code, and it is not very simple :slight_smile:

1 Like

Ok, I’m pretty sure it’s an issue with multiple contexts.

Both the main project as well as @planarally/dice have a ShaderStore

1 Like

hahahaha

Same conclusion :slight_smile:

My guess is that since both depend on the package, the import from the package is not shared among the projects, but this is an uneducated guess. I would expect vite to optimize it correctly, but it is certainly not happening. Might be a setup thing, might be a vite limitation

Thanks to both of you for helping!

It might be the npm link, I’m not super used to using it so I might be doing something wrong with it. But if I unlink the library and instead npm i the output of npm pack in the lib as if it was a real dependency, it does seem to work properly.

1 Like