Stormhawk and Bellerophon + space views

Published March 16, 2008
Advertisement
Anti-aliasing with multiple render targets

It took me months to figure out ( of course, not full time. Just a couple of hours here and there ), but I had a serious problem to combine anti-aliasing with multiple render targets.

Inn OpenGL, it all comes down to how to make the EXT_framebuffer_object, ARB_draw_buffers, EXT_framebuffer_blit and EXT_framebuffer_multisample extensions work together.

The geniuses who wrote the specification were apparently too lazy to make this case work. According to the specification,

Quote:12) Should we add support for multiple ReadBuffers, so that multiple color buffers may be copied with a single call to BlitFramebuffer?

Resolved: No, we considered this but the behavior is awkward to define and the functionality is of limited use.


It is infuriating me to hear, in 2008, that combining anti-aliasing with multiple render targets is of "limited use".

To make a long story short, I found a workaround by blitting all the render targets manually one-by-one. It's not as optimized ( thanks to Vista, where binding FBOs many times is horribly slow ), but at least it works.. unfortunately I haven't got the chance to test it on ATI cards yet, so I'm expected loads of problems on them.

Spherical Harmonics

I researched a bit on spherical harmonics in order to improve the shading a bit. One thing I wanted to achieve is, for a ship in orbit around a blue planet, to have a subtle blue-ish color coming from the direction of the planet. A good way to do that is a cube map, but the details are too high frequency, so I would have had to blur this cube map. A better approach is to encode some infinite lights in spherical harmonics at a very low frequency.

While I was at it, I also added some slight reflectance on ships between each other, also added to the spherical harmonics. The intensity is estimated based on an approximation of the relative size of a ship from the viewpoint of another one. So this means that if two ships get close to eath other, a bit of light will be reflected between each other.

All those calculations are done on the CPU, and all that is left on the GPU is to evaluate the 9 spherical harmonics terms in the pixel shader; this is a relatively low cost.

Oren-Nayar lighting model

I modified the ships lighting model to use Oren-Nayar instead of Lambert. At the moment, the whole equation is evaluated per pixel, but I'm planning to encode it in a lookup texture instead. To be honest, the difference with lambert on ships isn't that visible, so I'll probably only apply it in high settings. However, asteroids ( which are rougher ) do look significantly better with it.

Sun shafts / god rays

I will come back on it in a later update, but I have added a sun shaft ( god ray ) effect ala Crysis. It's a screen space effect, but it looks volumetric, and it matches the actual shadows. It looks really good, although it requires to take various samples in screen space, up to 64. Sampling a screen buffer 64 times per pixel isn't exactly fact, even on a 8800 GTX, but this is of course for the highest quality. On slower cards, it is possible to only sample 32 or 16 times, although sampling patterns start to appear.

The implementation is rather easy: project the light source ( sun ) into screen-space, and perform a radial blur while accumulating and fading out samples. I improved the initial ideas a bit with all sorts of optimizations, and clipping the light source to the screen boundaries, fading with the camera-to-light angle, etc..

I'll post some pictures later, but this is definately a nice effect that was quickly implemented ( in like 2 hours ) and that adds a lot to the realism and rendering quality, especially on planets at sunsets :)

High-dynamic range

I've also spent a lot of time to reimplement HDRI in GLSL, and fine tune all the parameters; making the bloom not too strong, etc.. I ended up using the improved Reinhard tone-mapping operator. The basic Reinhard operator was washing-out the colors ( they never achiever pure white ); but the improved version is better, as you can specifiy the intensity of the white color in HDR space.

Still, HDR was and is still a real pain to tune. Especially in space scene. Imagine a small ship inside a starfield. The camera is quite far, so the ship is only a few hundred pixels on screen. All tone-mapping operators make use of the average scene luminance.. which is extremely low in a space scene, since 90% of the pixels are black. The result is that the ship is naturally over-exposed. Fortunately, Reinhard's operator does a decent job at avoiding over-exposition, but you can immediately forget any linear operator.

Databases

A few words about databases. I've done some performance tests with Mysql about the amount of queries and operations I can do per second, and although it's very dependant on the complexity of queries, amount of bandwidth between the mysql client/server, size of the tables, etc.. I believe I will not be able to exceed the order of 10K queries per second on a decent machine. That sounds a lot, but I think I can do a lot better by implementing a high-performance, memory cached database myself. The code is already ready, but I have to do some performance tests to compared with a "real" Mysql server. I'm expecting a x10 performance boost, but it won't use SQL as the query language, but instead a specific restricted interface. The final plan is to mix mysql were reliable data is needed ( accounts for example ) with my high-performance simplified database when unrealiable data is acceptable.

New screenshots

Last but not least, a brand new serie of screenshots. With anti-aliasing back :)

Showing the Stormawk, modeled by CJ and textured by Juan; and the Bellerophon, by Spectre, with its temporary texturing by me.















Previous Entry Horizon culling
Next Entry Terrain engine
0 likes 9 comments

Comments

DJMurtz
Great update on a lot of things. I was wondering if you noticed the weird self-shadowing (best seen on the last image) that occurs on the ships? Is this something that is being looked at or is the best you'll be able to achieve without dropping in performance?

Also, about the background planet. Is it a real planet you could actually land on, or is it just an image? If the first, is it a planet procedurally generated by your engine? Because it seems there are a lot of small islands on that planet which look kinda "squarish" (best seen on image 4). Is this the way planets are meant to be generated, or is it some kind of bug that's still present in the generator?
March 16, 2008 02:53 PM
johnhattan
As always, very impressive screenshots. I'm not seeing the shadow problems. If it's that the shadows are harsh, they would be in space. Shadow blurring is the result of atmospheric scattering which wouldn't happen in space.
March 16, 2008 07:27 PM
sprite_hound
As awesome as always.

I too can't see anything weird with the self-shadowing. Oh wait... had to look at the larger versions: jagged saw-tooth edges on the shadows.

What's the circular spotty effect on the screen? (on the last image especially).
March 16, 2008 10:39 PM
Cth
I wonder... since you're using many almost hack-ish techniques due to non-performance restrictions on hardware, drivers, etc. - where does this take you in the long term?

Of course that is the coolest kind of programming and exactly how limits are pushed, but how do you know that at the end of the day you'll be able to deliver a working engine? Are you continuously testing on different platforms?

I'm not criticizing - I'm just curious. I don't know how standardized graphics HW functionality is nowadays, but many years ago it was just horrible. Most things I worked on only ran properly on my own machine. Anything beyond the most standard way of doing things could result in unexpected behavior.
March 17, 2008 03:03 PM
Ysaneya
Quote:Original post by DJMurtz
Great update on a lot of things. I was wondering if you noticed the weird self-shadowing (best seen on the last image) that occurs on the ships? Is this something that is being looked at or is the best you'll be able to achieve without dropping in performance?


Yes, that's shadow aliasing. Nothing I can do to fix it; I'm already using cascaded shadow maps with 4 frustums/shadow maps, to get a shadowing range of up to 20-30 Km. You can't really get any better than that without 1) increasing the amount of levels, which would hurt performance even more or 2) reduce the shadowing range, which wouldn't fit the wide range of ships and buildings we have so far.

Quote:Original post by DJMurtz
Also, about the background planet. Is it a real planet you could actually land on, or is it just an image? If the first, is it a planet procedurally generated by your engine? Because it seems there are a lot of small islands on that planet which look kinda "squarish" (best seen on image 4). Is this the way planets are meant to be generated, or is it some kind of bug that's still present in the generator?


This is a real planet.

It is procedurally generated.

The small islands indeed have some squarish artifacts, but I'm still working on it. They're usually ice/snow areas on top of mountains.
March 17, 2008 05:31 PM
Ysaneya
Quote:Original post by sprite_hound
What's the circular spotty effect on the screen? (on the last image especially).


Are you refering to the reflections on the ship ? This is the starfield background. I'm using a spherical environment map rather than a cube map, simply because I haven't bothered implementing real cube maps yet. So yeah, there is a spherical deformation effect. It's only temporary.

March 17, 2008 05:33 PM
Ysaneya
Quote:Original post by Cth
Of course that is the coolest kind of programming and exactly how limits are pushed, but how do you know that at the end of the day you'll be able to deliver a working engine? Are you continuously testing on different platforms?


Exactly. I'm regularly developing on various NVidia-based systems (GF7/GF8), and less regularly on ATI cards (X850/X1900). I also release public prototypes every once in a while (like the ICP) which are very useful to make sure it runs on a wide amount of systems.

Finally, the game will have alpha and beta testing phases.
March 17, 2008 05:36 PM
youaresomean
I am following your journal for quite some time now. Amazing work!
How do you manage to stay so motivated and put so much effort into this project along with a fulltime job? Unbelievable.
March 18, 2008 01:51 PM
AbelCorver
Unbelievable!! These screenshots are truly amazing! I'm working on some landscape stuff and I'm using 100MB ram for the most ugly images in comparison with these!
Great job! I hope it will become a sort of large-scale engine!

Continue the good work!
June 12, 2008 10:08 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement