HW3: Changing Gravity

CS 482/681, Dr. Lawlor

I'd like you to build a fluid dynamics simulation where the gravity direction is not constant relative to the simulation's grid. 

Specifically:
  1. Begin with a phase field fluid dynamics simulation that responds to gravity.
  2. In JavaScript, set the gravity direction as the angle Math.sin(0.1*lib.time) radians, with 0 radians meaning gravity pushes straight down, and every frame update the orientation of the textured square showing our simulation output tilted to that angle.
  3. Get the direction of gravity into the fragment shader.  (I used a float to pass in the angle as a uniform, you could also use a uniform vec2 to pass in the gravity vector, or recompute it from time inside the shader.)
  4. In the shader, force the outer 10% of the simulation domain to be stationary (zero velocity).
  5. Apply the varying gravitational acceleration to one phase of the fluid, assuming that phase is 10% denser than the other fluid phase.  You can ignore the centrifugal and Coriolis forces due to the nonuniform motion of the grid itself (this is plausible if the grid rotation is slow).
You should verify that the fluid slowly sloshes against the sides of the box in a plausible fashion, and that the simulation runs smooth and stable.

Fluid sloshing with changing gravity.

To save your PixAnvil simulation, hit the "Save" tab, select all the text, and save it to a .html file using a plain text editor such as Notepad.  Turn in your model and updated .html simulation as a .zip file on Blackboard (you'll need to log in first) by the due date of Friday, April 14.