Hello, I added some babylon.js code to my electron project. Things work as expected EXCEPT any custom coded shaders whether it be a ShaderMaterial or a Material Plugin fail to compile.
I’m wondering if it is maybe a shader language problem.
I already fixed the CSP issues as far as I know.
One strange thing is I am getting this error in the console:
PresetPreview.tsx:70 BJS - [04:02:39]: #version 300 es
#define WEBGL2
#define NUM_BONE_INFLUENCERS 0
#define NUM_MORPH_INFLUENCERS 0
#define SHADER_NAME fragment:cssBlendShader
precision highp float;
<!doctype html>
<html>
<head>
<script type="module" src="/@vite/client"></script>
<meta charset="UTF-8" />
<title>Electron</title>
(the rest of my index.html)
It is like the shader code is including part of my index.html file?
OK, the index.html thing was because I forgot to include the module that set the BABYLON.Effect.ShadersStore
.
But I am still getting errors like:
PresetPreview.tsx:70 BJS - [10:09:40]: Error: VERTEX SHADER ERROR: 0:17: 'uniform' : only allowed at global scope
ERROR: 0:17: 'uniform' : Local variables can only use the const storage qualifier.
ERROR: 0:17: 'uniform' : invalid qualifier combination
when the exact same shader code is working in my web application.
I don’t know what is causing the issue in Electron.
I have confirmed that WebGL2 is being used from engine.webGLVersion
outputting 2
Nevermind, I figured it out. There were some #ifdefs in my shader code that triggered incorrectly.
1 Like
Hey, thanks a lot for sharing the solution! It’s always super helpful when someone circles back and posts how they solved it. Really appreciate it — makes it easier for others to find answers!
2 Likes