• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
  • entries
  • comments
  • views

Back on track

Sign in to follow this  
Followers 0


I finished refactoring with components, added a reflection-enabled editor and XML serialization, finally got real PCF shadow filtering, and started experimenting with a somewhat cel-shaded visual style. I've been busy.

The refactoring had a lot of positive side effects. Serialization is now relatively easy, as the state of each component is determined by its properties, which are usually simple, easily serializable value types. One interesting side effect of serialization is that object creation is now split into two parts: initialization, and binding. When creating a new object at runtime, a factory performs the initialization. When loading objects from XML, the XmlSerializer performs initialization. In both cases, the factory creates the necessary bindings between properties afterward.

So far this works great on PC, but apparently XmlSerializer performance is significantly slower on Xbox. I'll report back as to whether this becomes an issue.

The new editor interface also uses reflection, making it extremely flexible at the cost of performance. Hopefully this won't be an issue either. Here's a screenshot.

When no entity is selected, it allows you to edit the properties of the editor itself. That way, I can make a property on the editor for the entity type to spawn, or the editor brush size, or any number of other useful editor thingies. Of course, this also means you can edit the scale and color of the editor model itself. It's quite amusing.

I managed to reduce the controls down to two buttons plus movement, and I think I can add one more button without making it too complex. For Xbox, I'm thinking those will be the A button and the left and right triggers. On PC I'm thinking spacebar, Z, and X, with the arrow keys controlling movement. I'm still trying to nail down a few more moves and their control bindings. They'll probably change during play testing.

At any rate, as you can tell, the graphics have taken a step toward cartoon-land. For me, that means simpler textures and running all the lighting calculations through the following filter:

float lightingFilter(float x)
float y;
float epsilon = 0.05f;
float a = 0.33333333f;
float b = 0.66666666f;
float c = 1.0f;
if(x < a - epsilon)
y = 0.0f;
else if(x < a)
y = (x - (a - epsilon)) * (a / epsilon);
else if(x < b - epsilon)
y = a;
else if(x < B)
y = a + (x - (b - epsilon)) * ((b - a) / epsilon);
else if(x < c - epsilon)
y = b;
y = b + (x - (c - epsilon)) * ((c - B) / epsilon);
return y;

There are three pivot points (a, b, and c) that split the brightness spectrum into sections. Basically it makes the brightness ramp look like a step function instead of linear. At first I tried a straight up step function, but the transitions were a little too harsh, so I added small linear transitions between the levels. When the lighting value is within a certain epsilon value of one of the three pivot points, the output scales smoothly between the light levels. I'm sure you could do this with a polynomial and avoid all the branching, but I didn't want to think that hard. wink.gif

I also finally implemented PCF filtering. Code for this is all over the internet, but I'll post my solution here just in case. It's nice and modular for easy plagiarism, at any rate.

float GetShadowValue(float4 position, sampler2D shadowMap, float2 shadowMapSize)
// Get the shadow map depth value for this pixel
float depth = 1.0f - (position.z / position.w);

// Convert from clip space to UV coordinate space
float2 ShadowTexClipPosition = 0.5 * position.xy / position.w + float2(0.5f, 0.5f);
ShadowTexClipPosition.y = 1.0f - ShadowTexClipPosition.y;

// Depth bias to prevent artifacts
float bias = 0.0005f;

// UV coordinates of the uppermost, leftmost pixel
float2 pos = floor(ShadowTexClipPosition * shadowMapSize) / shadowMapSize;

// Collect samples from the surrounding four shadow map pixels
// These will all evaluate to 1.0 or 0.0
float bl = tex2D(shadowMap, pos).r - bias < depth; // Bottom left sample
float br = tex2D(shadowMap, pos + float2(1 / shadowMapSize.x, 0)).r - bias < depth; // Bottom right sample
float tl = tex2D(shadowMap, pos + float2(0, 1 / shadowMapSize.y)).r - bias < depth; // Top left sample
float tr = tex2D(shadowMap, pos + (1 / shadowMapSize)).r - bias < depth; // Top right sample

// Blend between the four samples
float horizontalBlend = (ShadowTexClipPosition.x - pos.x) * shadowMapSize.x;
float verticalBlend = (ShadowTexClipPosition.y - pos.y) * shadowMapSize.y;
float bottom = (bl * (1.0f - horizontalBlend)) + (br * horizontalBlend);
float top = (tl * (1.0f - horizontalBlend)) + (tr * horizontalBlend);
return ((bottom * (1.0f - verticalBlend)) + (top * verticalBlend)) * 10.0f;

And here's the result:
Notice the awkward light level transitions on that point light. Difficult cel-shading is difficult.

Mirrored on my blog

Sign in to follow this  
Followers 0


There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now