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...

Monday, November 26, 2012

Radiator Blog: Three Year Anniversary


Wow, I've been blogging here for about 3 years now. This blog is now approaching the end of its toddler years. Much like last year, and the year before, here's a "greatest hits" compilation of this past year's posts:

(Oh, and feel free to have some cake. Forks and plates are over there, on the table.)

GAME ARCHITECTURE CRITICISM

COMMISSIONS
  • Level With Me, a post-mortem. A Portal 2 mod I did for Rock Paper Shotgun. The level design is some of my better work, and I like the idea of game journalism in the form of games, but it seemed somewhat cooly received. I have to conclude that it must simply be not as good as I think it is... or that Portal 2 players are super lame.
  • The Future of the FPS, written for PC Gamer UK in issue 240. A short essay and list of really cool indie FPS games and how they're changing the genre, kind of the basis for my later RPS series. Thanks Graham!
  • A People's History of the FPS. A three-part essay series for Rock Paper Shotgun that argues mods are transcending their video game bodies, becoming genuine culture that is increasingly independent of the products that they're meant to be "modding" and adding value to.

ON GAME NARRATIVE
  • The myth of psychological realism in narrative. Argues that thinking of fictional characters as "people" is meaningless for a writer. It is much more useful to write by thinking of a character as a vehicle for plot, and let the player fill-in character for themselves.
  • Dishonored fails as an immersive sim in its first minute. The simulation should be "immersive" -- meaning, the scope of it should be consistent and everywhere. Scripting special cases goes against this genre dogma.
  • Dishonored uses the Heart to lie to you. You'd expect the Heart to be an unreliable narrator of some sort, but it doesn't lie to you with narrative -- it lies to you through gameplay and psychological framing.
  • "Stair K": architecture criticism, Thief, and a coffee maker. Situates Thief as dialog on social class and urban architecture. (e.g. stairs are invisible to rich people who take taxis, not subways, and frequent buildings with abundances of elevators) It argues that in Thief, stealing is framed as an ethical act because the rich deny the truth and infrastructure of cities.
  • Thief 1's "Assassins" and its environmental storytelling. I really hate the type of analysis that just thinks of game narrative as a static text that you read -- game narrative is also a game design tool, a way to make the game better to play. Games tell stories, yes, but those stories tell games too.
  • What do simulations simulate? Argues that a simulation gap is important for framing a narrative.
  • The structure of Sleep No More (part 1, no spoilers) and (part 2, detailed and spoilery). You paid a lot to see this damn show everyone's raving about and now you're inside, on a timer. Are you going to spend your valuable time (a) reading faint scribbles on random pieces of paper under a dim flickering light-bulb or (b) follow the crazy naked people who have an interpretive dance orgy in a blood-smeared disco?

    I still think a lot of "game critics on Sleep No More" like the idea of it more than how people actually consume it -- unfortunately, reading is boring and performance is captivating. So I argue the readables function as set dressing to assure you of the production's expense, not to serve as barely coherent narrative in a familiar plot that's hundreds of years old. Of course, the dancing's fantastic, but I guess it's hard to argue for the value of dance to gamer culture.
  • Rule Databases for Contextual Narrative. On modding Valve's dynamic self-branching conversation system and using it to author dynamic self-branching narrative, and how Emily Short's already doing something like that, naturally. I think it's one of the more promising directions toward a holy grail of procedural narrative.
  • Balls and conversation: let's narrativize the sports genre. I really love baseball movies, but I'm really bored by the focus on statistics, which is probably why Moneyball sucked. There's a rich tradition of sports narratives in film and literature, but in video games it's conspicuously absent. Let's change that.
  • "Do you think shooters take themselves too seriously?" We watch blockbusters in a special way, I think, but the gulf between action films and action games is this: the films are structured to be human and sympathetic, but games are sociopathic and mean. This is a game narrative writing problem.

ON GAME CULTURE
  • Frog Fractions should really win something at the IGF.
  • On appreciating the UV texture flat as fine art. Here, I propose three aesthetic modes for enjoying texture flats on their own merits and glorifying them as authentic game art, rather than the silly concept art we parade as game art. I later re-wrote this piece for Game Developer magazine, as "Loving the Bones."
  • Desperate Gods and rules-forcing in games. Pretty recent, but I think it's a good summary of current thought on the issue -- if you can play a game of Starcraft in your head, and Starcraft exists fundamentally more as a mental construct than a product, then why can't we just argue the rules of Starcraft in the same way we interpret and amend the laws of board games.
  • On grad school for games / what studying at Parsons was like. Imagine a cohort of game developers from all around the world, and 50% are women, and 10% aren't straight people. Parsons is like the rainforest: diverse, beautiful, and vital to the global ecosystem -- but it's also humid, with lots of insects everywhere, and it's constantly in danger of deforestation. It's not for some people, while others will really grow to love it.

GAME CONFERENCE / FESTIVAL NOTES
  • Why Indiecade is the best games conference / festival I've ever been to. It might sound like hyperbole but it really isn't.
  • I spoke at Games for Change this past year, on LGBTQ attitudes and developers in games. It went great. I began with "I'm Robert Yang, and I'm a practicing homosexual" -- and the entire auditorium erupted in applause and cheering. It was an amazing feeling.
  • Notes on the Games for Change industry. Fun fact: I got into an argument with a G4C speaker in the comments. His stance -- yeah the games suck, but people want to put a lot of money into this, so just accept it. My stance -- art should be a free or reasonably available public good, not a product.
  • How the worst part of the game industry uses PAX East to teabag your entire face with its cancerous scrotum. I encourage everyone to go to at least one big mass market game convention, because that's when you will know what "indie" really means and you'll realize how small, puny, and insignificant we "video game intelligentsia" really are. The sheer amount of money being thrown around in this industry is insane -- the money spent on a 20-foot tall Blops booth-complex, blaring out noise at a regular interval, is a huge contrast to the humility and humanity of indie game culture.
  • What were the main trends of GDC 2012? A look-back on what happened and what stuck out as significant.

    UNITY TUTORIALS / RESOURCES
    • Shader-based worldspace UVs ("triplanar") in Unity. The worst thing about BioShock's environments is the cookie-cutter feel of the game architecture, the result of modular building in game engines today. The scale and proportions don't feel human or plausible. To me, one answer is to embrace old school BSP construction techniques with procedural UVs so that you can scale your primitives to arbitrary sizes without texture stretching.
    • How to integrate Unity and Twine. Notes on Unity's web player JS hooks, and how that can feed into Twine's JS, or any webpage's JS, really.
    • How to dig holes in Unity terrains. How to use depth mask meshes to selectively mask geometry, then disable the terrain collider temporarily.
    • The best Unity tutorial writer in the world. He really is. I'd pay him to write a book, in fact, but unfortunately I'm poor.

    Thursday, November 22, 2012

    Desperate Gods and rules-forcing in video games.



    Desperate Gods, by Wolfire Games, is a virtual board game made for Fuck This Jam; you have a bunch of virtually simulated tokens and cards, but you must process and execute the game rules yourself. You can easily cheat, but then what's the point?

    DG is not the first game or toolset to do this, although it's certainly the most polished and nicest looking so far. LackeyCCG, for instance, gives you a deck builder, a table, some tools for keeping track of state, then walks away and lets you get to it. The rationale, from their FAQ:
    Q: Does LackeyCCG force people to follow a CCG's rules? Will it allow me to do something that isn't legal?
    A: LackeyCCG does not implement rules forcing. I have tried other methods of playing CCGs online and I have found that forcing rules adherence just serves to bog down the game and makes it much less fun to play. Lackey allows you to simplify your turn when not much interesting is happen (so you can get to the more fun parts of a game faster). LackeyCCG will allow you to do anything you could do if you were playing with real cards. It also allows for a more formal adherence to the rules if you want to play that way, but it doesn't force any particular play style.

    Friday, November 16, 2012

    On why Convo is now a WW2 spy romance, and the myth of psychological realism in fiction.


    Short version: I've chickened out, a bit. Long version?

    To make some sort of procedural "anything", you have to have an idea of what the building blocks of that "anything" are, or at least what you'll argue they are -- and then either frame your game in those terms or expressly simulate those terms. So if Convo is a game about narrative instead of people, then what's a unit of narrative?

    From there, my thinking goes like this...

    Friday, November 9, 2012

    Dear Esther postpartum, by Robert Briscoe.

    Rob Briscoe has put-out a really heart-felt, personal, death-defying postpartum on Dear Esther.

    I think if you ask the vast majority of career game developers out there (or anyone, really) what they're worried about -- it's probably money.

    It's industry developers without any job security or a job, where shipping a title means the publisher will force layoffs to improve their quarterly financials. It's the average indies who glare at their monthly 3 figure check from their meager sales, assuming it's even that much, and wonder what that'll buy after rent.

    Briscoe had to sacrifice a lot and felt poised to fail throughout the entire process, even though everyone was telling him that Dear Esther was going to do well. Given popular depictions of game development, it seems success comes to those who risk everything to the point of emotional breakdown.

    Can we, in good conscience, recommend careers in game development (AAA or indie) to the uninitiated when our passions often lead to the verge of self-destruction? I guess you never hear about the developers with stable lives, happy families, and financial security -- their lives aren't stories -- but isn't it scary to think that passion can easily lead to hell instead of the good life?

    Thursday, November 8, 2012

    Dishonored's narrative design: how The Heart lies to you.


    (UPDATE: this interview at RPS with Arkane devs confirms that not only was I right, but that it was also a very conscious decision on their part to make it do that, wow.)

    Dishonored does a lot of things with game narrative (abstract dream levels, scripted body awareness, lots of readables, overheard conversations, scripted sequences, branching missions changing based on player decisions) which fit neatly into the existing immersive sim / first person toolbox that we're used to. It's well-done, but it's not particularly new or anything.

    The Heart is something slightly different, though, and I found it surprisingly subtle and ironic.

    Level design / character SPOILERS (but no plot SPOILERS) below: