I’ve been using ShaderMaterial many times. As stated in the documentation:
Note that uniforms are refreshed on every frame, so updating the value of the uniform will immediately update the value available to the GLSL code.
Anyway if I change the uniform value I cannot see it reflected in my shader.
If you look at this codepen I’m trying to change background color based on current time. Nothing changes in the background colors, although the uniform value clearly does.
uniforms.u_current_time = clock.elapsedTime();
has to be like this
uniforms.u_current_time.value = clock.elapsedTime();
Just out of curiousity, why don’t use
backgroundMaterial.uniforms["u_current_time"].value = clock.elapsedTime() * 0.01;
VALUE! I was missing ‘value’.
Can’t belive was such a stupid mistake!
@prisoner849, we were using THREE.Clock() but we dropped it because we were so lost in the dark that we thought maybe it was the clock to be the cause of the issue.
At that time we also came across a MrDoob comment where he was expressing doubts about THREE.Clock.
We are actually re-implementing it now that we’ve solved the issue.
Thanks again for the prompt response.
Here the codepen updated with THREE.Clock for future reference