Natural Selection 2 is the sequel to the popular Half-Life mod Natural Selection. It is built on our own engine and will be distributed through Valve's Steam platform.
The team take you through their recently built effect editor for their engine.
Posted by LongBottom on Apr 7th, 2009
One of the difficulties with having such a small team is finding enough time to do everything that needs to be done. As the only engine and tools programmer, this can become a problem, since often my work can hold up other people's ability to make progress. While almost every other tool or system has been developed far enough that people can be productive, special effects is one area that hasn't gotten any of my attention thus far. This week I decided to rectify this and create the effect editor that we'll use to create all the special effects for the game.
Tools often fall into a "level of effort" category, where the amount of time they can take is unbounded; there's always one more feature you can add to make it easier to use or more powerful. Since there are lots of other tasks to be done before shipping, I decided that 5 days was the most I could afford to spend creating the effect editor. I think most people (including myself) would consider this a ridiculously aggressive schedule, but nobody said independent game development was easy!
Since this was such a short task, I decided to document the major stages of development as I progressed. I started working on the editor on Friday morning and it's now Monday afternoon. A power outage on Friday put an abrupt stop to development, but things are progressing smoothly otherwise.
The first step to building anything is creating a design. For tools, I always like to borrow ideas from other similar applications, synthesizing the best ideas from each into something even better. My hope is that by drawing on established user interface conventions, my tools will feel very familiar and immediately usable. This also speeds up the design progress by transforming it into more of an editing progress.
As a first step, I grabbed screen shots of the features I like from 3D Studio MAX and Photoshop � two tools that most artists are intimately familiar with. Normally I would have also grabbed shots from the effect editors that come with other game engines, but I didn't find anything I thought would be helpful in the ones I looked at. Typically at this stage I'd also talk to effect artists who had experience with making effects for other games, but I felt like I already had a general concept of the high level advice they'd give (e.g. make everything animatable) and I could solicit the detailed ideas later.
Like our level editor and viewer, I'm building the effect editor using our engine and the wxWidgets user-interface library. To get the basic framework of the effect editor up and running, I put together existing components with a little bit of copy and paste from our existing tools.
A solid undo feature is one of the most important components of a usable tool, and in order to make sure it worked great I started on this right away. Undo can be a little tricky, but fortunately I'd already built a good system for the level editor. I took the existing system, generalised it a bit and incorporated it into our engine library. Now the level editor, the effect editor and any tools I build in the future will all use the same system.
The next step was to start building the concept of time into the tool. Every effect editor I've seen is based around the concept of emitters which release particles into the world. The properties of the emitter and particles can be varied over their lifetimes to create all types of different effects, ranging from smoke to fire to unearthly magic Most effect editors use time varying graphs to represent and edit these properties.
While I wanted to incorporate this type of editing into my effect editor, I also wanted "key frame" based editing like you'd find in a tool like 3D Studio MAX or Maya. Since I'm still developing the tool, I don't know how well this will pan out, but my expectation is that this will make editing certain types of effects much faster and more natural. The video shows this type of key framing for the position of an emitter with a slider for scrubbing through the frames of the animation.
From this point I had a lot of details to fill in for the big functions I'd put in place. This included creating a UI for typing in values for properties, displaying the key frames on the time bar, and (optionally) rendering the trajectory of the emitter over time.
The next task was putting in the traditional curve editing user interface. In this UI you can see a graph showing the value of a parameter over time. The levels tool in Photoshop has a great graph editor that allows you to easily move, create and delete points with just the left mouse button, so I implemented a very similar mechanism in my curve window.
This final video shows the current state of the effect editor, with key framing, graph editing and manually typing in the values for emitter properties. I haven't implemented very many emitter properties yet, but with the underly framework I've built it's quite easy to add new ones.
Also noticeably missing are any actual particles. Because I have a very clear idea in my head of how this tool will work, most of my time has been spent building the infrastructure rather than trying to get something fully usable as quickly as possible. Particles will be going in very soon though! I think I'm still on track to hit my 5 day schedule.
What effect tools have you used and found useful? What would you change about them?