-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resetShader() doesn't reset to default stroke / fill shaders #4714
Comments
Hi @aferriss It looks like rendering order is an issue here. |
It seems to me, that there is actually nothing wrong with 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. |
An update to this to make the task clearer: it would be great to mention somewhere in the shader() docs that since a shader might update the vertex positions of shapes in 3D space, causing them to draw in front of subsequent shapes. We generally recommend using this vertex shader for shapes to use p5's transformation system: https://github.com/processing/p5.js/blob/main/src/webgl/shaders/filters/default.vert Maybe we can add another example to |
alright! @davepagurek, could you please be a little specific as to how to go about it? |
Maybe we can update the shader in the Then, in the docs for |
I opened a PR(#6497), please have a look! @davepagurek |
Most appropriate sub-area of p5.js?
Details about the bug:
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 toshader()
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
The text was updated successfully, but these errors were encountered: