Monday, April 18, 2016

Hashtag Enlightened

In my first post, I promised step-by-step instructions on how to waste eight hours building lighting for a game, and I think the time has come to deliver. The amazing thing I learned about Unity3D's Enlighten (which is the part of the engine responsible for baking the lighting) has come up in conversation quite often lately, and I realized that a lot of other people have had the same problem I had.

Short disclaimer before we begin: I'm a big fan of Unity3D, as I use it for just about every project I do lately. That said, sometimes even the people we consider to be our closest friends can do some really stupid shit. It doesn't make them any less of a friend, but you know we can't just let them live that down.

So let's just get right to the step-by-step guide, ladies and gents (but first, a little bit of context).

You may have heard me talk about the World of Plankton Project, because that's arguably the biggest project I'm working on at the moment. If you haven't, I'll probably do a post explaining it in more depth--but for now all you really need to know is that it's an educational simulation of freshwater ecology and all the fun stuff that entails.

Anyway, as project manager of World of Plankton, I have a lot of duties--one of which is making sure we have working builds for certain milestones. On top of that, one of our milestones also required me to make a video showing off what the project is so far.

Sidenote: I don't claim to know anything about making or editing videos. I had never used OBS or any other video capture software before making the WoP demo reel. If you're also using video capture software for the first time, you might want to listen to the following advice:

If you're going to make a video using OBS, do not assume that, just because you've told it to record the video playback from a specific window, it will also record the audio playback from solely that window alone. It won't. It will record the audio from everything else on your computer making noise, including Facebook Messenger if you also have that open; and--in case you're so used to hearing that notification sound (because maybe you're in a lot of chats that are often pretty lively)--you should really double-check that the notifications you're hearing are actually from Facebook and not from the video--because let me tell you just how embarrassing it would be if that video was perhaps posted to YouTube and linked to a bunch of people before you were aware that anything was wrong with it. It would certainly suck to have another team member figure it out and tell you what the issue was a full three or so days after you posted the video. Definitely don't let that happen.

Not that I'm necessarily speaking from experience here--this is all strictly hypothetical, of course.

*cough*

But for all intents and purposes, let's say you did release a video with a bunch of random notification sounds in it and didn't know how to remove them without just recording the video again. You'd probably just need to open OBS and take it from the top--but perhaps that seems too simple for you. Maybe you want it to be more of an ordeal, because it just wouldn't be fun any other way. Well, you're in luck. Here's how to waste the maximum amount of time before finally re-recording your video:

Step 1: Open up the project on one of the lab computers that you've been using for the past week or so. Using the same computer as usual should help you avoid having to download all of your data onto a new computer. 

Step 2: Get ready to start doing the video capture. Since you don't have administrator access to the lab computers, you're going to have to run OBS from a flash drive.

Step 3: Realize that the USB ports on the computer you've got all your data on are absolute garbage and have apparently already bent a friend's flash drive out of shape.

Step 4: Decide to boot up the lab computer behind you and take the video capture there instead.

Step 5: Wait approximately ten minutes for SourceTree to download the entire project to the new computer. Then, wait another twenty for Unity3D to load in all of the assets this project has.

Step 5.5 (Optional): Browse Reddit or shitpost in one of your Facebook chats while you wait.

Step 6: Come to the conclusion that you might as well use the most up-to-date version of the project for the new video, since one of your teammates has apparently made some major optimizations to the performance of the project, and we like 1080p 60fps videos because they're buttery smooth.

Step 7: Remember that the data from baking a scene's lighting is only stored locally, and therefore wasn't pushed to this computer when you downloaded all of the data onto it.

Step 8: Start building the lighting in the main scene and wait approximately two minutes for it to finish.

Step 9: Fix some bugs in the main scene and commit the changes.

Step 10: Realize that you have a quiz soon and that you should probably go take it. Hopefully this video capture doesn't take too long.

Step 11: Start building the lighting for the intro scene. This one has a lot of terrain with a lot of trees, so it will probably take a while longer than the other scene.

Step 12: Wait for way longer than you originally thought you would have to.

Step 13: Go take your quiz. Sitting through the entire lecture today is not something your schedule is going to allow for, though; thankfully, the quizzes are at the beginning of class, so you can just go and then come right back.

Step 14: Return to the lab to find that Enlighten is still in the clustering phase. Resign yourself to the fact that this is probably taking a while to bake because it will be that much more optimized at runtime. Convince yourself that the time you're spending is worth it for the project to run smoothly.

Step 15: Wait for other people to come to the lab after their classes are finished. At least now you can talk to someone in person about how obnoxiously long this is taking.

Step 16: Decide that the baking might be taking too long to be worth it and start to tinker with the numbers in Unity's lighting tab to make it build faster. Start making a build on the first computer you booted up which you can then transfer to the second computer once it's done.

Step 17: Realize that the build on the first computer will still have the bugs that you already fixed on the second computer but didn't transfer over. Oh well. At least once it bakes the lighting once it won't have to bake it again, and you can just transfer over the bugfixes and build the project way faster the second time.

Step 18: Wait to determine if the second build is actually going to take any less time than the first.

Step 19: Realize that neither computer will probably be finished for a few hours, and boot up a third computer in an attempt to bake the lighting even faster. Repeat Step 5 with this computer. Leave the other computers running because we've already come too far to turn back at this point.

Step 20: Start messing with the lighting settings to try and reduce the build time. Eventually decide that a low-quality lighting bake is probably fine for how far the camera is from the terrain and start baking the lighting with lower settings.

Step 21: Wait for the low-quality bake to finish, and get increasingly agitated when it appears to stall on one of the final steps.

Step 22: Look up what the potential problems could be. Tweak more numbers based on suggestions from online forums.

Step 23: Repeat Step 21. If you've followed the steps precisely up to this point, you should notice that the bake is faster, but still stalls in the same spot.

Step 24: Go eat dinner because you've been at this for hours and haven't eaten a damn thing since lunch.

Step 25: Come back to the lab and check on the progress of your first and second builds. Getting close, but still another hour or so to go, you estimate.

Step 26: Go back to the forums to find out why this stupid thing is stalling. Pray that the other two builds won't stall when they get to that point, but have a sinking feeling that they will anyway due to Murphy's Law.

Step 27: Decide to stop the first build and start over with terrain set to lightmap static. You have no idea why that wasn't the case earlier, but you think that'll probably make it go a little bit faster. Keep the second build going just in case it isn't. You decide that you want this build to have high-quality lighting, because you can just make a low-quality build on the third computer in the meantime.

Step 28: Make a low-quality build on the third computer in the meantime.

Step 29: Watch it get to the same point where it always stalls, albeit in record time. Poke around the forums some more. Someone else must have encountered this bug. There has to be an answer somewhere.

Step 30: Notice that both of your other builds have stalled at the same point as the one on the third computer. Contemplate defenestrating one of the lab computers to make yourself feel better. Decide against it because you can't afford to replace one of these workstations. 

Step 31: Pantomime defenestrating a computer instead to one of your colleagues who understands just how fed up you are with this whole thing.

Step 32: Go back to the forums and read that perhaps the reason you're having trouble is because you have a primitive shape in your scene (e.g. a cube, a sphere, etc.). Think to yourself how ridiculous this sounds and how stupid it would be if it actually solved the problem. Why would a simple shape be giving Enlighten such a hard time?

Step 33: Search through the scene hierarchy for primitive shapes. Find and delete a cube. Start baking the lighting again. Assuming you've done everything correctly up to this point, you should notice that the lighting takes a little under two minutes to complete, and no longer stalls right before finishing. They've got to be kidding you.

Step 34: Shout obscenities.

Step 35: Stop your other two builds. You're just going to use the one with the low-quality settings because it doesn't even make that much of a difference from that far away and it's been way too long for you to care anymore.

Step 36: Load up OBS and re-record the demo reel, making sure to have all other applications closed before you start.

Step 37: Edit the video using Adobe Premiere Pro.

Step 38: Remove the old video from YouTube and upload the new one to your channel. Wait approximately four minutes for it to finish uploading.

And there you go! If you've done everything correctly, you should have wasted approximately eight hours before simply removing a cube from your scene and setting the terrain to lightmap static. If you've reconsidered and just want to do things the easy way, simply do steps 4, 5, 9, 33, and then 36-38.

I hope you found this step-by-step guide to be helpful, and I urge you to leave a comment if you have any questions.

Until next time!
--JBird

No comments:

Post a Comment

Want to tell me something? I would say I'm all ears, but that'd be a gross exaggeration of my physical appearance.