Shader Works with External Files, Fails When Inlined

Hello everyone,

I have a simple script (simpleShader.js) that loads vertex and fragment shader from external assets. It works perfectly and the shader is applied correctly

However, as soon as I try to move the exact same shader code into a single script (inlining both the vertex and fragment shader strings inside my .js file), it stops working. Instead of the expected effect, the model becomes either black, uniformly colored, or simply doesn’t show the intended animation/pattern.

It is not really a problem that I need to use external fragment and vertex shader but I am just trying to figure out what am i doing wrong ?

here is the exemple i use if you wanna check :

https://playcanvas.com/project/1306548/overview/test

So basically what I was trying to say was that when I try to put all my shader code into one single script it doesn’t work and I don’t understand why

It was because of how you updated time in update in the simpleShader.js file. I’ve made it the same as the external version and it looks fine

https://playcanvas.com/project/1307026/overview/test-shader

1 Like

Oh ok now I get it ! Thanks Yaustar !