As far as I can tell resetShader() isn't doing any resetting. I haven't dug too deeply into this so I'm not sure what might be going on but it looks like setting userFillShader and userStrokeShader to null is not enough to reset the custom shaders. Oddly, if I place my initial calls to shader() inside of setup, resetShader() does seem to work if I do my non-custom shader drawing inside of draw.
Here's a small example showing the issue
https://editor.p5js.org/aferriss/sketches/X-kF7aVT8
Hi @aferriss
Thanks for reporting this bug.
It looks like rendering order is an issue here.
https://editor.p5js.org/matvs/sketches/_rtBhhm-h
I am working on it :)
It seems to me, that there is actually nothing wrong with resetShader() function.
In my previous example one can see, that the green square is actually rendered, but either drawing order is false or z coordinate of red square is higher.
It looks like it is the latter, because adjusting position.z in vertex shader solves the issue: https://editor.p5js.org/matvs/sketches/FG-Lz2Oon
It can also be solved directly in JS with for example applyMatrix or transform.
I don't think that it is a bug in p5.js, because it simply respects how shaders are defined.
Ah, this is good to know! Thanks for looking into it. I wonder if there is anything we can add to the docs to make people aware of the fact that depth will be taken into account over draw order.
Most helpful comment
Hi @aferriss
Thanks for reporting this bug.
It looks like rendering order is an issue here.
https://editor.p5js.org/matvs/sketches/_rtBhhm-h
I am working on it :)