Discussions about the new game shaders (image-heavy)

I already uploaded this screenshot in the “What’s new in this build?” thread, but I wanted to show it again. I’m fond of it. It’s a picture taken from inside my standard test game; I launch into this thing probably forty or fifty times a day, most days. Often for only a few seconds each time, as I test specific things.

What you’re seeing in the backgrounds of this image are what I’m calling “the mushroom mountains”, and full disclosure: they’re a bug. They appeared while I was showing an artist how the “Region Info” window could change the terrain types available in a region.

Originally, over in that corner of the region there was a big forest. So I showed the artist how I could change that forest into a giant mushroom grove, just by changing a setting on the region. And then I turned it into a mountain range. But… as it turns out, there was a bug; when switching from a terrain type with automatic scenery to one without automatic scenery, it didn’t remove the previous terrain’s scenery items. So while the trees from the forest were all cleaned up when it turned into a mushroom grove, the mushrooms from the mushroom grove remained embedded there inside the new mountain range. And by chance, they got autosaved into the file before I closed it. That bug was fixed a long time ago, and I could fix it trivially, just by changing the terrain type again… but I’ve grown fond of them, and so they’re still there, just for me. :smiley:

As a side-note, I don’t actually ever play in this saved game; just jump in and out to quickly test things. And often I forget that I’ve left it open, as I write code. As a result, it seems to fluctuate between about 20 and about 70 subscribers, most of whom are deeply unhappy with the MMORPG I’ve created.

Anyhow, let’s talk about the game’s shaders.

For the sake of being able to see what’s going on, I’ve put primary-colored spheres above each building. Here are the old shaders:

This is what I call “wraparound lighting”; it’s a technique I learned while I was working at Iron Monkey Studios (now FireMonkeys); it’s basically a cheap fakery of global illumination. Instead of normal Lambert shading, you say that the amount of light falling on a surface is equal to (1.0 + dot(normal,light)) * 0.5. Basically, you get zero lighting at the far edge of the object from the light, full light at the front, and wrap around the sides.

It’s worth noting that this is “diffuse” lighting. It’s a simulation of light that hits an object, some of it gets absorbed, and the rest bounces into the camera. The key thing is that the light has interacted with the object such that some of the light’s wavelengths get absorbed, so we see the object’s color. All of the next few screenshots are simulating only diffuse lighting.

Traditional Lambert diffuse lighting looks more like this:

Here, you can see that you get full light at the front, and it falls off to zero light at the sides. The whole back half of the object receives no light. This is the traditional lighting model for diffuse lighting that games have used for decades.

Finally, here’s the diffuse shader used by Disney, in their recent feature films:

Disney’s shader looks a lot like the Lambert shader, except that they’ve made the area illumated by the light adjustable, based upon an artist-adjustable value called “roughness”; rougher surfaces make the light spread out more. You’ll also note that the light fades out around the edges of the object, as more of the light gets reflected away from the camera, instead of toward it, even along the upper edges of the spheres, which technically are facing the light. They are being hit by the light there, but less of the light is bouncing toward us, so it appears less bright!

Note that Disney’s diffuse shader isn’t physically correct; it tends to make objects brighter than they really would really be in the real world (They did that intentionally, to help maintain color saturation). The version I’m using here was adjusted by Electronic Arts, to bring it back into agreement with real-world lighting.

Now, you might have noticed that I’ve disabled shadows on those spheres in the above shots. They made it difficult to see the ‘wraparound lighting’; I’ll turn that back on now. And what’s more, let’s start talking about specular lighting.

Specular lighting is basically a reflection of a light source which doesn’t interact with the object such that some of its wavelengths get absorbed. So for example, while that bottom center sphere is red, it has a white specular highlight because there’s a white light shining on it which reflects off of the sphere and hits the camera, in that specific spot, without having interacted with the object’s surface. It appears white because the light is white; the light has bounced off the object without picking up its color. The surface roughness determines whether we get a wide, blurry spot (as seen below), or whether we get a tiny, sharp, pinprick.

Above, we’re back to Lambert diffuse lighting again, and I’ve turned on Blinn specular lighting. Blinn is again the system that you’d typically have for simulating specular lighting in games from the late 90s, if they had this at all. It’s okay, but it’s nothing fancy. Basically, we figure out the angle at which light bouncing off an object’s surface would be reflected toward the camera, and then as the object’s surface approaches that angle, we brighten up that part of the object.

On the other hand, here’s a more modern simulation of specular lighting, Cook-Torrence:

(We’re also back to the Disney diffuse lighting model, here). Things to notice; Cook-Torrence has a much smarter model for when light is going to bounce back at the camera; even with big specular highlights like these, they’re not blurry the way that Blinn highlights are. What’s more, we’re adding a touch of rim lighting around the edges of the spheres, which can give things a gentle, glassy sheen. (Which is appropriate for large spheres, but maybe less so for buildings)

So the game is now using the Disney diffuse model, and the Cook-Torrence specular model. Depending upon roughness and specular levels set by the game, buildings could look like they’re made of glass:

Or like an almost-matte plastic:

(I’m actually using these latter settings, in the current build)

It’s been kind of a long process, learning about the different modern lighting models; the last time I did this stuff was back in the days when everyone just used Lambert, and maybe Blinn. Now there are so many more options, and there’s all sorts of new jargon to learn (BRDFs). But I think it’s made a big difference to the appearance of the game. And knowing me, I’m sure I’ll be tweaking these shaders right up until release. But… here’s what we have right now!


Before reading i need to say:
there will be only the trees that we could see into today?
theres no tree customization?
explain to me aboitu tree customization

After reading i wanna say only 2 things:
and make a post about the buildings because u didn’t maked it


In this screenshot they are beautiful, for me that can be the final shaders of the game, :smiley:

1 Like

I’m still focusing on the core game systems, rather than on building up content; I want to be sure the game fully hangs together before I really start paying artists to produce lots of artwork full-time!

Right now there are just two types of terrain-type-based scenery objects; the trees you’ve seen, and the giant mushrooms you see here (I don’t think any trees are actually visible in the screenshots in this post?). There are five different models for the giant mushroom, just to prove that the game can have a variety of models within a single “type”, and randomly select amongst them when automatically placing that type of scenery object.

My main artist told me a few days back that he’s already built about a dozen other types of tree. I haven’t actually seen them yet; I think he wants to surprise me with them.

Right now, to get new scenery items into the game I have the artist send me the models, and I’m the one who integrates them into the game. He wants me to extend the game’s data pipeline so that he can easily add them himself, without having to go through me (which is an entirely reasonable request!).

So I suspect he wants to surprise me with the new trees; he wants to add them to the game himself, and have the first time I see them be in-game screenshots taken by him. Which seems reasonable; he wants to be able to adjust them to look as good as possible with the game’s shaders, before I give him feedback on them.

1 Like


and then is confirmed,
theres really no tree customization XDD
its like…already pre made trees?

Just FYI, I don’t respond to “Barney and dortos with some mlg”.

If you want to argue for how a particular feature you’ve invented would improve the game, do it in one of the myriad “Ideas” threads you’ve been creating. Explain how such an idea would work, why it would make a difference to the game, and why it’s more important than other features. While doing this, please bear in mind that every new feature takes time to implement and makes the game be released later.

1 Like

Sorry :frowning:
By the Way what FYI

" For your information "

1 Like