Search This Blog

Saturday, October 20, 2007

Unity3D


Unity3D












OTEE's Unity3D promises to be what the Mac needs and many of us have wanted for years, a program that is to 3D what Macromedia Director was to 2D. It's close enough that it will take your breath away, but it falls short of its promise in ways that may frustrate many potential users.


A Little History


There have been many radically innovative programs on the Macintosh. MacWrite, PageMaker, ImageStudio (monochrome precursor to Photoshop), Live Picture (even if it ultimately failed), Illustrator, Fontographer, Authorware, Futuresplash Animator (Flash), Avid Media Composer, After Effects, Dreamweaver, Swivel 3D, HyperCard, Lightspeed Pascal, PowerPoint, and even Excel. Phew, what a long list.


One of the most radically innovative Macintosh programs started life as Videoworks, but became well-known as Director. Director is now circling the drain, with no significant updates since 8.5 (MX was simply "Carbonised", and MX 2004 added a bunch of DVD support and made Lingo more like JavaScript), over five years ago, and no Universal Binary.


So, what is a multimedia/game developer seeking reasonably state-of-the-art tools to do? Director is moribund, most of its competitors - from mTropolis to iShell have fallen by the wayside.


Unity3D - The Promise



Physics? I ducked that class in high school! Here is a whole bunch of programming you won't have to do.


Unity3D sets out to be the ultimate 3D game development environment. In many ways it succeeds, and in fact it succeeds so well in many respects that it comes close to being the ultimate multimedia development environment. For $250 (for the indie version) you can easily put together interactive 3D programs, dashboard widgets, and web plugins. With a little more effort you can produce 3D screen savers.


For $1500 (for the pro version) you can also produce Windows executables and gain access to a number of higher-end features, including render-to-texture, C++ plugins, and gorgeous preset full-screen and shader effects (such as the currently popular "bloom" effect). You can put together some things with little or no programming. If you just want to display a 3D model or animation, you don't need to write a line of code.


To produce an interactive walkthrough, you need only write a few lines of code. You can bring in models and animations produced using Maya, Cinema 4D, Cheetah 3D, or any program that can export to FBX, which covers most high-end 3D software, including Lightwave 3D, Softimage, and 3D Studio Max. With the first three programs, the workflow is seamless. Otherwise, you simply need to export an FBX. Unity3D also supports Blender files, although it currently cannot import animations.


If you do want to program interactivity, Unity 3D offers you a choice of three scripting languages, "JavaScript", C#, and a fairly obscure language called Boo (think compiled Python). Each of these languages is pretty easy for a programmer familiar with C-like syntax (e.g. PHP) to pick up, although the environment is a little quirky.


Features


Unity3D is very much a state-of-the-art real-time 3D tool. First, it supports all the latest graphics hardware (you can even write your own vertex and pixel shaders). If you don't know what vertex and pixel shaders are, then the short answer is pixel shaders are the difference between DX8-10 and DX7. They're what CoreImage is built on. Vertex shaders are the difference between being able to barely animate two human figures at a time (in say the original Tomb Raider) and being able to animate forests.




Coding Unity3D. This much JavaScript code handles the character (collisions are handled without code in this case) and the camera movement. The behavior is completely configurable from the IDE (e.g. you can change the character's walking speed, turn rate, and so on).


Second, Unity has the Aegia Physics engine built in. You can simply click on an object and pick "rigidbody" from a menu to make that object subject to gravity and collisions. Stack up some objects, make them rigidbodies, click "play" and you see a Physics simulation instantly. Unity3D also supports hinges/joints, springs, forces, and so on. Unity's built-in particle system is terrific, and it plays well with Physics too.


Third, Unity offers excellent audio support, including effortless implementation of 3D positional audio (including doppler-shifting sounds from moving targets).


Pretty much everything you'd expect to work, whether it's importing animations from powerful animation tools like Maya, or normal maps, or sky boxes, just works. (If you've ever tried to work with Director's 3D import, and character animation in particular, this may sound like Science Fiction, but yes, it's true.)


The simplest way to put it is this. Go look at a current single player AAA console game. Chances are, Unity3D can do that stuff. But remember, I said "single player" and "console". Unity3D doesn't have much support for networked multiplayer games. It offers all the networking functionality present in .NET 1.x, but this is kind of like saying a C compiler lets you write networked multiplayer games. It's also lacking in 2D and video support, as we shall see.


Underpromise and Overdeliver


In some ways, Unity actually exceeds expectations. It comes with very good examples (more are available on the website), solid tutorials (including several video tutorials), and the features of Unity 3D that were developed internally are well documented. Unity3D has excellent forums and a growing wiki and the developers are very responsive to questions (and actually use the software themselves). In many respects it is the model of a bleeding edge 21st century software company, the kind of guys who ship a new version of their program while waiting for Dilbert's pointy-headed boss to shut up in a meeting.


Flies in the 2D Ointment



Setting up 2D interface objects. If you want to build a 2D interface in Unity, you'd better learn to love this little panel. The "Pixel Inset" values are misleadingly named, they should be called "left, top, right, bottom". Each 2D element is "pinned" to a screen x,y coordinate (each ranging from 0 to 1) by a handle (located top/center/bottom by middle/center/right). So positioning an element involves setting the handle and then the "pixel inset" values as offsets from the handle. You certainly can't just pick up an object and drag it into position. And automating the process is difficult for other reasons.


All is not perfect in Unity land. From my perspective this comes down to five things.


First, Unity's JavaScript isn't really JavaScript - it's about as different from JavaScript as, say, ActionScript. Unlike JavaScript, it supports (optional) explicit types, lacks many dynamic features, but is compiled and runs insanely fast. The speed is wonderful, but the subtle differences from JavaScript and the minor but irksome inconsistencies of the underlying runtime environment can be infuriating (e.g. arrays have a .length property, but strings have a .Length property … or is it the other way around?) and aren't well-documented.


Second, Unity leverages a huge amount of open source functionality. E.g. it incorporates the Mono code-base for .NET functionality and the CLI (Common Language Infrastructure; hence C# and Boo; "JavaScript" is built on top of Boo). The functionality is welcome, but the lack of documentation and widely varying "standards" can be frustrating. Unity's documentation is pretty decent - as far as it goes - but you won't find third-party books on its flavor of JavaScript, or those portions of .NET it happens to support.


I should note that on the positive side, Unity's forums are incredibly lively, full of very helpful and knowledgeable people, and the developers are extremely responsive to questions, feedback, and bug reports.


Third, as much as the developers have lavished attention on its 3D capabilities, Unity3D's 2D capabilities are relatively awkward. You certainly can't just drag a 2D interface element into position, just forget you even thought of that. First you need to give it a pseudo coordinate, then you need to pin it to that coordinate, then you need to edit some pixel offsets. Building 2D interfaces (and most good 3D games have a significant 2D component) is, at best, fiddly. There's nothing - or very little - you can't do, but much of what you can do is, say, far more difficult than doing things in 3D is in Director.


Fourth, while the development environment is completely live (which is great) there's no actual debugger you to let you step through code and watch variables. (Such is the curse of the new generation of programming languages). The live environment lets you create fairly solid workarounds (and when a script crashes, the game keeps running; you just get an error message, and it will point you to the line of code that caused the problem), but sometimes you just want a debugger to step through code, and Unity doesn't have one.


Finally, Unity3D's undo is, at best, quirky. This would normally be a crippling deficiency, but oddly in Unity, it's merely annoying. In part this is because so much of your work will be done in a text editor or 3d tool (either of which probably have working undo). In part it's because its interface is so powerful in other ways (see the section on workflow, below). In any event, Unity certainly needs to improve its undo support.


This Revolution Can't Be Televised Yet


The major missing piece of functionality in Unity3D right now is video support. If you want to play a video on a TV in your virtual world, you'll need to have the Pro version of Unity3D, a sketchy third-party plugin, and a good measure of luck. I doubt it would get through any kind of QA process. This is sad, because if Unity3D had robust video functionality it would essentially eclipse Director in all major functional respects.


For multimedia developers, there is a potential workaround. Unity can run in a web browser and offers excellent browser/JavaScript integration, so you could combine Unity with Flash or QuickTime inside a browser, but you can't really allow the two things to overlap.


Of less importance to me is support for Director's many many supported file formats, notably Flash (hardly surprising, but still), HTML, or humble text. (Why is it that developers of multimedia software always forget text?) Given all these shortcoming, you won't be able to seamlessly replace Director (or Flash) with Unity in your multimedia production just yet.


The Unity 3D Workflow


OTEE is justifiably proud of Unity3D's workflow. To develop 3D games/applications, aside from Unity itself, you'll need a compatible 3D modeling/animation tool (e.g. Maya, Cinema4D, or Cheetah3D), a suitable image editing tool (e.g. Photoshop), and probably an audio editor (e.g. Amadeus Pro). You may want to use your own text editor.


Unity uses its own version of Smultron (called "Unitron"), which is perfectly decent, although if you have your own favorite text editor, you'll probably prefer to stick with it. As mentioned earlier, Unity3D's workflow with the apps mentioned is seamless. When you double-click an asset in Unity, it opens in the source program. When you save changes, Unity updates automatically by doing all the export work without your having to.



This is the Unity3D development environment. 1: this is my game running. 2: this is the 3d world editor; my character is currently selected (but I can change the selection while the game runs - the entire interface is live and modeless). 3: this is my character's transform, which is visibly changing as I run around.


A word about what using Unity is like (in case you don't feel like downloading the rather hefty disk image to try it out for yourself). Unity runs its game engine live in the development environment (so you can see what you're doing live and interact with it live). Furthermore when you run your project, the development environment is live. E.g. if you instantiate an object at runtime, it appears in the development environment and its properties change in real time. You can pause the game, manipulate objects and properties, and continue. Live. I repeat: live.


Again, I should mention two other key features of Unity3D in practice:


If you write a configurable script (e.g. it might have several user-editable properties) all you need to do is declare them (e.g. var name : String = "Fred";) and the variable becomes user-editable in the main interface. If you create an enumeration and set a variable to that type, you get a popup menu in the editor interface. Powerful, elegant, and beautiful. (If you've written user-configurable behaviors in Director - shudder - you're probably drooling on your keyboard right now.)


If you want to reuse a particular configuration of objects, e.g. an object nested in another object with a few components and scripts, you can turn it into a "prefab".


You can then create instances of that prefab anywhere (e.g. by dragging it into a scene) or create instances it at runtime with a single line of code. If you modify a prefab, it remains linked to the original, and you can reset it to the original (entirely, or one property at a time) or make the prefab conform to it (with a single menu command). Again, the equivalent operations in Director range from being difficult to near impossible, and if you've build reusable components in Flash, well, this is a lot easier.


Time to ship. You may wonder, after all this, how difficult it is to build an application with Unity. Well, you select a menu item. Now, congratulate yourself on a job well done and have a beer.


Unity not only publishes with a single click, it performs image compression "just in time". So you can keep your textures as layered Photoshop files knowing that you can tune the delivery format at the last moment by modifying Build Settings. It would be even cooler if Unity could do the same thing with level of detail in 3D models and audio compression, but I guess we can't have everything.


Performance


Obviously, all this functionality comes at a hefty price in performance. To run the Unity3D development environment you'll want the latest eight core Mac Pro with at least 16GB of RAM and dual 30″ monitors. This is only reasonable, since you probably want this kind of setup if you want to play with Aperture or Motion, right?


I'm joking.


Unity3D runs just fine on my 1.2 GHz iBook with 1.25GB of RAM (indeed I wrote a little game on my iBook while we were snowed-in in Denver over Christmas). I bought my license after trying it out on my (since supplanted) dual 1GHz G4 Power Mac. Not every high end feature works on older hardware, although surprisingly many do, and GMA 950-equipped MacBooks and Mac Minis run Unity just fine. I've repeatedly been surprised at how many of Unity's higher end effects work on older hardware. As projects become more complex, resource requirements increase and you can never have too much memory. Certainly, if you can run the latest Maya or Cinema4D, Unity3D isn't going to trouble your hardware. Unity3D is not the resource hog you might reasonably expect it to be.


So, what's it for?


Is Unity3D a solution looking for a problem? When VideoWorks first came out it certainly seemed to be. (But then, it originally had no scripting language.) Unity3D was obviously conceived of as the ultimate game development tool, but it has obvious applications for developing education and training programs, interactive multimedia, VR applications (yes, they still exist), and presentations.


Its existence appears to be owed in large part to major initiatives in the EU toward funding the development of compelling educational software for use in schools. Clearly, for almost all of its potential users, its major missing feature is stronger 2D layout functionality. Unless you're developing a certain kind of game, you're going to need a fairly complex user interface at some point, and as of now building it in Unity3D is doable, but not pleasant.


Conclusions


Pros


Bleeding Edge 3D Graphics
Given its capabilities, gentle learning curve, good tutorials and documentation
Given its capabilities, modest hardware requirements
Amazingly Interactive IDE
Seamless workflow from Maya, Cinema4D, and Cheetah 3D; solid workflow from most high-end tools
Aside from undependable Undo, amazingly Mac-like
Lets you target Macintosh, Windows, and Web Browsers
Excellent Price ($250 for Indie License, $1500 for Pro)
Amazingly helpful and friendly people at OTEE, developer community, forums, and Wiki
Upcoming Wii support
Cons


Undependable Undo in IDE
Clumsy 2D Capabilities
No real video support
Gaps in the documentation send you to Google or the Forums (e.g. "JavaScript" and Mono)
Possibly a little "too visual" to work well for very large projects
It's not fair to review Unity3D as a Director replacement, since that's not what it's intended to be. Unity is intended to allow anyone, from a hobbyist to a small, serious development team to produce their own Quake, or (more likely) compelling 3D educational and training software or promotional tools. It is intended to let you deploy your finished product as a Mac or Windows program, or as a web plugin (or, soon, as a Wii game).


As such, with some of the generally minor issues discussed above set aside, it succeeds admirably. You will find building the 2D components a little painful, but nothing terrible. And you can always minimize your 2D interface components in favor of realtime 3D. But, life isn't fair. Whether it's intended as a Director replacement or not, Unity3D practically screams to be considered for this role. Unity is only missing video functionality and improved 2D functionality to be the next Director.


For now, if you're even mildly interested in developing 3D games, you should try Unity3D (it has a free trial).





Technorati :

No comments:

Find here

Home II Large Hadron Cillider News