Freeze Shader Material

Hello, BabylonJS community,

It has been a while since I haven’t posted here and it feels like I am reaching a friend to know what’s up! :hugs:
The reason I didn’t post is because on the whole BabylonJS works perfectly well!

As a matter of fact, the question which brings me here is a more curiosity question:
I have been playing with shaders a lot recently and I started trying to optimize them. The first obvious thing which came to my mind was to freeze the material once there is no more float or texture values to change in the shader.
But doing some tests I found out that I could still change values after the freeze as you can see in this playground ligne 60-62: Is it normal?
As shaders are already so performant (for my use case at least) is it interesting to actually freeze it?
And otherwise what would be the best practice to optimize the shader except having an optimized glsl shader code?

In advance, thanks for your answers and ideas! :pray:

The freeze is mostly about the recompilation. You can continue changing uniforms afterwards

btw you did not share a PG :slight_smile:

Optimizing a shader will be useful mostly if you are GPU bound. Else it will have no effect on your overall performance

1 Like

Thanks, I edited my post with the playground link.

How to know if you are CPU or GPU bound?
My instinct tells me it has something to do with Scripting vs Rendering from the performance screen of the developer console?

you are gpu bound when increasing the resolution hits the FPS counter
You are cpu bound else :slight_smile: