I improved the VRChat cloth simulation, now it is actually rendered as a mesh and finally can handle self collision for proper folds. Also I moved the simulation to CRTs so it kinda works for non friends(the simulation is on the avatar!). But the collision still requires cameras.
Decided to implement this as a compute shader. Looks very nice with millions of points! I've also made the beta parameter parametrize the color by a spectrum function.
The fluid simulation plugin for Unity I've been working on for these months has finally released on the Unity Asset Store!
Check it out:
Also you can check out the free version:
If you have any questions:
Finally figured out how to hack GPU vertex/index buffers in unity meshes, now I can use native unity materials and rendering for the liquid mesh 😤. Meaning all the rendering stuff you can have in unity you can have here too. It is a bit slower tho due to some Unity limitations😔
Implemented liquid force fields based on SDFs. Now liquids can take any form 🧐. Next on the list is to finally add skinned mesh support for this to work with character models.
#ZibraLiquids
So I kinda got mesh fitting working, taking a simulation mesh and fitting it on top of a given mesh. For a test I used a simple skirt, but there would still be lots of work to make it work on my avatar as an actual skirt.
Different mesh topologies are gonna be just as hard to add
Emergence is truly a fascinating thing, one moment you mess with random fluid systems, and the other moment cellular life emerges. Yeah, those things even have a cell structure, idk how that happened, but its amazing.
Made a volumetric bidirectional path tracer in shadertoy. Basically tracing a laser path, and then trying to connect the camera path with the laser path using importance sampling.
Took me a month, but the blog post is finally finished! 🫡
Here I'll explain how to write up a generalized space time geodesic ray tracer in GLSL, as well as going in-depth into Lagrangian/Hamiltonian mechanics with derivations of the geodesic equations!👀
After some messing around I've switched to a different simulation method, with precomputing the neighboring vertices into a texture. I've made a tool that converts unity cloth's into shader based cloths. Here as a demo I'm trying a 30k vertex mesh. Still lots of work ahead tho
Now that the latest Chrome version has WebGPU support I guess I can finally talk about this. A year ago
@david_ar
and
@cornusammonis
were developing a compute shader based Shadertoy alternative called I already had a lot of fun making some toy projects 😳
Huh, just by shifting the points randomly on a circle depending on the distance to the focal place I can get free bokeh. There is just so many particles I guess
The cat is out of the bag finally👀
Since summer I've been working on a smoke/fire real time GPU simulation plugin as well. It features a multigrid pressure solver and a fully custom volumetric rendering system for Unity.
Added friction to the self-collision terms, omg it works so good even tho I only track a single closest non-neighboring particle(and stochastically at that)
As a side project I've been working on a Kerr black hole shader for Space Engine with a volumetric accretion disk. The way a Kerr black hole distorts space is really odd because of frame dragging🤔. I might make a blog post about how I solve for geodesics in general.
Implemented SDF inversion, now you can make fluid inside arbitrary boundaries. Also improved fluid stability, figured out how to remove particle giggling when only a few particles a present, it seems the divergence part of the affine matrix produced unstable oscillations.
Now that I have a way to render multi material liquids, I thought that it would be pretty trivial to add something that looks like foam by adding a material based on velocity gradient, so here is the result of the experiment. Of course its a bit blurry but I think it might work
Testing fluid interation with lots of objects. Real time 3D liquid simulations can finally be used as a gameplay feature. Can't wait to see how this can be used in games👀
#unity3d
#ZibraLiquids
#vfx
#realtimeVFX
I didn't think atomic add's were this fast. I was messing around with a particle cloud rasterizer, before this I was rasterizing them using a radix sort, I thought that was fast, but now that I tried atomics I can render 16M particles at 100fps(wat) which is 6x faster than radix
Over the last 6 months I've been working on a real time fluid simulation plugin for Unity. At its core it uses a GPU implementation of MLS-MPM.
You can try it yourself: . Right now it's in early access.
#ZibraLiquids
#Unity3d
#RealtimeVFX
#FluidSimulation
Improving Zibra Liquids foam generation, still lots of work ahead. Specifically the foam is not yet occluded by the liquid, making it look way too white
Implemented anisotropic kernels in my VRChat fluid sim ()
Now to figure out how to get high quality normals out of this... (no screen space, thanks)
Also still need to make tighter billboard quads for the ellipsoids, rn pretty expensive to render
One of the coolest applications of the new Zibra Smoke&Fire plugin I'd say would be this tire smoke sim.
It showcases volumetric rendering illuminated by multiple point lights. The simulation domain moves with the car which creates the illusion of a boundless simulation
After somewhat improving the way volumetric materials are rendered, I've checked how foam looks in HDRP. Results are pretty good, but there is not enough high frequency detail, adding additional foam/splash particles will definitely improve the looks further🧐
Made a Shadertoy port of Marble Marcher! (original game by
@_CodeParade_
) Everything is inside a fragment shader, even the physics/gameplay! Also I've implemented some cool features like TAA and a path tracing mode(look up define in Common tab)
Finally a blog post about the volumetric accretion disks I've been helping to make for Space Engine! Soon I'll also release a blog post about the math behind the geodesic ray tracer.
After fine tuning dual contouring the mesh seems to look relatively good on splashes. Also the depth of the liquid is ray marched per vertex, making it much faster to render than ray marching per pixel. I think I can still improve the mesh though.
Working on improving liquid mesh and render. Surprisingly by generating the initial dual contour mesh from an isovalue close to 0 and gradient descending it to a high isovalue counterintuitively makes the mesh much more fluid like and with a higher quad density.😳
Researching particle based destructible soft bodies(not PDB yet)
The approaches differ quite a lot from MPM-MLS, but the core idea is still the same - to track the deformation. In this case I track the deformation explicitly, by storing the original particle positions.
Zibra Smoke&Fire is pretty much perfect for creating cool ambient volumetric effect, in fact that's what I usually like to do, just mess around with a few point lights trying to make something pretty🤔
So I discovered that you can make super tiny SIREN networks representing SDF's that can be hardcoded into a single shader! blackle has made a shadertoy with such an example for a stanford bunny:
I've decided to put it inside of my path tracer to test it
Took me a day, but here it is, the particle cluster grid SPH fluid now in 3D.😤
It is probably the highest res 3D liquid sim in shadertoy, considering the ~1.5 particles per voxel.
Wonder if I can improve the render, takes a large chunk of the frametime.🤔
After fine tuning the rest density, smoothing radii, and viscosity algorithm, changing the merging and splitting a bit - the results are astonishingly good.
Perhaps its time to do a 3D version of this.
And there are no particles here, just a grid🤯
I have finally implemented exact particle number conservation with the CA particle algorithm. This allows me to make a simple and really fast MD simulation. You can see the crystalline structure as well as the crystal defects here.
I wanted to do this for quite some time - here is my first blog post! It's explaining the grid particle algorithm and how to implement fluid simulations using it. I used it for pretty much all of my latest simulations(including the fluids and slime molds)
Actually decided to try improving the anisotropic stuff, and also added some PBR as well as reflection ray tracing, but holy crap I didn't expect it to look THIS good🥵
Did some improvements to the WebGL water caustics. Now I compute the derivatives in texture space(with a precomputed texture), instead of ddx/ddy. It produces waaay smoother results, on top of that I also use a 512^2 caustic mesh, which looks really pretty.
I think this is the last Shadertoy demo for now. Fixed some issues with SPH and added proper refraction rendering. 🧐
Getting any better than this would probably require anisotropic kernels (gaussian splats??)
Implemented the Position Based Fluids paper by
Miles Macklin et al.🤔
Optimizing particle simulations is a true pain, and using groupshared memory is even harder. I needed to sort particles along the Hilbert curve for this to work. 💀
Right now I can run 8M particles at ~40fps.
Lately I've been trying to solve the multielectron Schrodinger equation using neural nets. In the video below you can see 2 hydrogens having a energy minimum at some distance thus creating a chemical bond.
Turned out my path tracer was totally broken for refracted rays(total internal reflection wasn't working), also the samples were accumulated with a lot of bias(to reduce noise), after fixing those I got some really stunning renders of fractal glass!
I kind of think at a larger particle scale, and thanks to having the mesh render, with the higher performance the liquid kinda feels more realistic. Also there is enough liquid to flood the entire room. Underwater render is still WIP. Also would be nice to add foam particles.
The path tracing adventure continues, I've figured out how to extend direct lighting to refracted rays, now I can kinda render sun caustics🤯
(here's the shadertoy, you need a beefy-ish GPU )
#define
V vec3
#define
f for(int i; i<9; i++)
V p=V(0,9,50.+fract(FC.x*.5+FC.y*.3)),a,l,x;a++;f f {f {x=p-V(0,i,0);x.xz*=rotate2D(t);V z=x.zzz*.1;f z=V(z.x*z.x-z.y*z.y,2.*z.y*z)+x*.1;l*=x=dot(z,z)<4.?V(.6,.7,.8):V(1);}o.rgb-=l*x-l;p+=V(FC.xy-r.xy*.5,-r)/r.x;l=a*=x;}#つぶやきGLSL
The last few weeks I've been working on optimizing the Zibra fluid solver, replaced the bitonic sort with a radix sort, P2G is now on atomics and rewrote the particle render. All in all I got a 3.5x performance improvement. Now I can do 3M particles in real time (~40fps on 2060).
Made another small demo using
This time I've used atomics to build a grid of lists of particles in sections of the screen, to then loop over them and compute the color. Can be used for good bokeh.
(although I wouldn't call this…
Made a spectal forward light tracer in shadertoy. Basically tracing rays not from the camera, but from the light source and then rasterizing them onto the screen.
Compared to path tracing this can easily render laser rays
Improved the CA neo-hookean solver, now should be stable more or less and be more accurate. For a test tried to model some rocky stuff, still jiggly a bit, but looks good. Blue glow shows the strain energy.
Messing around with volumetric rendering this time.
I wondered if reprojection will work for volumetric stuff, assuming a density isosurface, and it does work, even if not 100% correctly. Also the lights are importance sampled by distance.
Tried to implement the method described in the "Reconstructing Surfaces of Particle-Based Fluids Using Anisotropic Kernels" paper for better surface smoothness. It got quite a lot more expensive, while also being sometimes unstable, not sure if worth it
Made a really weird fractal flame based on a mandelbulb, looks like a moving stardust cloud. (oh the codec aint gonna like this video...)
Keeping the rng seed constant and varying the params makes the points move in interesting ways
Lots of people were asking how exactly does the cloth simulation work. I'll try to explain it in detail. The simulation itself runs using a Custom Render Target, its a weird asset inside of Unity that can execute shaders if its used as a texture on any object in the scene.
Improved the stability and performance of the GPU molecular dynamics solver. Around 1.5ms for 1M particles per iteration on a 3070. Not going to lie, this is really fun to play with. I wonder if one can make a game out of this🤔
So yeah, thanks to
#Putin
I can't really work on the liquid sim right now. And I was planning to work on some performance improvements, oh well.
For anyone worried, I'm fine, and currently in western Ukraine.
So for now I urge everyone to
#StandWithUkriane
to stop this war!
Tried to add volumetric path tracing to the mix to visualize the caustics, it takes like 50x more time to converge uh, so I was only able to render low res images, but here it is
Currently working on improving the way foam looks. Since the foam lacks high frequency detail I've decided to add a flow-map based on a few octaves of some Worley-like noise. Should improve the way the liquid looks with a low resolution simulation.
I've been collecting interesting shadertoys into a few playlists, might be interesting to someone
Reintegration tracking
Cellular automaton particles
Fluid solvers
Wave equations
(1/2)
Decoupled the performance from the hash grid resolution, now the speed only scales with the particle count. Meaning I can use an absurdly large hash grid like here! 250M voxels (1024*1024*256). Of course it still takes up a ton of VRAM, but oh well.
Combined MLS-MPM with Reintegration tracking, took some time to figure out why it was unstable, but now it seems to work, the velocity is advected really nicely, also the vortices are conserved for a relatively long time.
Shadertoy implementation:
Lately I've been trying to make a nonlinear wave equation simulation in curved space. That took way too much time, but I finally got something that seems to work. The wave equation behaves similarly to a liquid, and it's orbiting a Kerr-Newman black hole. Wave accretion disk?👀🤨
Decided to mess around with path tracing a bit, since I haven't done that in like literally forever. I've also been wondering about rendering SDFs as voxels using DDA, so I tried that, while also proportionally (to SDF) skipping voxels for performance.
Messing around with general relativistic FLIP simulations. Not sure FLIP is applicable to relativistic equations of motion, but seems to work more or less. In the simulation I've put a 45deg offset accretion disk around a spinning Kerr black hole (a = 0.95). Looks pretty cool 👀
Added shadows and some basic surface shading. Looks a bit closer to a liquid now.
Next I might try to actually ray trace the iso-surface and trace the refractions too (RIP GPU). Wonder how that will look like.
Messing with some basic GPU molecular dynamics simulations. Haven't done this in a while. Also first time doing it properly in 3D 👀. GPUs are pretty damn powerful. Also you can see some nice crystal structures here.
Improving the volumetric path tracing. Added anisotropic scattering and a better sky model. Fractals inside a fog look really awesome! (even tho take a lot of time to render)
So I thought I'd jump from physics to rendering a little bit. Inspired by Nvidia's spacio-temporal reservoir resampling I made virtual lights by fitting the incoming light using a gaussians and importance sampled that. That allowed to path trace stuff like caustics in real time.
Interestingly enough, when putting a particle density waaaay higher than the number of cells, you get constant splitting of the particles, untill they fill all of the space.
Messing around with a really large simulation grid (400*400*60, > 1GB of VRAM). Now I'm computing the SDF only around the fluid, so now it is much faster for such grid sizes, and kinda works in real time on a mobile RTX2060. I think there is still potential for optimization tho.