January 28, 2014

Temporal multi-resoluton SSAO in Temporality – Ultra mode

by Niklas Hansson

When we started working on Temporality one thing was very clear to us, to make a good looking indiegame on a shoestring budget we needed a good lighting solution that would take our simple models and make them look the best way we can. So we spent a lot of time on our light solution and we felt that a really solid SSAO solution was an important part of this. However with the limited bandwidth of the XBOX360 the traditional SSAO techniques wouldn’t work.  We did some experimentation with low quality approximations like Volumetric Obscurance(crysis 2 used this on console). But we felt we needed something of a higher quality.

Here is an example of what our original implementation could achieve on the left side there is no SSAO and on the right side we added it.

SSAO

The big issue with SSAO is that it samples the depth buffer to determine if a sample lies in front or behind the current depth buffer value. On the 360 4 samples are around the maximum that it can handle decently. This is what Volumetric Obscurance uses. The thing is that with 4 samples you can detect cracks but you really don’t have enough information to detect the longer ranging effects of the AO,  so we knew we needed more samples. The first thing we did was to remember that since the camera doesn’t move around to different parts of the map every frame but are in the same are the same pixels on the screen will be visible during a large number of frames. Sure the pixel might move but it will still be the same place in the world with the same light information.

This idea  is called Temporal Coherence and can be used to save time on any kind of calculations like shadows and so on. You just detect if the pixel has been calculated the frame before and reuse the value. Our solution however is a bit different. We want to use the Temporal Coherence to add new calculations for every frame that we combines with the old ones to create a more accurate view. We basically save values through the last 16 frames which gives us 16*4 = 64 Samples per pixel which is pretty nice since most ultra modes uses only 32.

Due to performance reasons SSAO are normally performed in a lower resolution and then blurred so that you won’t notice the pixels. This is a good optimization if you do it in 1/4 of the resolution you get to do it at 1/4 of the cost. And the SSAO needs a blur anyway due to the low number of samples.  We discovered that with our 64 effective samples we really didn’t need that strong a blur which allowed us to drop resolution one step more to 1/16 of the resolution which made it possibly for us to also add in Screen Space Light bounces too and still keep it running on the 360.

However one problem of SSAO is that it only catches small scale obscurance and can’t really consider the larger forms and distant light obsurance and we felt we needed to fix this too. Our solution is to use multiple resolutions. We resolve SSAO at 1/16 1/64 and 1/256 resolution (which is 1/4  1/16 and 1/64 resolution around either axis) (this was before the paper was published to be honest I still haven’t had time to read it to compare). But due to the low resolution we got a lot of noise. However thankfully Temporal Coherence came to the rescue again. Due to the low resolution we could increase the amount of samples to 16 and 32 which gives us 256 and 512 real samples. Combined with a liberal blur(which we can do since we have high res data from the other passes) this allowed us to capture  even distant effects of obscurance.

Last week we decided to revisit the SSAO due to the game being a PC centric title, what we realized is that while we could gain some wins with increasing sample count the solution we had in place did a good job for what it was meant to do. In fact in the end we just bumped the samples and the resolution. In Ultra mode we now get 256 Effective samples per pixels which gives an ultra smooth SSAO almost without any blur. And after careful bench marking we decided to retain this also for the very High mode but at the old resolution. While doing this we also did some extra parameters tweaking to give the SSAO just a little bit more umph.

Here is a look at the first implementation
OldSSAO copy
And the new Ultra mode version.

newUltra copy

 

 

 

 

 

Share this



Temporal multi-resoluton SSAO in Temporality – Ultra mode Temporal multi-resoluton SSAO in Temporality – Ultra mode Temporal multi-resoluton SSAO in Temporality – Ultra mode Temporal multi-resoluton SSAO in Temporality – Ultra mode
May 18, 2013

Weekly Progress, GUI,Maps etc

by Niklas Hansson

So we have had a lot of things going on during this week some we can talk about and some we can’t. One of the main things we have worked on this week is to actually map the game out all the way to the end which means putting a limit on what gameplay elements we are going to put into the game and how many levels each can manage before being repetitive. While some cool ideas as always had to hit the cutting floor we are pleased with what we have homed in on. It’s nice to finally have a set scope on the project as we can really feel how we are moving towards the finish line.

temporalityscreen07

This project has been a giant labor of love from our side from it’s humble beginnings over 2.5 years ago to now. The funny part is that it was supposed to be a quick 6 months project to test out XNA,XBLIG and digital distribution overall but when all focus testers loved it so much we decided to spend the extra time doing it really well, because if you have something people love you shouldn’t rush it out so we spent a lot of time going over the graphics (compare to this early version and it’s not even the first http://www.youtube.com/watch?v=60ipniNj_qY) ) But also trying out different puzzles and mechanics we have focus tested a ton of puzzles we have even had the game at lans with people not knowing it was in early pre-alpha to measure real worlds peoples attention. All to make certain that the final product will be worth it. And now finally after over 2.5 years we can finally see the goal it’s still a bit away but we can see it.

So it has been time to turn our attention to stuff that really hadn’t mattered so much this far like our front end ui. But as this is the first thing that meets the players eyes it’s important that it feels attractive and simple to use. We have been throwing around a lot of different ideas here but in the end we had to select one that wouldn’t break the current scope of development because as a wise man said “Real artists ships” If we can’t put the game in your hands then all our work is for nothing.

So in the end we went with a simple but visually attractive style. While it doesn’t show here on an image we have everything in the UI animated so it’ not a boring still image it reacts to you fades in and out images, it actually feels really nice compared to our earlier placeholders so we are quite happy with this change. We also finally have a working options screen that will allow you to configure the game according to your needs. We are currently looking at quite simple options as this won’t be a game that requires the newest hardware to run. A simple setting of High,Medium and Low should suffice on the graphics side. As for controls we are currently debating to what extents they needs to be rebind-able.

Also this week Project Temporality is a part of Pixel Prospector new video for greenlight (55 indie games in 5 minutes). About greenlight we will soon be in a situation where we will start pushing for it and update it with a ton of new content we just need a little time as we are working hard with our indiecade deadline.

But as always please go and vote for us at greenlight. And also expects a lot more news from us in the coming weeks, the new screen shots with the latest posts gives a hint of what is to come :)

Share this



Weekly Progress, GUI,Maps etc Weekly Progress, GUI,Maps etc Weekly Progress, GUI,Maps etc Weekly Progress, GUI,Maps etc
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
July 3, 2012

Dream Build Play Tech Postmortem

by Niklas Hansson

At the end of a deadline for any project a certain amount of tiredness always arises, but more than that a feeling of disappointment “What that all we did ?”,”Couldn’t we have done more ?”. The bigger the project the more pronounced these feelings raises.

With Project Temporality we want to prove that XNA can be used to create XBLA style lush 3D environments. We hope that the steps along that path that we have trodden will inspire others, and help show the potential of XNA and managed development, you really can do whatever you put your mind to. And we hope that you do agree we reached at least a part of the way to our goal, we have a long way to go still but now it seems possible.

So we want to talk a bit about the techniques we used in PT. To make our visuals distinct and not just standard “sci-fi pretty” we had to make a lot of technical base decisions to reach our goals. One goal of our rendering technology was to try to avoid as much as possible the hardness/harshness that much real-time graphics have in their lighting and edges. This was really important to us as we wanted to have a vibrant but soft look in the game.

One of our base techniques is exponential shadow mapping, thats the reason why our shadows look soft and smooth and neither really sharp or worse pixelated as we are used to in most games. We will upload an example of the XNA shadow mapping sample ported to using exponential shadow maps later on just got to write up some extra explaining text. Exponential shadow mapping (ESM) just like variance shadow mapping builds on the idea that if we could blur the shadow map texture instead of performing blurring in the per pixel look up like in Percentage Closer Filtering(PCF) we can perform a much greater blur effect and those create smoother transitions than we could afford else. It also has a really nice property as long as you don’t update the shadow buffer you won’t need to re-perform the blurring which makes the soft shadows almost free on non updated shadow maps. Also the blurring can be done as a separable blur filter which means it’s well adapted to the strengths of the XBOX360 platform with it’s low ALU performance.

These images are booth from the XNA shadow mapping sample using a 2048×2048 resolution texture, now the sample in itself could benefit from numerous improvements but it still works out well for this comparison as they both suffer from those problems. The one difference I have added is that I allow the ESM shadow to go to black instead of just multiplying with 0.5. On the old solutions the shadow looks low-res and jagged but with ESM it looks smooth, it can be made look even better with some tweaking but this was enough for a sample. For our goal of having a soft smooth world without jaggies using ESM was a no brainer especially since it doesn’t double shadow texture usage like Variance Shadow Mapping does.

Another technique that is a big part of our look is our temporally reprojected multi-resolution screen-space ambient occlusion(SSAO) and bounced light solution. SSAO is really cool and helps a lot with visuals however it is not without it’s share of problems one being that it only picks out creeks and small scale occlusions. This mean that if there is occlusion on a larger scale the algorithm has problems handling it. This is due to the fact that you need a huge amount if samples to to get good coverage.

We solved this by performing SSAO at three different resolutions, we down-sample parts our Gbuffer to these resolutions. This allows us to use much more far reaching SSAO without running into a samples limitation. Because we get a much better cache-coherency on the GPU due to the samples still being close to each other on the texture map. We also get to scale away small ridges etc that doesn’t matter to our large scale occlusion. Then we combine the data from the 3 different resolutions to create our final ambient occlusion term.

However even with this technique it would cost to much to run it on the Xbox360 with a good sample quality, so we also use a temporal re-projection technique that tries to match a pixel on the screen with a pixel on the screen of the last frame and reuse SSAO data from that frame if possible. This allows us to use a huge amount of samples because we can amortize the cost over multiple frames. The way this work is that we save data from the last frame then for each pixel on the screen calculate a world space position. Then reproject it using last frames view and projection matrix to find a pixel on last frame screen. We then verify that it’s the same pixel by comparing the position of them(done using depth due to cost issues) and then select if we are going to use that value or not. In fact what we do is that we use the old value and a new one and rotate the samples every frame this means that even if we had only 4 samples per frame we can get 32 or even 64 sample quality and if we up our sample count we can increase the quality even more.

We hope you agree that the effect of the technique is very visible on the right part as the left one looks very flat, and I also believe you will feel the softness and the range of it as quite different compared to normal SSAO techniques. We definitely feels that this was worth the amount of time we had to spend on tweaking it and working hard to make it possible to get it running on a 360, we should mention that our technique uses both normals and depth for every pixel and could be seen as a simplified model of the Bunnel disc algorithm, it is based upon Practical SSAO but with a lot of tweaks and fixes. And of course multi resolution makes a huge difference.

Another important part of the technique is our per pixel re-lightning scheme. To show this one off i have opted to use the classical crytek spoonza as this is an extra per pixel technique the results obviously won’t be as impressive as with for example cryteks LPV technique but this is just a part of what gives PT that special look and feel. This could be done with just a small change to our SSAO code, but actually making it fit into the pipeline and work properly so it didn’t just made corners brighter was a lot of work.A naive implementation of this is actually worse than no implementation. After we have applied direct light and emissive light we do our ssao pass and while we do calculate ssao for our pixels we also calculate for each pixel how much if the other pixels light would be reflected upon this (under the assumption that the pixels are fixed area discs in 3d space)

The part of this that we are the most happy about isn’t actually the bounced red light from the draperies even though it breaks up that large shadow nicely, but we have other systems to handle that kind of bouncing in PT. It’s the small subtle details how bounced light makes the bottom of the pillars brighter than the top. Small details like the wall above the arches are brighter because light had bounced on them. You can also again see the effect of our large scale ssao on the pillars to the right side. This image is actually from quite early code but due to all the different systems working together in PT we thought using this instead better demonstrated the effect.

The final part of what gives PT it’s look is our global bounced light solution including localized and blurry reflections. Our basic engine is a fully deferred render capable of handling hundreds shadow casting lights in a level (though we learned that artistically that it’s better with a lower number) Projected texture and so on, all feed into a physically based shading model (that will be the topic of a separate post) but we aren’t using that as our primary source of light most light of what you see is bounced light either bounce specular light or bounced diffuse light.

We do this using a Box projected system of environment mapping where the map is projected upon a box shape representing the environment. For each pixel we calculate a reflection vector using that position and the eye vector. But instead of using this for our cube-map lookup we instead fine the intersection point of the box from that position using it’s vector and use that position on the box as our reflection vector. This allows us to get accurate reflection of objects that look natural like the picture below.

For blurry reflection we use a form of mip-map convolution, we basically use a similar method to ATI cube-map gen with angular extents but we use a phong lobe for the weighting of the samples when we down-sample to get a reflection that matches properly to the specular size in the game. And then when doing the texture lookup in the code we use the micro-facet distribution (roughness of the surface, similar to the old gloss term in non physically based shading models) of the pixel to select which mip-map we use. This is imperfect due to the fact that our look up is antitropic so we do some fudging and interpolation at the lower mip-maps to hide the error.


If you watch the image above you should be able to see a radical difference in the clarity of the reflection this is due to different glossiness values on the surface.

Except for this we also used a similar method for bouncing light in the scene, it is a limited method because occlusion can only happen at box boundaries but it still worked out well for us, we use the position and the normal of the object to find out where it intersects the box and then weights that vs a vector that goes from the center of the box to the object to get a final lookup position and use that value as it’s local ambient value for that pixel. To get a nice smooth light distribution we perform 5 light bounces all in a linear HDR space. Which is basically just rebuild the cube-maps but using the old cube-maps as input to the world we could do more bounces but after 5 it’s not possible to see a difference anymore. If there is an interest in this we could probably do an article for this too but it’s a bit more complex than the shadow mapping.

In the images above the left images represents the result of the direct lightning and the rest of the light comes from our bounced light representation, we are quite happy with the results which works well even in large rooms.

We hope you have enjoyed this view of what makes Project Temporality tick visually, there is of course a ton of more stuff but this is the most important systems that we also think the least amount of people are using at the moment. We wish we could have gone into more detail on some parts but then this entry would never have been finished at all.

Share this



Dream Build Play Tech Postmortem Dream Build Play Tech Postmortem Dream Build Play Tech Postmortem Dream Build Play Tech Postmortem