Custom Building Shader

We recently posted some of the first buildings modeled by artists hired with the KickStarter funds.  They all did great work, but we’ve selected five artists to form our core art team for the rest of the work.

One of the first things we have to do as a team is decide upon the materials the buildings will be made of.  In video game terms, a “material” is a combination of texture images and something called a shader — a little computer program that runs for each and every pixel on screen, determining exactly how the textures are combined with lighting and other data to generate their final appearance.

The standard shaders include a “diffuse” shader that just looks like a flat material, perfect for things like chairs, roads, and brick walls; and also a “reflective” shader that is used for shiny things like disco balls, polished metal, and glass.  Buildings need both, as most of the walls are diffuse, but the windows should be reflective.  But using two different materials means we need use twice as much texture RAM on the video card, and also a lot more drawing calls to render every frame.  For the number of buildings we expect your colonies to have, this was very worrisome.

So, we solved the problem by writing a custom diffuse/reflective shader.  This uses the alpha channel (a fourth color channel after the red, green, and blue channels) to determine which parts of the texture should be diffuse, and which should be reflective.  It even allows the artist to mix some diffuse color in with the reflections, to produce effects like tinted windows or polished metal surfaces.


You can see a test render using this new shader in the image above.  A static image doesn’t really do it justice; as you move around the building, you can see the reflections shifting in the windows, which really makes them look shiny.

Of course the reflections in these windows show the Earth sky.  There won’t be any Earth sky inside a space colony; instead you’ll have a lot more ground and buildings curving up around you, with a bright light source whose position depends on the colony geometry.  So, we’ll have to use a different reflection map for the game.

But, we’re really happy with this shader, and we know you’re going to love the look of your cities in space!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s