Showing posts with label unity. Show all posts
Showing posts with label unity. Show all posts

Tuesday, May 28, 2013

Cubemapped Environment Probes: Source Engine-style cubemap implementation in Unity 4 Pro


I wanted a static baked-in solution for doing cubemap-based reflections in Unity. Using cubemaps instead of (or with) traditional Blinn-Phong specular is great for games if (a) the light sources / environments stay static, and if (b) the player's camera will frequently be close enough to see small surface details. If that sounds like your game, maybe baked cubemaps are the way to go for you.

Tuesday, May 21, 2013

Post-partum: teaching Unity.

Here's a bit of reflection on my first semester teaching Unity at an art and design school, mixed undergrad / grad level. They're in the form of rough guidelines that I'm giving myself for next semester:

» Don't assume mastery of coding fundamentals. Some students will be able to formulate and solve abstract problems with little help, while other students will need to be taught the difference in syntax between variables and functions, repeatedly. Course prerequisites, even if enforced by your school's registar (at Parsons, they usually aren't), are no guarantee of mastery. In my class, I put a code comprehension section on the midterm exam, only to realize that some students didn't understand nested for() loops, which implies they don't fully grasp how unnested for() loops work either; but it was the midterm, and it was already too late. Some students didn't know how to use AND or OR, and some didn't understand scoping. I should've caught these problems earlier instead of unintentionally punishing them for it.
Recommendation: On the first or second week, conduct a diagnostic quiz that asks code comprehension questions, and assess which students need which kinds of help.

» Cover vector math, every day. Do light drilling. Even students with significant code experience may have trouble conceptualizing how vectors work together / what vector operations do, especially in 3D. I don't think I'd necessarily impose grade school drilling, like worksheets with 50 problems and 1 minute to solve all of them, but a few minutes or short drill, every day or week will help a lot.
Recommendation: At the start and end of each class, do some vector math problems together as a class. Practice thinking about vectors in multiple modes: visually as spatial coordinates, abstractly as sets of numbers, and procedurally as variables in code.

» Teach Maya and Unity, side by side, in parallel. I front-loaded the syllabus with Unity stuff, and only started Maya in the second half of the course. I think this was a mistake because we ended up having a 2 week break where students did very little code and focused on Maya, and it seemed to be like we were moving "backwards." I should've paced the class better to prevent this dead time.
Recommendation: When teaching the basics of 3D transformations in Unity, also teach the basics of 3D transformations in Maya, and emphasize the many similarities in interface and project organization: scene hierarchies, hotkeys, lights, materials handling, etc.

» Don't teach coroutines. I tried to teach this early in the course, and it ended up confusing a lot of people. Personally, I use coroutines constantly because I find them really useful for timing things... but maybe I shouldn't have projected my own practices on them.
Recommendation: Teach the use of timer variables and bookkeeping variables / using Time.time instead. It is worse practice sometimes, but it is a more immediately intuitive way of timing things, and reinforces fundamentals of controlling logic flow.

» End with procedural mesh generation / mutation? I really want this to be an "a-ha" moment of the course -- when students realize that everything is just a different way of storing data, and artists are just people who can figure out how to get the data looking and performing the way they want. Considering the emphasis on 3D, I think this is a much more coherent endpoint than my previous emphasis on AI and behavior.
Recommendation: If students have been working in Maya for a while and they understand for() loops, they might be ready to iterate through arrays of mesh data. Maybe look at implementing some Perlin noise or a simple sculpting tool.

This summer, I'm going to try to put these ideas into practice when teaching 6 week Unity intensives at NYU Game Center. Feel free to check-up on us on the class GitHubs (session 1) / (session 2).

Tuesday, May 7, 2013

Notes on first person virtual reality / implementation in Unity.


I've been implementing the Oculus Rift VR goggles into my first person projects, and the process has been... interesting.

Valve's excellent introduction to working with virtual reality (per their experiences in porting Team Fortress 2) is the definitive primer to working with VR in a first person context, and more or less the state of the art. However, it also ends with a powerful notion: we're only just beginning with VR, and it's going to take time before we know what we're doing. Here's a very brief summary of general design guidelines, as defined by Valve:

Sunday, April 7, 2013

The joys of sub-projecting in Unity


Let's say you have a personal Unity framework full of useful models, prefabs, shaders, scripts, etc. that you'd like to use across several projects. How do you best deploy that framework?

If you use version control, then maybe in each Unity project folder you'd also have a special folder hooked up to an SVN or a Git submodule. (Though I find Git submodules to be scary and unwieldy and more trouble than they're worth.) If you don't use version control, maybe you'll keep a separate Unity project just for your framework and from that you'll export a new Unity package every now and then, then separately import and update the Unity packages across your different projects as needed.

There's a third way that I'm trying, inspired slightly by how the Source Engine's filesystem works: basically, you keep all your projects *inside* a main Unity project, so they exist more as "mods" or "sub-projects", and they interface with each other as well as a main framework folder that has core prefabs and scripts.

Friday, March 22, 2013

Summer 2013 @ NYU GameCenter

This summer, I'll be teaching 6 week Unity studio intensives at NYU Game Center. The "regular" class during the semester is usually 15 weeks, so trying to fit all that material into a summer course will be, uh, interesting.

The sessions themselves are pretty expensive, but I believe that they do count for credit that you can put toward a degree. I believe non-students can also take it for non-credit status, which might be cheaper? Unfortunately, I don't set the price, so all I can do is to try to help you get your moneys' worth. You can look at the Github for "Building Worlds", the (15 week) Unity course I'm teaching at Parsons right now -- as well as a blog post on my general approach to game development education.

You'll, uh, also get to hang out with me, I guess. That's a perk, right?

Sunday, March 3, 2013

Unity to Android (Nexus 7) with Windows, notes / workflow troubleshooting

Some misc. "quirks" I encountered in setting up a build pipeline from Unity (on Windows) to Android on a Nexus 7... some is mentioned on Unity's Android quickstart docs, some required additional research. Anyway, if you're having problems, here's a pile of different things to try:

Wednesday, February 13, 2013

Approaches to game development education.

I'm currently teaching a Unity class at Parsons called "Building Worlds" -- and I'm treating it as my opportunity to get everything right and Solve All Problems in Game Dev Education... Obviously, the reality of the class is much more complicated, and ambitious teaching philosophies never really survive a semester intact.

But before I become bitter and jaded, here are the main principles / pillars I'm starting with:

0) Game development is not game design. The former concerns process, implementation, and engineering, the latter is the art of theoretically abstracting behaviors and relationships into something compelling.

1) Breadth. Everyone should know a bit of every aspect of game development, a "liberal arts" education in all facets of development, and everyone should be able to make a game entirely by themselves. All developers should have basic drawing / modeling skills, basic coding skills, and basic design skills. Of course, everyone has their specialties and interests, but the goal of game development education should be to produce independent, T-shaped developers who can see the big picture and collaborate when they need to. Don't specialize too early.

Wednesday, February 6, 2013

A smoother triplanar shader for Unity.


To review: procedural UVs are amazing and you should consider using them in your games. Now, the old triplanar shader I posted was great at hard-edged cubes, but it didn't handle the transitions between textures very gracefully; curved surface like cylinders and spheres were forbidden.

So I took a look at how James "@farfarer" O'Hare handled the blending in his triplanar terrain shader, and how Tom "@quickfingerz" Jackson grabbed normals in his own triplanar shader (but the blending in his shader would "blow-out" a lot, I found) and I combined their respective strengths. I also added different handling for top vs. bottom textures, since grass rarely grows on ceilings. (Textures in the shot above are from Farfarer's pack.) One last change: I let Unity's built-in surface struct calculate world normals instead of calculating my own.

So far, I've been unable to get normal maps working with it, so if any enterprising blog readers would like to instruct me how to do it, and share that technique, then I'd be much obliged.

Here's my shader so far. Do what you will with it:

Monday, January 21, 2013

Devlog: "Conanbowl"

(lighting / color test with random NPC mobs)
Me and Eddie decided we should make a game this past / current weekend. It started with our usual process: clicking "random page" in Wikipedia until something strikes us. This time, we were struck by "The God in the Bowl," a Conan the Barbarian short story where Conan has to solve a murder (?) when he's actually there because he wants to rob the museum, but then a ghost kills a bunch of people?

Anyway, this concept resonated with us: an adventure-ish game where you must steal things and solve a case; you're a kleptomaniac detective in Victorian-ish London, and you're assigned to cases where you're actually the thief.

Or something like that.

Tuesday, December 4, 2012

Teaching game development community.

In Spring 2013, I'll be teaching an undergrad / grad Unity course at Parsons called "Currents: Building Worlds."

The course has a few learning goals -- (a) to gain a broad conceptual understanding of how Unity works across art assets and code, (b) to learn some useful software engineering patterns for games, (c) to develop self-sufficiency for solving Unity problems / "learn how to learn", and lastly (d) to recognize membership in a global game development community.

That last one's probably the most ambitious.

Friday, November 30, 2012

Using screen-buffer masks in Unity Pro for a fog of war effect.

As I prototyped Convo, it became clear that I would need some sort of fog of war / sight radius visualization. Depth masks weren't very good for this because of the uneven terrain, and the other fog of war solutions I found involved a tile system (nah), or a vertex alpha plane (eww), or some other pretty convoluted thing. Lame. So I did a bunch of research and figured out my own technique... best of all, this visualization uses no script code at all, it's just shaders and geometry.

Also, you don't have to use this for fog of war. You can use it anytime you need to mask-off certain bits of the camera view on a per-object, per-triangle, or per-pixel basis. Like, maybe you'd want some stuff to glow red?...

The gist: (you will need Unity Pro since this uses render textures)
1) A camera's render texture is in RGBA format. You can technically do whatever you want with the alpha channel; most of Unity's built-in shaders use it to mask out alpha textures for various image effects.
2) If we use a shader that writes only to that alpha, we can use it to mask objects or pixels.
3) Then, we edit the image effect shader to modulate an effect with the alpha channel values.

If you need some more details and shader code, read on...

Thursday, September 6, 2012

What I'm Working On Right Now

So after coming back from Europe last month, I thought about why I haven't been good at finishing things these past few months, and I've decided to try making something different in a different way, and to see how well that goes. That means no first person, no reliance on written narrative, no vast architectural worlds, and no "art + writing first" approach, which is what I've been doing (with varying degrees of success) for the better part of this year.

Convo is a squad tactics game about linguistics and binge drinking, and I'm working on systems / interface first... I've never paid so much attention to UI before. I have a few ideas as to how to structure the narrative and such, but I'm avoiding anything resembling implementation right now. Roughly, I'd say it's based on the notion that a game narrative's job is to emphasize and/or problematize a game's simulation gap.

Someplace Else: Source is a Source remastering of Adam Foster's Someplace Else, in anticipation of Black Mesa Source's impending release and the 5th anniversary of Minerva: Metastasis' release. If you're interested in partnering for Minerva Day in some form (fan art? photography? sculpture? design criticism? fan fiction? etc.) then please get in touch.

I'm also in the middle of writing a three-part series of essays for Rock Paper Shotgun. It'll probably appear in about 2-3 weeks, and the whole thing will get published across a single week -- so lucky you, not much waiting involved.

Stay frosty.

Tuesday, August 7, 2012

"In Ruins" by Tom Betts


"In Ruins" is a first person procedural platformer-explorer thing. Spoilery critique after the jump:

Monday, August 6, 2012

How to dig holes in Unity3D terrains.


UPDATE FOR 2019: This post is 7+ years old, and new versions of Unity have updated the Terrain system. In principle, this technique should still work -- but the specific code and variable names are probably broken. I have no plans to update this post. Good luck.

Say you're making a Unity game that takes place in a large landscape dotted with windmills, and some of these windmills have tunnels that lead underground. But in Unity, the terrain collider is generated from heightmap data: it's essentially one giant bumpy plane. You can't punch holes in it.

Can we hack it to achieve the same result? Yep. Here's one way, there are two parts to it:

1) Hiding a piece of terrain geometry with a "depth mask" shader.
2) Disabling the collider so the player (or whatever) can pass through the hole, but collides with terrain other times.

If you need more detail, here's my specific implementation:

Friday, August 3, 2012

The Best Unity3D Tutorial Writer In The World

I hate video tutorials; they're slow, you have to consume them linearly / it's hard to skip around, and frankly I just don't think they add much unless cursor movements really matter, as in a ZBrush DVD or something. Textbooks (like, made out of paper) also suck because you can't click on the words.

Jasper Flick's Unity coding tutorials, then, are a revelation: a short essay, written in plain language, rendered on a clean webpage with non-patronizing glossary, just enough screenshots, and code snippets that link you to the relevant documentation. Wow.

You'll learn a lot about C# concepts / syntax too, which is what makes this series especially great, a focus on general fundamentals. So many tutorials hinge on a structure like "use rigidbodies to make enemies die" but Flick is more about "make enemies die to learn how to use rigidbodies."

The impeccable structure comes at a significant time-cost to Flick, so he's soliciting donations to add more tutorials, using a pretty novel timer mechanism.

Maybe I'll chip in. I just read his tutorial on mesh generation and custom inspectors and I feel like I can take on the world now.

Monday, July 23, 2012

"March" by Mindful XP


"March" is a first person art-platformer in your browser (never thought I'd type that) about a relationship by some students at Carnegie Mellon.

Brief spoilery review after the jump.

Friday, July 20, 2012

Return to Zobeide.


To tell the truth, I had kind of forgotten about Zobeide. My Twine / Unity interface experiment, instead of being my own version of Unmanned's interface, was strange and broken. People kept forgetting the text was there. But after conferring with some interactive fiction people at No Show -- where one had an interpretation of the game that made it sound much more fascinating than it really was -- I think I know what to do with this.



Expect another announcement in a few days (or weeks?)...

Wednesday, July 18, 2012

How to integrate Unity and Twine.

EDIT, 16 May 2013: Unity has changed their Browser to Web Player communications, but just a little. Basically, you don't use "getObjectById()" anymore, you just use "getUnity()" to get a reference to the web player -- more details here.

*****

Okay, I'm one of those people who thinks the problem with interactive fiction is that it's not sexy enough. However, I think IF, as a mode of interaction, is extremely powerful and is quite possibly light years ahead of whatever we're doing with narrative / meaning in the latest 3D whiz-bang video games.

Then one day I realized -- I could combine the CYOA tool Twine with the web player export of Unity, and the two could possibly hook into each other through Javascript. Turns out, they can.

Unfortunately, the project I used it for -- well, it didn't really work out -- but maybe someone else can use it?

The Unity Web Player has a useful method Application.ExternalCall() that can call Javascript methods on the web page. Similarly, you can call SendMessage() from a page script to call a method on a specific GameObject and even pass strings into Unity. That's the gist. If you need more help / my code snippets, a more detailed guide is here:

Friday, July 6, 2012

Rule Databases for Contextual Narrative... and spelling bees.


Valve's Elan Ruskin gave a fantastic talk at GDC 2012 on using "Rule Databases for Contextual Dialog and Game Logic" -- basically, the implementation behind the dialogue response system in Source games, most recently used in Left 4 Dead 2 and DOTA 2. I'm surprised more people haven't picked up on it because I think it presents some really effective research on procedural narrative systems.

A lot of game logic / narrative resembles a flowchart, especially with the advent of visual scripting systems like Unreal's Kismet or Twine -- resulting in this deeply entrenched concept of branching structure. Authoring and changing these individual branches is usually very expensive.

Thursday, June 7, 2012

7dfps: The Leaden Circles, prep

(I'm making an FPS in 7 days, as are many other designers. This is cross-posted.)

"One feels even in the midst of the traffic, or waking at night, Clarissa was positive, a particular hush, or solemnity; an indescribable pause; a suspense before Big Ben strikes. There! Out it boomed. First a warning, musical; then the hour, irrevocable. The leaden circles dissolved in the air."

Mrs. Dalloway is a novel by Virginia Woolf about a rich white lady in 1920s London throwing a party for a bunch of random acquaintances she doesn't really care about. She does it because she likes the attention and it's good for her husband's career.

It's also about a smart-ass white dude coming back from India who judges everyone.

It's also about a depressed World War I veteran who's going insane, hearing trees sing in ancient Greek. It's also about.... well, 20 other people.

It's not an easy read on the first try. Virginia Woolf wrote it in a "stream of consciousness" style, meaning you go back and forth between different characters' heads, often without warning -- sometimes several times in a paragraph. Sometimes you're reading what he thinks she thinks he thinks, as filtered by her (?!) but trust me, it's rewarding. Part of the idea behind making this is that hopefully it'll make the logic and systems governing the book (novels and narratives are systems!) more apparent.

Now, most of the different book covers feature a portrait of some random lady on the front... which totally misses the point. My favorite version is the one above, Wassily Kandinsky's Akzent in Rosa (1926). Sure, the book is about a Mrs. Dalloway, but it's also about consciousness, some kind of unseen universe on the edges of human comprehension.

My plan is to adapt Mrs. Dalloway as "The Leaden Circles," a single player squad shooter with a stream of consciousness mechanic, kind of in a Space Hulk format. You'll ping pong between the different characters, chaining together thoughts, memories, and feelings -- and to win, you have to get this rich petty vapid white lady to feel something deeply profound at the end of the day.

I'll be using Unity, C#, Maya, Audacity, Photoshop, and source material from Virginia Woolf, CGTextures, FreeSound.org.

Let's do this, and good luck to everyone!