In this semester project we are currently working on, I have done an VR interaction of fluid flow based on the Perlin Noise. The implementation is based on the paper Curl-Noise for Procedural Fluid Flow. In addition, several github projects have worked on that, using curl of the Perlin noise vector field in shader files to create fire and movement of falling leaves. However, the work people have done on this topic are in a static state of curl flow.
What I was doing is a CPU side dynamic fluid flow corresponding to the hand movement in Virtual Reality circumstance.
Purpose of using this technology is to create a more immersive experience in the Virtual Reality.
According to the paper, to simulate a turbulence, the divergence of the air flow movement in the area should be zero. To create a non-divergence field, curl of a noise vector field is applied. Perlin noise is the ideal noise for this circumstances because it is differentiable at any point.
In the implementation of the curl Perlin Noise, I used Noise Generating package keijiro/NoiseTools. He uses a value noise generating method and trilinear interpolation to create a 3D differentiable noise. To get the random vector field, the gradient of the 3D noise can expressed as ( (noiseAt(x,y,z)-noiseAt(xInt,y,z)) /xFractual , (noiseAt(x,y,z)-noiseAt(x,yInt,z)) /yFractual , (noiseAt(x,y,z)-noiseAt(x,y,zInt)) /zFractual ).
According to the implementation of the project keijiro/KvantSpray,the cross product of the neighborhood gradients can approximate the curl value.
As the feature of the turbulence has been implemented, the big challenge of a dynamic interaction-based turbulence generator is the amplitude function that defines the amplitude change across the time and distance.
The amplitude of the curl noise behavior is separated into two parts. The first part is invariable with time but linearly related to the position as the hand move away from the object. As the object is more far away from the hand joints when hand reaches the closest position to the object, the less curl force will be applied to the curl noise force. The closest position is determined by the sign of the dot product of the hand-object position vector with the hand velocity vector.
The second amplitude is an exponential attenuation according to the distance of the path the noise ball has moved since the curl force is involved.
In addition to the curl noise behavior of the object, another force model is implemented to to fake the laminar flow. In this model, the force is generated according to the movement of the hand relative to the position of the object. As the hand move closer to the object, the object will have a force to be pushed. In the other hand, it will get a force of pulling. The amplitude and the direction can be easily represented with the dot product of the hand velocity and the relative position of objects according to hands.
As the implementation of the force system, the performance of the system did not fit in our requirements. As more than two objects or both hands get involved into the curl noise calculation process, the frame rate dropped tremendously to less than 10 fps. The optimization is done by adding a process of determine the nearest moving hand involved in one object curl noise calculation. Moreover, the computation of each object becomes asynchronous. Only two of the objects is computed the curl noise behavior for each physics frame. Eventually, the system can handle even dozens of objects in real time.