E-Book Givaway!

While developing and play testing Chess 2 over the past year I've been slowly amassing a list of strategies, tips, and proverbs which has evolved into a full e-book with more than 50 tips to help you improve your game and get ahead of the curve for release. Remember, you can play and practice now with a normal chess set if you download the rules

There's also some artwork in there that has not yet been revealed anywhere else.

For a limited time, we're giving it away for free. To claim your prize:

  1. Re-tweet the following message "RT #chess2 #givaway &follow @LudemeGames before Jul31 to get a strategy e-book with more than 50 tips for free!"
  2. Follow @LudemeGames so I can send you a direct message with the link.

The e-book comes with all future updates for free, but this offer will only be available until July 31st. 

Press demo & Media Kit

Members of the press can now fin a copy of our game here:  Chess 2: The Sequel: The Demo. Please check it out and contact me if you're interested in doing an interview or coverage for the game. Here's the media kit.

If you like Chess 2 and know a member of the press point them in the direction of this post! A larger community of players means a better game and better multiplayer.

Lighting the Pieces in Chess 2: Part Three (Shadows)

Features

The shadows in Chess 2 conform to the shape of the shadow caster, fade and become soft with distance. They also come from multiple light sources which adds to the ambient occlusion effect and makes the shadows colored slightly blue, to account for light scattering in the sky. Theoretically, they could even support refraction induced caustics - would the pieces be transparent.

Obviously, this is not possible in realtime on the OUYA. And, if you've read my previous post you won't be surprised to know that they are baked onto planes.

Constraints inform the method

The shadows in Chess 2 take advantage of from some constraints due to the type of game it is.

  • Chess pieces do not deform
  • Chess pieces do not rotate
  • Chess pieces move on the surface of a plane
  • Environment shadows are kept off the surface of the board

Because of these, it is possible to bake the shadows into planes on the ground, as long as some limitations are placed on the art, which will be discussed later.

Tech

The math for a diffuse shader in a forward rendering pipeline basically looks like this: a*albedo + b*albedo + ... n*albedo, where albedo is the color of the surface and a and b are light color * dot product of surface normal and light direction. We can factor this though to c*(a+b+..n). Since (a+b+...n) is precomputed when we bake we can just call it L.  So we simply have L*albedo. The important thing here is to see that the light can be simplified to a simple term L, and we can modify that term in the equation to change the light from it's current value to any other value we like by multiplying the final color, if only we know what to multiply by.

A multiplication texture is pretty simple to create. When baking the light, capture a lightmap to two planes. One will have a piece on it which is the light with shadow, and the other does not which creates a 'control' texture that informs us how much light is received where there is no shadow. With a program the shadow texture can be divided by the no shadow texture to get a texture of the term that the lighting of the board would have to be multiplied by to get the lighting of the board when affected by shadow.

All that is left is to somehow do the multiplication. One way would be to create a material using Unity's particle/multiply shader and apply the texture there. This shader has some bloat though, and we'll make a better one in the next section on performance.

This method for shadows makes shadows which are mathematically perfect in the context of this lighting model, support advanced lighting techniques like caustics and hdri lighting, and have low performance impact. Unfortunately it's only usable in a very small percentage of scenarios.

Art limitations

Because these shadows don't render on the pieces, but only on the flat board, the light direction of the sun was carefully chosen to center the shadows in-between squares, where they would avoid intersecting with pieces or other shadows.

Additionally, the board squares are rendered without a specular component.  When a specular component is involved, the light cannot be factored to a single term and the equation involves both addition and multiplication, so there is no value to multiply the final color by that will always have a correct result from all camera directions.

The scene is an outdoor scene to allow us to treat light sources as coming from infinitely far away.  Indoor lighting would not be possible because lights too close to the board affect the shadow direction

For the shadows to be perfect, the board should be a completely flat plane. In practice I think the added art benefit of having the individually cut squares outweighs the imperfection of the shadows.

Lighting the pieces in Chess 2: Part Two (Advanced Lightmapping)

There are three main ingredients used to cook up the lightmapping on the pieces.

  • Smart IBL
  • High-res Geometry
  • Directional Lightmaps

    To see the detailed effect that each of these had on my lighting, click on the images for an up-close view.

    Smart IBL

    Smart IBL (or sIBL) from HDRLabs is an open standard for one-click lighting solutions captured from real environments. The net effect is much more interesting color and fill in the lighting then I could get by placing lights in the scene. Even better than the quality of the results is the speed of iteration. Various sIBL sets can be quickly swapped in/out at the click of a button to view the effects of different lighting conditions on the scene without the need for a professional lighting artist.

    Because my needs were limited to a small subset of the sIBL features, I have not yet written an importer for Unity. If there is sufficient demand in the comments I'll consider making one. For now, the easiest way to setup a light-emitting environment according to the sIBL spec is using this free plugin from the Unity Asset Store: Lightmapping Extended.

    sIBL sets in the archive usually include blurred hdr files for light emission, sharp reflection maps, information like sun direction and color, and even seemingly esoteric things like how far off the ground the light probe was when capturing the maps. Clearly some thought has gone into this that's beyond what I would have considered attempting to light without it. They are of the highest quality. Careful though, not all of the sets in the archive are free for commercial use.

    High-Res Geometry

     

    One technical note. In Unity meshes that are larger than 65k vertices are split up into multiple meshes. If you simply bake before laying out the atlas to a shared space for all the mesh pieces there will be seams. 

     

    Directional Lightmaps

    There's not much to say here, except that Unity supports a directional lightmapping mode which stores a map that encodes the direction of the most significant light source in addition to the normal light color. 

    If your shader has a specular component, this is critical.  Hopefully Unity will get around to documenting this feature someday... so I won't here. Just, if you want specular or other light direction dependent effects turn it on.

    In the next part, we'll discuss capturing the shadows

    Lighting the pieces in Chess 2: Part One

    There is a paradox among chess players. Most serious chess players use two dimensional pieces when playing on a computer, yet they play with figurines in person. There can only be two explanations for this. Either the look of the pieces is not convincing, or it's the lack of depth perception. (Chess 2 adds depth perception by supporting stereoscopic 3D, but that's a subject for another post.)

    There are two basic contributions to the look of something in the game. First, is the silhouette, and second the lighting. Just how important is lighting? Take a look at this image.

     

    From early on I believed that great lighting would be one of the most important places to invest time and energy on in Chess 2. The result? Chess 2 is the only chess program where I prefer to play with figurines. 

    To divulge how we achieved this look on the OUYA, we'll be splitting this post into three parts: 

    I'll be using Unity throughout, but the concepts should still apply. 

    Up Next:

     Advanced Lightmapping