We store cookies, you can get more info from our privacy policy.

Flip's Twisted World Developer Journal

Shader, Where Art Thou?

by Douglas Gregory - September 21, 2010, 6:30 pm EDT

Creating Flip's material effects using NintendoWare.

The way game developers create the visual and material effects in most modern games is by using small programs called shaders. These programs get run for every pixel that's drawn to the screen (as well as millions that aren't), and decide exactly what colour that pixel should be.Because these programs can be basically anything, it’s possible to create very complex effects including physically-correct models of real-world processes, or fantastic phenomena seen nowhere in nature.

The Wii doesn’t support fully-programmable shaders though, at least not directly. It uses something called the TEV (for Texture EnVironment). The TEV is much more restricted in terms of the operations you can do, and the inputs at each stage. In a way, it's like the difference between sculpting clay by hand versus pressing it with molds or stamps. With careful application you can get many of the same effects, but it's not the same freedom you have when working by hand. You have to think very carefully about the tools at your disposal, and sometimes use them in unconventional ways.

Edge Light

One of the first things we added to the materials in Flip's Twisted World was a coloured edgelight. This is a glow that affects just the visible edges of a shape, and helps accentuate curves, as well as aiding in picking-out a character from a background. When writing a DirectX 9+ shader, I might add an edge light like this:

float edgeLight = saturate(1 - dot(normal, view));
colour += lightColour * edgeLight;

This tells the graphics card, "Calculate the angle between the player's view and the surface's normal (the direction that part of the shape is facing), and apply full edge light when they're perpendicular (at the edge), and none when they're parallel (in the middle)"

Doing this with NintendoWare materials is much harder. I didn't have access to the view or normal vectors directly, or even the basic "dot product" operation that's at the heart of so many 3D calculations. At first brush, it looked impossible. The trick turned out to be leveraging the wealth of texture mapping modes the NintendoWare material system provides.

Lost? Check Your Map

Textures are images that are wrapped over the surface of 3D models to give them fine details and colour. Normally they're wrapped using what's called "UV Mapping," which means each part of the texture stays glued to a particular part of the model as it moves.

NintendoWare also let us map the textures using “Environment Mapping,” which means the texture gets mapped according to how it curves relative to the player's view. The middle of the texture gets mapped to the parts that are facing the player, the right edge of the texture gets mapped to surfaces curving away to the right, etc. Starting to sound a little like the edge light, isn't it?

We used a radial gradient texture, environment-mapped, to get the edge light to fall off from white at the edges to black in the middle. (Actually, we only used one-quarter of the gradient, and mirrored it to get the whole circle – that let us save memory for more interesting textures!)

When we add it to the basic diffuse material (light colour times surface texture), we get a passable edge light. What we didn't like about this effect was that it made everything look a bit fuzzy, like velvet, and it washed-out the colours and details at the edges.

To fix that, we decided our edge light should pick up and exaggerate the colour of the incident light. We changed our gradient from 0 -> 255 (black to white) to 64 -> 192 (25 percent to 75 percent grey), then multiplied it by our light colour. Then we took the result and multiplied it by four, and used the new value as our light colour for all our materials. That meant we had the normal amount of light in the middles of our forms, and triple the light at the edges, while still preserving the light's colour. This became the foundation of Flip’s lighting look.


An Indirect Approach

One problem with the environment mapping is that it's applied orthographically, meaning that it only really works on curved surfaces. On flat surfaces like floors and walls, the whole surface lights up as though it were all-edge, quickly becoming overwhelming. We fixed this with what's called an indirect texture, which modifies the mapping of a regular texture. We mapped our indirect texture to the screen's four corners, and used it to gently bias the lookup into our edge light gradient. That way, even when a big flat wall filled the screen, the indirect texture would ensure that the light varies over its surface, rather than being all glare, all the time.

Grokking the Wii

The techniques we used for the coloured edge light sum up what we discovered is the main idea of working with the TEV and NintendoWare materials: you use combinations of textures to do the heavy lifting, rather than fancy math like you'd see in a typical shader. As a final example, here’s how we achieved one of my favourite effects: the lava seen in the Depths world.


The lava material works on just three textures: a "hot" layer representing the fast-flowing, liquid lava, a "cold" layer representing a cooling crust of the solid rock on top, and a random-looking pattern we use to blend between and distort them.

We blend between the cold and hot layers using our random-looking texture, so some patches look hotter than others. We throw in a little of the cold texture's green channel as a bias, so that as the lava heats-up or cools, the rocky crust grows and shrinks at the edges of each chunk, rather than just fading in-and-out. We also blend in a base colour assigned to each body of lava, which affects its overall brightness and makes the rocky chunks glow red at the melting/cooling edge.

We map all three textures at different scales, so even when they repeat, they don't line up exactly the same way. This helps when we have large seas of lava, such as during the Magma Toad battle. As a final touch, we reuse our random pattern as an indirect texture to distort the cool and hot layers, so they warble and undulate in a fluid way.

By varying our base colour and the blending values, as well as the way we animate the three texture layers independently, we can make anything from the cool, stagnant lava in the Forge room to the hot, flowing lava of the Lava River, all with one material. The end result has a surprising amount of visual depth for a three-texture, three-stage material.


A Poor Craftsman Blames His Tools...

Throughout development on Flip's, I wasn't working with the TEV directly, but rather via the NintendoWare material editor I was using to create the effects. This sped up our work a lot because it gave me instant, visual feedback of what my materials would look like, and I didn't have to trouble our programmers to keep compiling new builds of the game every time I wanted to tweak a parameter. However, I have a strong suspicion that the tool doesn't expose quite everything the TEV can do. While I'm very pleased with the range of material effects we could create this way, I'm interested in pushing the Wii even further. On our next Wii project, I may bite the bullet and learn the raw code the Wii uses to describe TEV effects, or beg our programmers to build me a more low-level preview tool.

Images

Talkback

I had only heard the name before reading this, but the game actually sounds fascinating. I appreciate the explanation of accelerometers, because there's a lot of misinformation and general ignorance about how the Wii Remote actually works. But as the designer notes that Wii MotionPlus can actually detect twisting, I hope that accessory will be supported as an option. The blue/orange arrow indicators sound like a great idea, especially since the flip won't take place until you release B. (Maybe a little like throwing in Boom Blox?)

BeautifulShyJuly 27, 2010

Is there a chance that Doug will come on to the forums and talk with us?

That detecting the way you play is a great idea. It was done wonderfully in Helix for Wiiware.
Yes In have been keeping track of this games progress and I do like the concept of it.

I played a demo of the game two E3s ago and really liked the concept, but found myself frustrated and confused by the twist mechanic's controls. I'm glad to see Frozen North spent so much time working on the controls, because Doug isn't kidding when he says there was "trouble".

I also played that demo with TYP and I was initially interested in this game, but then I was so turned off by it. However, they've had more than a year to work on it, and as far as I know, they took the E3 critiques to heart and tried to work them out.

DMGregoryDouglas Gregory, Guest ContributorJuly 29, 2010

Quote from: Maxi

Is there a chance that Doug will come on to the forums and talk with us?

Hello, Maxi!  Doug here.  Sorry for the delay, I was just alerted to your comment by a coworker today.  I'd be happy to answer some questions here.  I hope you won't mind if my replies are a little delayed - we're swamped here at Frozen North working on our next title.

Quote from: NWR_Neal

I also played that demo with TYP and I was initially interested in this game, but then I was so turned off by it. However, they've had more than a year to work on it, and as far as I know, they took the E3 critiques to heart and tried to work them out.

We most certainly have taken those critiques to heart.  Post-E3 we overhauled the game's visuals, including an all-new lighting system, and fixed a lot of inconsistencies in the twisting and combat mechanics.  I'm sorry the early version turned you off; we have to admit it really wasn't ready to show at that time.  I hope you'll give the finished product a try, and have a lot more fun!

Thanks to everyone reading for your interest!

Doug, just on the basis of this first entry in the developer diary, I am very inclined to check it out when it hits, and since I'll be formatting all of the subsequent developer diaries, I expect to get even more excited.

BeautifulShyJuly 29, 2010

Oh wow we don't get many developers here.
Hmm questions...
Was the reason for the delay to work on it more or was it to avoid a certain other platformer from taking away the spotlight of this game?

What type of music will be in the title?

Hmm how much will it cost?

DMGregoryDouglas Gregory, Guest ContributorJuly 29, 2010

Hi Maxi,


You hit the nail on the head: our publisher didn't want to release at a time when we'd get eclipsed by Super Mario Galaxy 2.  The hope is that waiting the summer will give Wii gamers' appetite for 3D platformers a chance to grow again.


The music in the game is all done by the legendary Tommy Tallarico, of Electric Playground and Video Games Live fame. He's easily the most prolific game composer, and what he created for Flip's delivers on his long reputation for musical excellence.  We asked him to evoke some of the memorable feeling of classic platformer games like Mario, Sonic, Donkey Kong Country, with a little of Zelda thrown in. He ran with that, adding his own signature spin, so that should give you an idea.


We don't determine the price for the title, but taking a quick look at a few game retailers' websites, it looks like most are planning to sell it for $29.99. That's not an official statement, so don't quote me on that. ;)

BeautifulShyJuly 29, 2010

What do you think of the resergance of platformers this generation on the Wii?

I mean we have games like Wario Land:Shake it,New Super Mario Bros. Wii, Donkey Kong Country Returns, Epic Mickey, Flips Twisted World and Kirby's Epic Yarn.

Do you think it is good to have this many platformers out?

Quote from: DMGregory

You hit the nail on the head: our publisher didn't want to release at a time when we'd get eclipsed by Super Mario Galaxy 2.

That's a smart move. All too often publishers want to simply push the product out the door. Hopefully that also meant the development team got a few more months to tweak and polish.

Quote:

The music in the game is all done by the legendary Tommy Tallarico, of Electric Playground and Video Games Live fame. He's easily the most prolific game composer, and what he created for Flip's delivers on his long reputation for musical excellence.  We asked him to evoke some of the memorable feeling of classic platformer games like Mario, Sonic, Donkey Kong Country, with a little of Zelda thrown in. He ran with that, adding his own signature spin, so that should give you an idea.

Jonny held a fantastic interview with Tommy shortly before E3 2010 to get the word out about Video Games Live. He shares a lot about the process behind running a show like VGL, also talks about his work on Metroid Prime. Anyone who missed it should really check it out.

DMGregoryDouglas Gregory, Guest ContributorAugust 01, 2010

Quote from: Maxi

What do you think of the resergance of platformers this generation on the Wii?

Platformers are one of my favourite genres, personally, so I think this can only be a good thing. Having more platformer options on the market:
- gives players more choice and more gaming opportunities
- encourages more experimentation and exploration among devs, to distinguish their offering
- (if they sell) demonstrates to publishers the business case for funding more platformer titles


When it works, this feedback loop creates more fun (or profit) for everyone involved. There is the risk of a flood of mediocre titles riding the coat tails of more successful ones, but so far I haven't seen that in the latest platformer surge. In any case, there are enough sources of solid review information available now (like this site) to keep most gamers from being stung by shovelware. So, bring on the platformers, I say. There's still tons of room to explore and innovate in this genre.

Quote from: TheYoungerPlumber

That's a smart move. All too often publishers want to simply push the product out the door. Hopefully that also meant the development team got a few more months to tweak and polish.

Unfortunately, a delay in shipping doesn't necessarily come with more funding to extend development. To keep our studio in the black, we've had to move on from Flip's to new paying work in the meantime. While it would be nice to refine FTW even further, I think you'll like what we've been creating since then.

Hey everyone! There's a new entry in the diary about the character design of Flip.

BeautifulShyAugust 05, 2010

Hmm while most of the designs look nice there wasn't really a hook with them.There was something missing in them.I'm not sure what though.

Killer_Man_JaroTom Malina, Associate Editor (Europe)August 07, 2010

Is there a video I can watch? It sounds like you've come up with a robust system with which to realise the original concept, but I'm struggling to visualise how it all plays out. Camera viewpoint, for example. I assume you'd need quite a lot of control over the camera to examine the level layout ahead of you. But how does the camera track Flip as the gravity changes while making sure you still know where you are and where you will be? That's what I'm trying to wrap my head around.

The third entry, about the game's story and voice acting, is up.

MoronSonOfBoronGarnet Red, Contributing WriterAugust 10, 2010

NEEDS SPOILER TAGS, ARRRGH

ToruresuAugust 13, 2010

I wonder if the name acronym FTW was intentional.

BeautifulShyAugust 13, 2010

I didn't even notice that. Maybe it was.

MGladneyMitch Gladney, Guest ContributorAugust 16, 2010

Hey guys,

The synopsis doesn't give the WHOLE story away, just touched on a few key events.  ;)

As far as Flip's Twisted World matching up with FTW, that was purely coincidental. The name of the game we pitched was actually called up & dn. (Up and Down) The logo worked both right side up and upside down.

Thanks,

Mitch

These guys are good writers. I'm totally fascinated by this game's development.

Killer_Man_JaroTom Malina, Associate Editor (Europe)September 01, 2010

I just read the latest entry pertaining to the http://www.nintendoworldreport.com/devjournal/23954 boss design and really, it is a fascinating prospect, the idea of fighting a boss with the twist mechanic. I can't even conjure any imaginary scenarios, but there's absolutely a lot of potential there.


It has made me more enthusiastic to try out And Yet It Moves on WiiWare, which is probably the closest thing to Flip's Twisted World at this moment. Sure, I respect that a direct comparison might show them to be very different, but it is nevertheless also a platformer that lets the player alter gravity. In fact, it sounds like it has complete freedom in rotation as opposed to 90 degree increments; apparently, the answer to making complete freedom of rotation viable is to ensure none of the terrain or platforms are flat.

Mop it upSeptember 07, 2010

I must've missed this somehow, but I've just read this article. This game is starting to sound like a winner. I like what I saw on the quick list of game mechanics, especially the one about being able to try things without punishment. It leaves more room to experiment and have fun figuring out puzzles. Interesting visualization of the Wii Remote... it sounds like it's a bit complicated to work with. I guess I now know why some companies have such trouble getting it to work right. Their way around the different positions people hold it is rather ingenious. I hope it works like they say.

Quote:

Platformers are one of my favourite genres, personally, so I think this can only be a good thing. Having more platformer options on the market:
- gives players more choice and more gaming opportunities
- encourages more experimentation and exploration among devs, to distinguish their offering
- (if they sell) demonstrates to publishers the business case for funding more platformer titles


When it works, this feedback loop creates more fun (or profit) for everyone involved. There is the risk of a flood of mediocre titles riding the coat tails of more successful ones, but so far I haven't seen that in the latest platformer surge. In any case, there are enough sources of solid review information available now (like this site) to keep most gamers from being stung by shovelware. So, bring on the platformers, I say. There's still tons of room to explore and innovate in this genre.

I've got nothing to add to this, I just wanted to say I pretty much agree with all of it.

BeautifulShySeptember 07, 2010

I'm really liking the design of the bosses. These days most bosses are realistic looking. It is nice to see this type of design.

Formatting and posting these every week has been an absolute pleasure. I will be sad when I don't have an e-mail from Majesco PR in my inbox every Monday or Tuesday.

FlipsterSeptember 07, 2010

"Originally, Butch was in the Glacier World's seas cleaning up a chemical spill from a potion sucked in from Master Fulcrum's lab, but when we decided to go in the direction of collecting Chapter Stones, he became a surly porpoise resolute on drilling the ice, searching for an elusive Chapter Stone."

Could this maybe have had anything to do with being controversial towards oil spills, or no? I guess since your idea of Chapter Stones has been around before the recent oil spill that is unlikely, but it still seems like an interesting coincidence, or maybe it's just me over-thinking it  :P:

I also enjoyed your guys' throwaway story, mostly for two reasons:

1. For me it's always been about the events and characters in a video game, not necessarily the main plot, but how the player progresses through that main plot and what memorable characters and events are experienced along the way.

2. Since Flip is actually in a far-off land inside of a magical book, if a sequel ever arises not only could you show a more consistent or in-depth universe if desired (much like what Banjo-Tooie was to Banjo-Kazooie), but it would also be less constraining for the plot to create a whole other universe with new characters and worlds without it seeming like an inorganic or unnatural progression.

Personally I always tend to love the first of a platforming series the most for having all of the basic themes (Super Mario 64, Jak and Daxter: The Precursor Legacy, Banjo-Kazooie, etc.), but more and more am I starting to appreciate a series' progression into a universe that is more of it's own, although that doesn't mean it NEEDS to be dark like Jak 2 or Banjo-Tooie.  :)

Mop it upSeptember 08, 2010

Part Two? Where is Part One?

EDIT: Silly me! I totally missed the sidebar with all the other entries posted. Looks like I have some more reading to do...

UltimatePartyBearSeptember 15, 2010

This developer diary has been a real treat, and it worked to not only put this game on my radar, but make me very interested in it.  I especially liked the bit about Flip's hit box getting wedged in the level geometry and doing weird things.  I've seen some really hilarious, but also some really frustrating bugs that come from that kind of thing.

I really appreciate the latest entry.  The TEV is a mysterious black box to most, so it's nice to not only see it getting use, but mathematical explanations of how it can be used creatively.  Heck, I haven't even seen NintendoWare mentioned anywhere since 2007.  I hope you guys have a chance to play with the lower-level TEV stuff and give Nintendo and High Voltage Software a run for their money!

ejamerSeptember 27, 2010

Wow, what a great (ongoing) read.  Thanks very much to the Frozen North Production guys for sharing, and for NintendoWorldReport for hosting.


Best of luck with the game.  If it turns out half as good as it looks then it'll be worth owning.  :D

Got a news tip? Send it in!
Advertisement
Advertisement