Particle-based Visoelastic Fluid Simulation - this experiment is based on this paper, modified for multiple fluid collisions and optimized for realtime simulation. If the frame rate is lower than 30fps the bar is greyed out. The maximum is 5000 and the default framerate is 40fps. Particle bar shows a number of particles on the scene. shows the number of particles on scene Grid - use Grid for drawing straight lines delete Air Emitter (visible when edited) Remove - remove liquid, pipes, sewers, ducksĪir - draw Air Emitter (visible when edited)ĭelete A. Sewer - create sewer, if you want to remove liquid P - Pipe - create water, oil or foam pipe Oil - create oil, lighter and higher viscosity than waterįoam - create foam, very light with high viscosity Added pipes and sewers for a never-ending complex water system. This simulation is quite process-intense, sometimes it helps when you close other tabs in a browser. It is based on smoothed particle hydrodynamics (SPH) - Langrangian method of fluid simulation. The maximum number of particles (drops) is 5000. Vec4 downColor = texture2D(velocity, vec2(pixel.x,pixel.y+yPixel)) įloat div = xPixel/2.0 * ((rightColor.x - leftColor.x) + (upColor.y - downColor.This is a new version of liquid simulation sandbox, in which you can create water, oil and foam, add pipes and sewers, draw walls and air emitters.Ī new Grid function is added for drawing straight lines. Vec4 upColor = texture2D(velocity, vec2(pixel.x,pixel.y-yPixel)) Vec4 rightColor = texture2D(velocity, vec2(pixel.x+xPixel,pixel.y)) Vec4 leftColor = texture2D(velocity, vec2(pixel.x-xPixel,pixel.y)) Uniform sampler2D velocity //Our input texture It gets access to the users local GPU through WebGL. ![]() Gl_FragColor = texture2D(velocity, pixel) ![]() Vec2 gradient = xPixel/2.0 * vec2((rightColor.x - leftColor.x), (upColor.y - downColor.y)) Vec4 downColor = texture2D(pressure, vec2(pixel.x,pixel.y+yPixel)) Vec4 upColor = texture2D(pressure, vec2(pixel.x,pixel.y-yPixel)) Vec4 rightColor = texture2D(pressure, vec2(pixel.x+xPixel,pixel.y)) Vec4 leftColor = texture2D(pressure, vec2(pixel.x-xPixel,pixel.y)) Uniform sampler2D pressure //Our input pressure Uniform sampler2D velocity //Our input velocity Gl_FragColor.b = (gl_FragColor.b * alpha +leftColor.b + rightColor.b + upColor.b + downColor.b)* rBeta Gl_FragColor.g = (gl_FragColor.g * alpha +leftColor.g + rightColor.g + upColor.g + downColor.g)* rBeta Gl_FragColor.r = (gl_FragColor.r * alpha +leftColor.r + rightColor.r + upColor.r + downColor.r) * rBeta Vec4 downColor = texture2D(x,vec2(pixel.x,pixel.y+yPixel)) Vec4 upColor = texture2D(x,vec2(pixel.x,pixel.y-yPixel)) Vec4 rightColor = texture2D(x,vec2(pixel.x+xPixel,pixel.y)) Vec4 leftColor = texture2D(x,vec2(pixel.x-xPixel,pixel.y)) X = gl_FragCoord.x - dxt0 * (texture2D(velocity, pixel).x ) Uniform sampler2D quantity //quantity to advect Uniform sampler2D velocity //input velocity Uniform vec2 res //The width and height of our screen Here are the shaders I am using: //advection Instead of posting all of my code, the general process I follow is:įor diffusing velocity and computing pressure I am only do 10 iterations because thats all my computer can handle with my implementation (I will optimize once I get it working), but I feel like the computing pressure and subtracting gradient are not having any effect. I can supply any pictures/links to the simulation if that would help.Īfter some more investigation I believe the problem is related to my advection function. I know the code I am posting is al little confusing due to the nature of what it is about. ![]() I calculate pressure using the diffusion shader as described in the linked resource. ![]() I displayed the divergence and I get very little around where I am moving the object around as well as when the velocity hits the edge (boundary), but the pressure that I get is completely empty. I added boundaries but it seems like they are having no effect, which makes me suspicious about how much pressure and advection are working. I have implemented everything but I feel like there are multiple things that aren't working correctly. I am trying to get a fluid simulation to work using WebGL using as a resource.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |