A query about the effects Store

I have a shader in the effectsShaderStore. On clicking the mouse the effectsShaderStore content should be overwritten by a different version so that I can create a new shader with the original name.
This is necessary as I am creating a rayMarching tool and obviously every time new object is added you need a new fragment shader.
Yet it does not seem to change, any reason why? Can you remove/replace items in the eventsShaderStore? It always seems to stick with the first version that I put in there for a given key.

Trying again as was getting a strange error message with example

Continuously getting an i.initFunction error when I try and run the example. How do you stop this?

Copied it out to a new project which seems to be working.

1 Like

There is a caching mechanism in the Effect class that relies on the name of the shaders + the list of attributes/samplers/uniforms + the defines. As in your case all of those data don’t change, the first compiled effect is reused each time.

The easiest way to overcome this is to add a define that will change each time you recreate the shader:

Note that you can also pass the shader code when creating a ShaderMaterial, you don’t have to use the shader store.

1 Like

Ah. Thank you very much, as I am recreating the shaders as new objects are added, it will be easy enough to add a changing definition statement in side. Will experiment with it now I know where the problem lies.