Home Artists Posts Import Register

Content

Major Annoyance: gfycat.com recently went through a giant purge and deleted some of my video links in my older posts. I will be going back and restoring them all slowly. Uggh. Going to upload to my Dropbox to ensure they live forever from now on.


From the previous post, the math between a cylinder (cup) and a plane (surface of water) was very easy to implement since a lot of it simplified away. The fact that the plane of the water will always be at a local (0,height,0) and the cylinder at (0,0,0), I was able to cross off many variables and calculations. A quick video of the water in the cup can be viewed here.

Then I made a shader to slap onto the model. One thing I have to fix is getting rid of the visible artifact on the model. This is an error with triangle ordering and rendering translucency:

Shortly after I realized that I wanted this water method to work with cone shaped cups, not just straight cylinders. The problem was that the math for a plane and cone intersection is very messy because it can produce a parabola, a circle, hyperbola, and ellipse. Which would have made it very annoying to calculate. However, I realized I could keep it as a cylinder+plane and offload some of the work to the GPU. Simply discard pixels outside of the cone in local space a la signed distance fields. Video 2 shows off the proper culling.  The yellow is area that is below the cup in local space.

Next thing I wanted to do is a good way for it to look like it's spilling, since I have the intersection of the water and cup, I was able to tell when the water is spilling over. I wanted the actual mesh to flow out. And so I needed to find the 2 exit points (marked in red):

From there I built another mesh and made it look like it's spilling out. Eventually I will add physics checks so it spills out slowly and collides with stuff. Video 3 shows off the unfinished spill effect so far.

Lastly, I wanted the level of water to decrease based on how much water is being spilled out. One big problem I had to really fiddle with is make it look like the volume of water remains consistent when you rotate the cup because this is all an illusion and there isn't any liquid particles inside. Video 4 shows off my attempt so far.


Files

Comments

No comments found for this post.