CS 184: Foundations of Computer Graphics - HW6

cs184-bw: Szu-Han Charles Wang, charleswang007@gmail.com

cs184-au: Steven Wan, xa1cap0n3x@gmail.com


In HW6, we extended HW3 to add new functionality, and make the assignment really nice. In HW3 we created a Cal Theme Park, with modern-rotating Ferris wheel, wild-African elephant, Renaissance-elegant Venus, exotic-Egyptian pyramids, colorful-shining crystal balls, navy-blue pillars and finally, real grass ground.

Previously, we created those pillars and the Ferris wheel by specifying their geometric vertices in space. The elephant and Venus were created by OBJ files. The two pyramids were made from RAW files. We textured the inner ground a Cal logo; the outer ground a grass texture, using PPM image format. Our scene has a blue directional light source that points from the bottom left of the scene as well as a yellow point light source that is located at the bottom right of the screen. Our display is initialized with GLUT_DOUBLE and GLUT_DEPTH, this means that our scene is rendered using double buffering as well as hidden surface elimination. We also call gluPerspective() to set up the perspective projection matrix of our scene.

New functionalities and features are documented below.

Environment Mapping

Our fragment shader implements environment mapping in addition to the lighting done for HW3. Objects can be displayed using environment mapping by setting isEnvMap to 1 before drawing the object. The 2 front spheres in our scene are environment mapped. Our vertex shader implements displacement mapping by shifting the vertices of the object depending on the value of the texture at the vertex location.

Newton 2nd Law Kinematics

In HW3 four color balls were bouncing on pillars as if they were doing free-fall kinematics, but did not strictly follow Newton Second Law. We improve the animation by implementing F=ma and its derived constant acceleration kinematics to render it more realistic.

In the left you see the flow of the ball movements. In the beginning, four balls are stationary on the pillars (height=h) but pushed by impulse which results in their initial velocity. Then the balls are rising in the air, with gravity being the only force exerted on them. We assume a=g=9.8 m/s^2. As the balls rises, their velocity decreases until they reached the top (height=H), where their velocities become 0. Their rising distance is denoted d. Soon after, they start free-fall motion until reaching the pillars, at the time which their velocities reverse directions and the cycles continue. We implement a global timer and the physics equations are shown on the left.

Animated Textures
We allow textures to be time varying on the playground such as a slide show. We alternate back and forth two different Cal logo images, both in 300X225 PPM format. We implement a timer for the slide show. If time (secs) is mode 5, we texture the playground with the yellow Cal logo; otherwise we texture it with the blue Cal logo.
Particle Effects
We include particle effects for steam from the teapot. Steam is basically water vapor, whose behavior follows the ideal gas law: PV=nRT. The equation suggests that the state of an amount of gas is determined by its pressure, volume, and temperature. In SI units, n is measured in moles and T in kelvin. R has the value 8.314 J.K-1.mol-1 or 0.08206 L.atm.mol-1K-1. We make an assumption that the teapot is observed at S.T.P, where at the sea level the Temperature and Pressure are 273K and 1 Atm. We model the steam particles as mini oval objects. As the steam rises, since PV is constant and pressure is decreasing so its volume increases. We model this fact by increasing the lengths of the oval axis. Images from four camera views are shown.
Procedural Modeling
We apply procedural modeling to create two identical fractal objects. Procedural modeling generally refers to a wide variety of techniques for automatic model creation. It is often used to create models that are too complex for humans to build. We run a procedural modeling program to render fractal trianglea. Initially, there is just one red right triangle. We connect the midpoints on each side to form four smaller triangles. We color all small triangles except the central one red. Then we start the procedure again for each red triangle. The algorithm is recursively called before the final fractal is formed. Procedural modeling is often associated with a set of rules, configurable by parameters. In our example, we set an iteration of 3. We may have made use of randomness for variety. The fractal triangles in our scene are self-similar when viewed at different scales.
Interactive Rendering
We extend HW3 into a video game with interactive gameplay. Our RED ALERT game has a set of grid planes right above the four balls. The player can pause the vertical movement of balls at any time. If the balls touch any of the grid planes, the game is over and the player loses. Conversely, if the balls stay away from the planes when paused by the player, the player wins. This simple game illustrating the idea of interactive rendering is shown on the left.