November 2, 2012

Deferred Decals in Project Temporlity

by Niklas Hansson

One of the big issues with being a smaller independent studio and making a 3d game is the staggering amount of content that is necessary to make a good looking game. Not only does every single piece of content need to be of a very high quality but you will also need a ton of it and often you need a lot of small variations to break up the look of the world and not let the user get bored at watching exactly the same models again and again.

Here at Defrost we built our tech targeting the issue from the very first day, it’s one of the reasons we decided to build our own. We wanted an engine that allowed artists to create good looking models in as little time as possible, so that we can maximize their efforts. A lot of different decisions stemmed from this like implementing a bounced light solution to allow easy lighting of rooms and also to break up the looks visually with all the extra detail, a multi resolution SSAO implementation, adapting a physically based lighting model and more. We will hopefully have time to cover all of these later on but today we are going to talk about a recent addition that we feel can make a world of difference to the overall look of the game.

Decals, they are well known technique you can use them to create bullets holes, put up posters etc and generally add a bit of clutter. For us in Project Temporality we where looking for a way to create unique visual details in different rooms without putting the artist through the hell of actually making all that unique details. So we turned to decals, we was inspired by the videos of how artists easily stamped out unique looking environments for rage and wondered if we could do something like that. Combining that idea with the memory of the normal mapped craters we created in World In Conflict at Massive we decided to try making a detail system that overrides any data in the base model so that we can completely change the material and look and feeling and that was easy to apply to any surface.

Normal decals where you take a polygon and cut it up to match the underlaying geometry didn’t work out for us because we have a lot of details in the models instead of in the normal map so we looked to deferred decals instead. Basically it’s a deferred rendering technique where you render a box and for any position inside that box finds the position in a decal space decided by the box and make a look up into a texture map, instead of going for the volume decal style like Humus we decided that 2D decals would be good enough, after all if it works for cryengine it works for us. After that it was easy to get the basic code up and running. XNA limitations with depth buffer and the fact that the xbox loses the data in rendertargets when they aren’t bound was kinda hurtful. In the end we got it to work with a decent solution but if XNA just would allow us to bind and unbind rendertargets individually for all the different slots this wouldn’t even have been a problem. While XNA theretically can do the right thign on their side with it’s declarative API it was never optimized to the level that it did it :/ But then again implementing RGBM fr HDR in 3.1 had it’s problems too.

Obviously all in here is coder art and not meant to be real content we are just playing around with the technique. One of it’s nice properties that does not show up in these screens are it’ ability to wrap around corners and bent shapes quite well. In the image here below you can clearly see the white box which is the primitive we render to project the decal. Thanks to XNA removing the border sample mode in 4.0 our artists needs to make certain that the border of the texture has a black alpha value :/

When working on decals we thought that it would have been a nice idea to be able to add waters puddles, oil slips etc into the game too with decals, however fluids works quite differently physically compared to solid objects and since this is a deferred rendered we cant just add transparent objects at the end due to lighting issues. In the end we opted to render the fluids into the gbuffer too so we could resolve lighting on them properly. We do this by blending the material of the fluid with the material below it and the blending factor is based on how much light will reflect from the fluid at the current viewing angle compared to it this allows us to model physically very different fluids quite effectively. It is still a hack thought, but thanks to us resolving environmental lighting in the Gbuffer pass we can get quite close to a realistic result this shows well on this coder made water puddle in that when viewed form above the water is mostly transparent but then viewed from a low angle you can see a clear reflection. For the player this means they show clear reflections at a distance but he can see through them when he comes closer just like with real water.

This was the first of our weekly updates (we might try to get even more in though) so every Friday from now on will be update day and we will try to bring you more information about Project Temporality and what we are working on. If you want more frequent news subscribe to us on facebook and twitter.

Share this

Deferred Decals in Project Temporlity Deferred Decals in Project Temporlity Deferred Decals in Project Temporlity Deferred Decals in Project Temporlity

Comments are closed.