HDR rendering means you do all your pixel/lighting calculations in a higher precision than that which is used for display, in a more "open-ended" color space. For example, you might use a 16bit per channel floating point surface. Normally, the output for each color channel is clipped to (0, 1). So if your lighting calculations meant that a pixel was brighter than full brightness, that information was lost. A floating point surface will allow for values greater than 1 (just using an 8 bit per channel FP surface won't technically give you any greater precision than your standard RGB, but makes calculations easier since you can just let values go above 1).
Unfortunately, none of the floating point surface formats on the Xbox support alpha blending. So that was pretty much a deal-breaker.
I could use a regular 32 bit ARGB render target, and just divide all my output pixel values by some factor. And then draw that render target to the back buffer and multiply by that factor again. But then I am losing precision. I played around with this before, and it wasn't too bad - but I dropped it because I perceived it to be a problem.
D3D supports a R10G10B10A2 format... 10 bits per color, and 2 alpha channel. This would suit my purposes, but the 2 bit alpha channel always worried me. Although, conceptually I didn't understand why the alpha channel of the render target mattered at all. So I coded this up again and was pleased to see it work fine.
On the PC.
On the Xbox, all my translucent objects were reduced to 4 levels of alpha. Why? They are only being drawn on top of the 2-bit alpha render target. Some searching on the XNA forum again showed that the Xbox converts the output of the pixel shader to the format of the render target before applying it to the render target. Foiled again!
Further research showed that this was only a problem for "translucent" alpha blending: where the final result included the original destination pixel in its calculation. Most of my non-particle alpha objects were like this (e.g. the shield, the planet atmosphere, the spotlight cones). Most of the particles used additive alpha blending. This wasn't an issue for additive alpha blending.
I found that I could mostly emulate the effect I want solely using additive alpha blending. A few things look a little worse, but I hope the gain I get from "true" HDR will be worth it.
What does it give me? Well, I don't need the contrast range necessary for realistically rendering indoor/outdoor scenes, and adjusting "exposure" (since the game takes place in space). What I do get is bloom: washing out the brightest parts of the scene with a glow.
The effect is often over-used in games, but I think it will help make things look more "professional".
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment