• entries
    338
  • comments
    2046
  • views
    1150695

Imposter rendering & Post-Processing optimization

Sign in to follow this  
dgreen02

1334 views

So I took out the two "most fun" items on my to-do list in the same week [grin]. Optimizing the post-processing pipeline of the game engine, and completing the imposter rendering system.

Well I'm actually not quite done with the imposter system...I have to extend it to work for actors & vehicles, should be done tommorow.

POST PROCESSING OPTIMIZATIONS
Previously I was rendering the bloom / motion blur / depth of field in seperate passes and it was totally fill-rate limited because I was doing the effects @ screen resolution [well the motion blur at least]. I was unable to get more than ~80 FPS on my computer [DualCore 2.4 Ghz, 2 GB RAM, Geforce 8800] @ 1024x768...

Now I combined them all into a single pass & shader...which just operates on a single A8R8G8B8 512x512 texture and then blurs it into a 256x256 texture which is then used for all post processing effects. I write the x velocity of each pixel into the r, the y velocity into the g channel. I also write the depth of field value into the b channel, and I'm using the alpha channel to modulate the heat-blur effect.

Here is a screenshot of the motion blur with a left -> right camera movement...


Early Depth of field screenshot...


Another one...I've move the far plane even farther back since this screenshot...I think it adds a mysterious atmosphere to the game ;-)


Actually these screenshots are wrong because the sky was being cleared to "full motion blur in all directions" so it's double blurry...




Bloom...




IMPOSTER RENDERING

Yea so the theory behind an imposter system is that instead of rendering a mesh you render a dynamic 2d sprite of the distant mesh instead. The cached sprites are generated in real-time by rendering to a texture.

This is going to be applied to all meshes in-game...actors, vehicles, objects. That was the big-time bottleneck before this.

Reference image showing a field-o-objects...~1000 of them to be exact. Notice the 14 FPS in the bottom left of the screenshot. Not good.


Now using an imposter system....117 FPS.

That is actually totally limited by the shadow maps I'm using a 2k^2 texture and a 1k^2 texture at the highest settings. It scales down to use 2 1k^2 shadow maps, and the frame-rate goes up.

Also it should be noted that actually rendering a city will take the frame-rate down by about 30%. The cities just sit in static VBs 90% of the time, and render quite fast.

Another screenshot with shadows turned off...205FPS. The tree mesh is ~550 triangles. There are ~1000 of them.


Debug output of the imposter textures...


Older/incorrect screens...~1000 trees, 500 tris each.





I'm getting this to work with the actors...it's just about done. Totally limited by the shadow map rendering...if I render no imposters / meshes I still get 150FPS with the 2k^2 shadow maps regardless of screen resolution.


These things can pan-out very differently on different hardware, so I've got some testing to do...but it's obviously going to be a major tool in keeping the frame-rate playable on lower end computers.

Also for those of you who want to be in the beta [grin] here is how my to-do list is looking...

-Get 3rd and hopefully final iteration of traffic AI working.
-Finish orders/gameplay aspects.
-Client side prediction on vehicles + actors to make network play seamless.
-Finish basement/illegal business artwork.
[DONE]-Imposter Rendering System
-City Editor / City format 2.0
[DONE]-Optimize Post processing / light weight bloom

I dunno...a month+ probably but we'll see how things go...

Thank god I'll be able to use this tech for any other games I come up with. I think I could use all this as a base and crank out pretty much anything in a matter of 1.5 years...verses the 3 years it has taken me to learn / code all this stuff.

- Danny
Sign in to follow this  


9 Comments


Recommended Comments

Looking good - your stuff continues to be an inspiration to small fish like me. In terms of the rendering to 2D sprites - do you have an article link that describes the process? I'd be interested in learning more

Share this comment


Link to comment
Ah yes...there is a really good article on imposters here...

http://www.gamasutra.com/features/20060105/davis_01.shtml

I should have mentioned that in my original post...everything you need is right there in that article [grin].

- Danny

Share this comment


Link to comment
Bleh, DoF... I'm not a fan of that in any game actually.

How are you handling what to blur and what not to blur? Are you blurring anything on the edges of the screen or are you blurring whatever is outside some radius of the cursor?

Anyways, I'm glad you're optimizing that stuff :) Hopefully it will run better on my machine when I get to play it haha.

Share this comment


Link to comment
Yea I spent a day or two playing with different configurations / blur formulas...I ended up just bluring @ a certain distance...anything more complex than that [ie, true DOF] is pretty distracting IMO.

None of the screenshots actually show the final effect, I'll have some in the next update. Yea, hopefully it'll run pretty fast on any computer.

Actually it's not doing the blurring inside the pixel shader, it's a seperate "blur texture" that is passed in, it is lerped based on the DOF factor in the blue channnel of the "blurred information texture". This way I only have to do ~10 texture samples per pixel @ screen resolution total for bloom/blur/DOF together...something like that. I also use the same blurred texture for the bloom w/some additional modifications.

Share this comment


Link to comment
Well I like that for once the bloom effect doesn't look like a nuclear bomb going off like with most projects. I have to say though that there is way to much fog/blur, like in the DoF shots, on a clear day it should be possible to see some detail on those buildings.

Share this comment


Link to comment
Yea you're right...the problem is that the view distance is set to 60% by default and the fog is setup for that view distance. When the view dist is increased to 100% the fog doesn't scale acordingly ;-/ I gotta fix that...should make things look better.

It's so hard to find a good balance between all the effects...though I think it has potential to give a nice/different look to the game.

Share this comment


Link to comment
Bah, I only like DoF if it happens in a cutscene or a special action scene.

If I walk around in a city than the building twenty meters meters in front of me is sharp as hell (if I wear my glasses) and those further away too. DoF simply doesn't look good, distracts and makes playing the game harder and frustrating.

Share this comment


Link to comment
The trees look like they've been lopped off at the top when they become imposters ;)

You could probably double up your FOV with a heat-haze effect (as GTA:SA does it) too :)

Share this comment


Link to comment
Yea most of those screenshots are WIPs with various problems...

http://www.radioactive-software.com/gangwar/Apr12/ImposterWIP12.jpg has the top of the trees fixed. I see what you're talking about now in the imposter-debug-screen, and the 2nd one below it [taken a few hour or so into the coding process]. I didn't even notice it until you mentioned it. You can't really tell in-game...

Also, if you don't like the DOf it's an option so it can be turned off obviously :-D

Share this comment


Link to comment

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