Sign in to follow this  
  • entries
    235
  • comments
    509
  • views
    171778

Compositing

Sign in to follow this  
SimmerD

178 views

One of the nice things about the Ancient Galaxy rendering, is that it properly composites textures and decals before lighting and shadowing is computed.

Things like terrain layers, bullet holes, blood spatters, etc. are combined into a diffuse texture, which is copied offscreen, and then the same is done for the normals.

Then the lighting is done using these composited buffers instead of the terrain's regular textures. I still draw the real geometry, just use a flat-projected texture for the color and normals for lighting.

At various points in development, I had the entities drawn into these composited buffers as well, and today I've once and for all taken them back out again.

One downside of this sort of compositing is that it is not totally correct with respect to anti-aliasing, but it can be made close to correct.

For instance, say you have two chunks of terrain geometry next to each other, one which is glossy, and the other which is not. The gloss term is stored in the composited normal buffer alpha, which is copied offscreen. During this copy, if Anti-aliasing is on, this is where the downsampling happens.

This makes the seam between the glossy and non-glossy parts a mix of the glossy & non-glossy values.

This can make visible seams when AA is applied, because the lighting is performed on both sides of the seam, and the glossy object is going to pick up some of the non-glossy texture and normals behind it. In practice, this is usually fine, b/c an AA'd edge should be a blend of foreground and background anyway, but what you'd really want is the lighting to happen twice, independently, and then sampled down once at the end.

This issue doesn't cause visible issues on the terrain right now, as I've gone through pains to ensure that the alpha channels of the composited buffers ( emissive and gloss ) are blacked out when the material is not supposed to be emissive or glossy.

But it certainly was causing problems with the characters against the backgrounds. When I tried to recall just why I had made the entities rendered in the compositing buffers, I came up blank. Since entities don't receive texture blending or decals, they really can be drawn over the backgrounds after all decals, etc are finished and copied offscreen.

So, I made the switch this morning, got things working again, and am happy to report the halo effect is gone, and performance is up a bit. Before entities were drawn to the diffuse buffer, then to the normal buffer, then once to the frame buffer for ambient, then two to three times per shadowing light.

Now they don't get drawn into the diffuse or normal buffers, so that helps out on levels with more entities.

I also made some AI fixes yesterday. You make a level with some new gameplay, and find more holes in the AI - like they were too careful about avoiding shooting teammates to the point where close-by dudes were blocking each other too much. But, it gave me a chance to clean up & consolidate some more code.

The beta mentioned earlier has not yet materialized, but could be shipped any day. Still a bunch of polish things to do on the 1st 3 levels, but this week it will go out to a couple of people, with the next real beta set for 7/7.


Sign in to follow this  


1 Comment


Recommended Comments

I love the screenshot 2 entries ago, with the water + character model. Looks awesome, and reminds me of Oblivion for some reason.

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