Tuesday, July 30, 2013

VFX of The Last of Us: Bills Town

Subtlety
This is a difficult thing to convey when working with visual effects. You want to create some movement and visible interest but it also needs to feel appropriate given the context of the environment. In The Last of Us this was particularly difficult because the weather wasn't always in some extreme state. For the most part things needed to feel calm and peaceful while being juxtaposed with horrific realities happening around you. I think it's because of this setting and tone that fools you into thinking you're safe but you know better. This brings me to Lincoln or as we referred to it, Bills Town.
Life Goes On
In Bill's Town there's only Bill, and of course the infected wandering around. No electricity, no human life. This was a constant theme throughout the game and it required us to explore other ways to create movement and life. We did this though things that weren't as obvious as animals and things of that nature. We used small swarms of flies and gnats that you end up walking through, grasshoppers that jump back and forth and loose pieces of paper trash that fly around in the wind to name a few. I personally had to really think about how to create the movement without it being intrusive or out of place. I borrowed a technique from one of our lead effects artist Eben Cook where I would take a still from the level with no effects in it yet and do some paint overs to try to imagine what effects would look good in areas. This helped a ton to see what worked and what didn't. I wanted to describe this because I think it's important to explain that visual effects in a game are not something that just get plopped down without any forethought. There are some effects that you have on hand and you know they will work well in many areas but before we lay them down we put a deal of thought into how it all fits together. This game was a great practice in restraint as well. An effects artist we could put any number of things into a scene to convey movement and so forth but you also need to be able to look at something and say "It only needs this one thing." and be alright with that. Just because we can doesn't mean we should.

Wind Effects
We have a wind system in the game that controls how things like trees and other geo behave to simulate the appearance of wind. In previous games we have created effects that best match what this looks like to us, but we were always just eyeballing it. We had to orient our emitters in the direction of what we perceived the wind to be and while this was fine it could be a little slow at times and they didn't always remain consistent. In this game we decided to ask for the ability to fetch the wind direction and strength from our global wind system so that we could use those values to control some of the behavior in our effects. I created a simple script that grabbed the wind direction and intensity and passed it to one of our global wind fields we exported from Maya. This allowed us to put things like leaves falling from trees and any other particles we wanted to have flowing in the wind wherever we wanted without having to worry about emitter orientation. So in Bills town I created a number of effects to take advantage of this, like grass and dusty dirt that gets kicked up randomly.

I created the video below to demonstrate some of these concepts at play. Ranging from subtle wind effects to in you face decapitation effects for the infected. There are spoilers so be warned if you haven't played the game yet.

Tuesday, July 9, 2013

Deep Snow Prints

Spoiler Warning!!!!!!!!!!!!!!!!!!
Be aware that the video below shows some footage that would be a spoiler for someone who hasn't played the game yet. I apologize for that.

Splash!
Long ago in the before time we didn't have a way to artistically control the footprints characters could leave on surfaces. The footprints in Uncharted 2 were smaller in scope and artists were limited in what they could do with them. Since then we have had some considerable support in a system that allows us to spawn effects based on collision data from objects in the game. Using joints in the game we can cast rays from joints that probe surfaces and use that information to test some conditions to spawn effects once those conditions are satisfied. We call this system the Splasher System. Originally it was just for creating splash effects for characters in water but it's a lot more intricate now. The splashers are something I'd like to go into more detail on at a later point if I'm allowed to. It's a great system but on the PS3 it became quite expensive and we had to scale back how many characters and objects used this system.

Projected Particles
One of the greatest things we have is the ability to project materials onto objects using our particle systems to generate the projections. This sounds like a decal system and in it's most basic description, it is. Our Dedicated effects programmer Marshall Robin, during uncharted 3 developed for us the ability to spawn projected particle cubes that utilize a number of parameters to project materials that we author onto surfaces. For example we can use this system to write directly to our destination normal buffer. This buffer takes the normal value of every pixel in screen space and writes to this buffer. Out projected particles directly perturb this buffer. Our lead effects artist Keith Guerrette, used this technique when creating the sand footprints in Uncharted 3. They can animate and do all sorts of great stuff. We can also draw these projected particles to the same buffers we draw all of our other particles to. So we can draw projected color based materials onto surfaces which is very much like the decals you are used to seeing. There is a lot of overdraw cost in these projected cubes so we don't like to use them all over the place just where it will have the greatest impact visually and where surfaces tend to have a lot of deformation. In the video I put together you'll see the outline of some cubes and those are the projected particles.

The Materials
We are lucky enough to have our own node based shader authoring tool. If you've ever used UDK's material editor it's a lot like that. Knowing we can only project a flag image onto the surface I used a technique that in UDK is referred to as bump offsetting. The idea is that you can use the camera direction to bias your original uv values modulated by some constants to create the illusion of parallax. The camera direction vector is a unit vector that ranges from -1 to 1. This is ideal because uv coordinates are commonly in tangent space which typically range from -1 to 1 as well. Of course you can push the values to whatever ranges you want but you would soon find the problem with that. The camera direction is a vec3 and I really only need 2 of the components from the camera direction. The x component and the y component. So I separate all three and recombine x and y back into another vector that is only x and y.


Using these vectors I multiplied them by a texture of a deep simple impression I made in Maya. The texture is the equivalent of a displacement map. By multiplying the camera direction vectors by the texture I create a more complicated and interesting shape of parallax per pixel. Now, what to use these crazy uv's on? I used the displacement map texture to create the illusion of shadowing inside the pit of the print. One of the unique things about our shader authoring tool is that we can define how our alpha is applied. This is similar to Photoshop layer stylings. You know things like multiplicative and additive and so on. The difference being that our options don't have those kinds of presets so we need to know how that alpha blending works. The simple version of what we have to work with is the source pixel (the pixel we are trying to draw) and the destination pixel (the pixel that is already there). Then we define some arithmetic on each of those alpha blending attributes and then by default the result of those two get added together. The majority of our materials multiply the source pixel by 1 so the alpha we are trying to draw just remains as is and then we multiply the destination pixel by one minus the source alpha. So the inverse of our alpha we are drawing. I didn't want to try to create any color of the footprints beyond what was already being drawn there. So the only color in my material is the shadow for the deeper parts of the print to make it look darker. For the alpha blending I set my source alpha to be multiplied by the destination pixels color. So now my alpha has within it the color value of the pixel that is already there. Then my destination alpha is multiplied by 1 minus the source alpha. Since my source alpha has within it the color of the destination pixel I don't want twice the color value when the two values are added together. That's a little complicated I know but totally worth it.


In Conclusion
There are some other things I did to create the prints but the bulk is being done in that one material with the fake parallax. The video will quickly demonstrate how the material is being modulated by a float to control how deep the parallax goes. These prints were important because we couldn't create any dynamic displacement of the geo and the player needed to have something to clearly track the deer. I'm proud of how these prints turned out. We tried to create prints like this for Ellie and I spent a good deal of time on them but it was difficult to make it look like she was leaving long trails and tracks in the snow. So I opted for the prints that write to the destination normal buffer to make it look like long streaks in the snow. Anyway, enjoy the video.

Saturday, June 29, 2013

Cockroaches in The Last of Us

Spoiler Free I promise
(Unless you count the roaches as a spoiler)

 


These little guys might go unnoticed in the game but I am particularly proud of them. This was a tag team effort between Eben Cook and I. With a shout out to Nick Lance and Kurt Margenau a couple of awesome designers I work with. Sometimes our effects team might conceptualize an idea but we don't always have the means to create what we want as it requires support from programmers and it's hard to justify pulling a programmer on to something that most likely is not worth their time. I had been exploring our scripting engine in more depth since the end of Uncharted 3 where I had begun using it quite extensively. It's a very flexible scripting engine similar to Unreal Script and LUA based on LISP. I like it. Let me just put that out there. I love things like this because it allows me to think in ways I may not have before. I always like when there is this complex problem to solve and when I come up with a solution I like to admire it's intricacy. Our dedicated effects programmer Marshall Robin, shortly after Uncharted 3, had given us the ability to declare variables in the root data of our particle systems. These variables could be used in our expression when authoring our effects and we could set the values of these variables at runtime. What all this means is we could change the way our particles behaved on the fly. Muahaha. So with all of this in mind Eben and I thought "You know we could totally make some cockroaches that scurry away in some fashion." So Eben setup the cockroaches. They are aligned with their velocity and while they are not being affected by anything they are just randomly moving about based on some expressions Eben setup in the effect. This is where the root data variables (Rootvars as we refer to them) come into play. We basically have this boolean value in the expression that while set to 0 will have them acting normally just moving about and then when it gets flipped to 1 it triggers a condition in the expression to make them scurry in a direction along the z axis of the particle spawner. We simply add some spawners using our level propagation tool and face their z axes in the direction we want them to scurry in.

The next stage is where I had some fun. So I have all the pieces of the puzzle in front of me. I have a set of functions our designers use for other gameplay purposes but I know they will be what I need to get these roaches working. Additionally I didn't want the script I made to be something we could only use once. I wanted it to be something that any other effects artist could just throw into a level and it would do all the work. To do this I needed to be able to let the artist specify the name of the spawners in the level to perform operations on and I had to allow for any number of spawners. I did set a limit of 100 spawners in the script but if we ever had that many in a level it would be insane. I think the most we ever got up to was 8 or 10. The script spawner allows for a user to specify data directly on the spawner in our propagation tool. So the artist just enters the names of all the spawners for the roaches on the script spawner. For the artist that's it. That's all they have to do. The script itself contains two sections. The first creates a symbol array that we refer to as a group. So the script checks the data on the spawner I mentioned and if that data is specified it adds that roach spawner symbol name to the group. The function that does most of the work here is basically a while loop with a counter. The next section is where the real work is being done. Now that I have a group of symbols I use some functions to create some conditions for the script to check on those symbols every frame. I check the distance between the player and the roach spawner. I check to see if the roach spawner is within a specified radius from the center of the screen. and I check to see if the flashlight state is on. If all three conditions are satisfied it sets the boolean switch (Rootvar) on the roach spawner that has met all of the conditions to 1 and the roaches go scurrying away. The first time I saw it working I pooped a little.

So that's how all that works. It might sound expensive but it was all actually relatively cheap to run because it wasn't all that complex on the runtime side. Of course the more spawners we iterate over the more expensive it would become but it never got to that point and we were always mindful of that. The reason why I loved this whole setup so much was because of what it represents. It represents how flexible our tools have become to allow us to fully realize an effect without having to request any tool support. All the pieces to solve the puzzle and many others like it are at our disposal. While the end result is just some roaches, the concepts we learned and put into practice here have larger applications across other areas when creating effects and completing effects related tasks. This level of creative problem solving takes shape when the tools expose more access to the inner workings of the effects to the artist. I will say that we are super freaking lucky to have the support we do because if it weren't for Marshall exposing the root data to us we couldn't do this and a lot of other things. Also big thanks to Kurt and Nick for showing me cleaner and smarter ways to write the code for the scripts.

Wednesday, June 26, 2013

Visual Effects in The Last of Us: Hometown

VFX TLoU
Spoiler alert!!!!!
The visual effects in The Last of Us consisted of a wide variety of things ranging from subtle ambient wind effects and insects to in your face molotov explosions. Each artist typically will own a handful of levels and will be responsible for creating the effects needed for that level. Additionally we have to create gamewide effects such as weapon effects and melee effects based on animations that happen all over the game. So just like I did with Uncharted 3 when we finished I'm making some videos and posts detailing what we worked on in the levels we were responsible for but I will also be going more in depth in later posts on some gamewide things that I thought were interesting struggles and the solutions we came up with to make it all work. I really want to shed some light on how we go about creating the effects we do and talk up my teammates because they are amazing. So in short I'm going to be creating a series of videos I'm just gonna call "The Visual Effects of The Last of Us".


Hometown
Originally when I was told how this level would play out I thought "That's cool I can handle this.". Wrong. But I'm super lucky to have the people I do to work with. Keith Guerrette really stepped up and helped to get this level done. The effects in this level were much more chaotic compared to other areas of the game. This is where the "Uncharted" in me went wild with explosions and sparking wires. I know a downed power line wouldn't spark like that but just go with it.

Joel's House
The first thing I worked on was the burning house on the side of the road and the barn. I used this area to prototype the fires I would use in other areas of the level. I used a lot of those concepts I worked out there for the burning buildings in the town. From there I created the explosions seen upstairs in Joel's room and the fire effects in the video with the reporter on screen. It's funny because I spent a good amount of time on that even though I knew it was going to end up on a small screen in the game. It's also worth pointing out that one of our rendering programmers Ke Xu worked out a way to increase the resolution of the runtime reflections without increasing the cost to render them. So the smaller the object with a reflective material the higher the resolution of the reflection. I constantly would joke with him saying "Reddit will love you for this." Keith stepped up to handle all of the other effects for the downstairs area of Joel's house and the effects for the drive into town. He also made the lens flares for the tops of the cop cars which was really cool. I used those lens flares on the helicopters flying around. We worked together to create some scripts to control the dirt kicked up by the car as it drives so that when the car would brake the smoke would look like it was being lit by the tail lights of the car.


In Town
With Keith's help on the other areas I was able to focus on the chaos going on in the town. It starts with their car being hit by a truck and I must have changed those glass particles like 30 times. The final result came out good though. I created a script to handle all of the events in the town that needed effects. For example the glass as Joel kicks it to each new horrible thing that happens as you move through the town. The gas station explosion had some amazing concept art to go on and I made a material that I thought worked fairly well for gas that shoots out during an explosion and then that gas ignites in mid air. This all happens really fast but it created a nice result. As you approach the end of the street near the theater there's a car that goes rolling by on fire and then explodes. I have the car leaving a trail of gas fire behind it as it rolls but like a lot of things in the level you can't take your time and look around less ye be attacked. As you run out the back of the bar I made some lingering dirt dust where the ambulance went off the road. These kinds of effects are subtle but add a lot of atmosphere to the environment.








The Sad Ending
When we work on cutscenes we have to watch them over and over again typically frame by frame. We don't hear any dialogue or anything but after enough viewings and having seen the mocap from the stage capture you know whats going on. I worked on the typical stuff like blood when the soldier is shot in the head by Tommy and dust as Joel rolls down the hill and scrambles towards Sarah. One of the interesting things I was able to work on was the tears on the characters. I created a hacked together kind of tool that allowed our animators to animate tears running down characters faces and we also used it to apply bloody hand prints from Sarah onto Joel's shirts where she grabs him on the shoulders. This cutscene is very emotional and the tears did a good job conveying that sadness. I'm glad we spent the time on that. Of course The scene wouldn't be what it is without Troy Baker and Hana Hayes. They did such an amazing job portraying those characters. I'll be adding more posts in the coming weeks.

Friday, June 14, 2013

The Last of Us Is Out!

The day has finally arrived. The game is out and we had an amazing turn out at the midnight releases. I will be updating this area with things I worked on in the game and other game vfx related stuff. If you haven't picked up a copy yet I highly recommend it. Not because I am personally invested in it but because I enjoy the shit out of good games and this is a great one. In the meantime checkout the trailer for the making of the game. The making of video is really awesome.

Monday, December 10, 2012

Last of Us Story Trailer

Sticking with the tradition of me only posting what I can when I have time to, here is the latest trailer we have released for the game. We worked on the trailer while simultaneously working on the game obviously. This essentially meant we didn't want to create anything for the trailer that wasn't in the game. You also want to make sure everything that goes into the trailer is as polished as can be. This is good because if you finished for the trailer you finished for the game. Burt being the perfectionists that we are I can personally say I will continue to polish until my eyes bleed. Enjoy!


Wednesday, September 5, 2012

Last of Us Extended Gameplay Demo

This is a video from PAX which was also the behind closed doors theater demo at E3 for our current project The Last of Us. We worked hard to get all sorts of minutia in the details. Things like the molotov and how it functions, blood fx on the characters faces and how blood hits the environment, ambient fx like dust and falling leaves that float on the water as they impact it, weapon fx, and even dust that is kicked up by enemies when they shuffle their feet during combat. There are numerous things that our team additionally crafted that I can't wait for people to see and experience. Enjoy the video.