Ray Tracer + Tanks VR Game

Tyler Dahl - CPE 473 - Spring 2016 - Zoe Wood

Ray Tracer

For the majority of this quarter, we worked on building a Ray Tracer that could simulate reflections, refractions, Bounded Volume Hierarchies, Anti-aliasing, and Global Illumination. By utilizing ray tracing techniques, effects such as reflections and refractions came naturally, whereas they would have been expensive to compute using rasterization. It was difficult, but I was able to get all aspects of my ray tracer fully operational and below are some of the renders I thought were particularly beautiful.

Color Bleeding via Global Illumination

This is a simple scene of a rotated cube and a sphere within a room. The walls of the room are different colors to showcase the color bleeding that takes place when doing Monte Carlo Ray Tracing in order to simulate global illumination. The cube and sphere are colored white so that the color bleeding will be easier to see. The front and back walls are also reflective so that we can see the effects of the color bleeding on the backs of the objects too. This scene was rendered using a maximum of 2 bounces for reflections/refractions and 128 rays per initial intersection for global illumination.

colorBleed.pov

Room of Reflective and Refractive Cubes and a Refractive Sphere with Anti-Aliasing

This complex scene was created using a room of reflective planes and a cube composed of smaller cubes within this room. The cube composed of smaller cubes also contains a sphere at the center of it, which is refractive. Some of the smaller cubes are reflective and some are refractive. This scene was rendered using a maximum of 5 bounces for reflections/refractions and anti-aliasing. I like this scene because it shows the interplay between reflections and refractions and there appear to be hundreds of cubes, when in fact there are only 27.

awesomeReflectRefract.pov

Mysterious Mickey with Refractions and Anti-Aliasing

I particularly like this scene because the reflections reveal something that otherwise would not have been seen. Behind the camera is a staircase. In front of the camera is a figure representing Mickey Mouse. It is almost as if Mickey is deciding whether to ascend these stairs or not. The refractions used in Mickey's body also look really cool as they reflect off the back wall and then refract back through again. This scene was rendered using a maximum of 5 bounces for reflections/refractions and anti-aliasing.

mickey.pov

Tanks VR Game

For the last week of the quarter, we worked on a Virtual Reality project using Unity and Google Cardboard. I personally had never used Unity before, but had always wanted to try it. I went through several tutorials to learn how to use Unity and to obtain cool ideas for a project. The tutorials I completed were How to Make a VR Game With Unity and Google Cardboard, Roll-a-Ball Tutorial, and Tanks Tutorial. I did not go through everything on the 3rd tutorial as the videos were all 30-60 minutes in length. I learned how to make a 3D Unity project into a VR project using the first tutorial, and I learned how to navigate and use Unity using the second and third tutorials. I utilized many of the assets from the third tutorial, such as the map, tank, and bullets. I also added in the rotating cube from the second tutorial, which can be collected by the player if they drive through it.

In my VR project, I decided to mix aspects of the tutorials I had completed and mess around with things to see what I could accomplish. The player drives around as a 3D tank, shooting bullets by pressing on the screen. The longer the press, the more powerful the bullet will be and the farther it will travel. When the bullet collides with an object, it causes a 3D explosion and if a tank is nearby, it will enact a force on the tank, pushing it away (you can also implement health in the third tutorial, but I decided not to). The bullet also contains a light source, which causes it to light up the ground below it as it flies around. The tank emits dust particles behind its wheels as it drives around. The tank makes a driving noise as it drives around the map, an idling noise when it isn't moving, a powering up noise when the screen is pressed, and an explosion noise when the bullet explodes. There is also background music going on, and I used an audio mixer to balance the various noises in the game so that no noise overpowered the rest. There are also small cubes scattered throughout the map that constantly rotate, and make a noise when the tank drives through them, adding to the tank's score and dissapearing upon contact. Sadly, I could not quite get the score to show up on screen.

Probably the hardest part of this game was figuring out how to get everything to work in VR. The second and third tutorials mentioned nothing about VR. They were purely 3D game tutorials. I had to add the VR elements to the scene and position the VR camera in the correct location and attach it to the tank so that wherever the tank moved, the VR camera would also move with it. I wanted the player to be able to move throughout the scene, so I made it so that tilting the VR device would cause the player's tank to move or rotate. I figured out how to do this by looking at the Google VR documentation online and experimenting with values. Tilting forward will make it move forward, tilting back will make it move backward, rotating your head left will make it rotate left, and rotating your head right will make it rotate right. If you want to sit in a chair and play the game, I also added support for tilting your head left to turn left, and tilting your head right to turn right. Thus, all 3 axi of the VR headset's orientation are used to control tank movement. I then used the screen press as the trigger for firing a shot. It took some research to figure out how to determine whether a user was pressing on the screen vs just clicking the screen. The default boolean used by the Google VR SDK only specifies when a click has occurred, not when the screen is still being pressed. I used Input.getMouseButton(int button) to get the mouse pressed information, which I eventually found by Google searching and looking through documentation (the Unity documentation is awesome btw).

Here are some screenshots of the game.

map
tank
non-VR game with cardboard button at bottom-right
VR map 1
VR map 2
VR explosion 1
VR explosion 2

Resources