Fluid Paint
david.li
david.li
Shameless plug: I made a similar but far more rudimentary particle based calligraphic brush in 140 chars of javascript: https://www.dwitter.net/d/17780 Or, drop this in an empty browser console:
document.body.innerHTML='<canvas id=c>';x=c.getContext('2d');c.width=1920;c.height=1080;C=S=t=0;setInterval('n=t++?n.map(([X,Y,A,B])=>(x.beginPath(x.moveTo(X,Y),x.lineTo(X+=A,Y+=B),x.lineWidth=(A*B)**.5,x.stroke()),[X,Y,A*.7+(C-X)/9,B*.7+(S-Y)/9])):[];onmousemove=({x,y})=>n[t&63]=[C=x,S=y,0,0]',16)https://www.adultswim.com/etcetera/elastic-man/
I'm rather new to shaders, would anyone know how to recreate something like this? Any useful tutorials around?
As for recreating some of this work, you could probably start by looking at his github repos[2].
[0] http://david.li/
[1] https://artsandculture.google.com/experiment/blob-opera/AAHW...
from his tweets about it: "Low res position based dynamics thin shell + some loop subdivision"
Which doesn't help me drastically.
Low res thin shell means that this is a model without many vertices. The "position based dynamics" is a more modern term for what was sometimes called "verlet integration", using the positions to compute immediately velocity relative to the ideal undeformed cage. So this is our simulation model. This is still how cloth sim is done today in games.
To compute the final render, Loop subdivision is used to turn the "thin shell" into a tighter model. You can Google for it, it's a way of subdividing triangles.
Nice paint simulation. Really needs a "dry" button like Painter's had since forever.
I frequently build PWAs, and see no more friction building a PWA using Safari on iOS/iPadOS than I do for Chrome on Android.
That said, the reason the OP's site doesn't work in Safari has nothing to do with whether or not Apple supports PWAs or not.
Orange is the new black
Apple could do better
But they don't give a
It would help "digital" mode if colors were blended in linear space. GIMP relatively recently changed the default mode and it makes quite a difference.
It would be cool if we could select a color like "cadmium red" and mix it "titanium white" to mimic a real painting and its interactions, instead of simply select colors in a sRGB space.
Is there any place where it is possible to read more about this painting techniques for code?
Something to note - it's all math. Changing other people's code and implementing things other people have devised is quite straightforward, but making new styles requires a good understanding of some relatively complex math topics. I'm not saying that to put anyone off - the opposite in fact. If your math isn't great or you're a bit scared of it then learning shader coding is a brilliant way to improve.
https://www.amazon.com/Real-Time-Rendering-Fourth-Tomas-Aken...
Peter Shirley's free Ray Tracing series is incredibly good as well: https://raytracing.github.io/books/RayTracingInOneWeekend.ht...
And the outstanding piece in rendering is the Physically Based Rendering book by Pharr et all (which won an Oscar): https://www.pbrt.org/
None of those are math references as such, but the thing is with graphics it's not based on first principles (well, ray tracing is kinda getting there but still has lots of artistic stuff rather than science stuff), but rather on a bag of tricks. And the math without the "bag of tricks" context may not be that clear.
My experience is, that all math is easy - if you understand it.
But most have big gaps in their basic math knowledge (like me) - and then "pretty easy math" is suddenly very hard, as you stumble every second step, over a concept you never really understood back in class and what you learned you have mostly forgotten - so you have to relearn this. And then that. And then the other thing. And suddenly "easy math" is hard work.
So ... telling people, it is just "easy math" - can make people feel very stupid for not getting it and totally put them off. And I know that I am not stupid - I simply lack knowledge in the area. But for other people with lower self esteem, it can have the opposite effect of encouraging.
I don't have a suggestion for the paint program in particular. There are a few S.O. answers that cover painting linked here
This example uses HTML Canvas, so you could look up some tutorials and start there. At first, programming visually when you've only done API stuff is a whole new world, but it makes a lot of sense with some practice.
I found a tutorial which is probably along the lines you'd want to go down, see https://www.youtube.com/watch?v=gm1QtePAYTM
So:
Probably take a graphics class, with an intro to shaders and the different lightning methods.
Then lookup some cosmetic liquid simulation algorithms by graphics people.
Then learn how to do shaders with canvas and javascript.
http://vis.computer.org/vis2004/DVD/infovis/papers/gossett.p...
They use fully saturated red and yellow, but blue is rgb(42,95,153)
On my MacBook Pro (Retina 15 inch 2015, "the best laptop ever made"), it's just laggy enough to be a bit irritating. A native app would be wonderful.
Edit: Just to be sure, I use Firefox, but it doesn't seem to be a Firefox only -effect, as it's similarly laggy on Chrome too.
I agree!
Honestly I'll play around a little to see if can quickly add that functionality.
[1] https://github.com/dli/paint/issues/9
EDIT: Just made a quick and dirty pull request, a live version here: https://brushpaint.pages.dev/ Now If someone puts more time into this they could: Add support for tilted pens (Change bristle direction based on tilt, my pen doesn't support tilt.) Also the scaling is linear, which is probably not perfect.
Any resources for learning this stroke style?
[1] https://play.google.com/store/apps/details?id=com.woodenclos...