acamposuribe / p5.brush

Unlock custom brushes, natural fill effects and intuitive hatching in p5.js
https://p5-brush.cargo.site/
MIT License
453 stars 25 forks source link

Using version 1.10 and above of p5.js breaks any sketch that involves the fill feature #36

Open Metamere opened 1 day ago

Metamere commented 1 day ago

For some reason, using the more recent versions of p5.js beyond 1.9.4 causes any sketch with a fill feature to break, in that the buffers get shifted around. Things shift from the center of the screen to the origin, don't blend properly, don't draw at all, wrap oddly across the upper left and lower right quadrants, etc. I tested example sketches with the current version of p5.brush and back to v1.0.4 and it's the same behavior as far as I can tell. Here you can see the example sketch with just the p5 version changed. image

Metamere commented 1 day ago

I think it has to do with the updates to how shaders are handled in p5 that started in 1.10, related to matrix operations and such.

Metamere commented 1 day ago

By changing the values in this portion: trans(){return this.translation=[s._renderer.uMVMatrix.mat4[12],s._renderer.uMVMatrix.mat4[13]],this.translation} to trans(){return this.translation=[s._renderer.uMVMatrix.mat4[13],s._renderer.uMVMatrix.mat4[14]],this.translation}, It brings it back somewhat. image But the hatching is screwy. Maybe where are more places where updates are required. But this seems to be a key line regarding the bug.

When using a sketch with only fill, it seems that using 12 and 13 makes things work.

Metamere commented 18 hours ago

It turns out the actual solution is to replace uMVMatrix with uModelMatrix, since in 1.10 uMVMatrix got split up into the model and view matrices. That seems to fix all the various issues.