Learning HDR ...

Started by
6 comments, last by MJP 15 years, 8 months ago
I feel very comfortable with my DirectX and HLSL skills to the point where I would really like to learn how to do HDR. However, I am finding it to be a harder task then what I thought it would be. I have seen a few tutorials (such as the one of this site), read over them but when I go to check out the example codebase it is usually broken or cluttered. I know the one of this sites does not even compile and I tried to fix it but I get a lot of run time errors. I tried looking at the SDK example but that one is just cluttered. Does anyone have or know where I can find an example project?
Advertisement
Which part are you finding hard to understand, the theory or the implementation?

If it's the former then I can move this to 'Graphics Programming & Theory' where you may get a more detailed answer and reading recommendations.

Otherwise, what is it about the implementation you don't get? Any specific code fragments you've seen that you don't get or are trying to write but don't know how?


As for the SDK samples, have you looked at my HDRPipeline sample?



It started out as my own educational toy to try and understand the 'behind the scenes' steps involved with HDRI.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I am having more of a problem with the idea of the implementation. I have seen the sdk example but I am really looking to find a smaller code demo of how it is done.
I know it's fairly difficult to understand it at first.
Try and grasp the concept of what you are doing. How it works and how the pipeline is put together.
Draw it out on paper and visualize it.

Then after that, try and code something similar to the concept and look for the required functions.

I hope this helps.
Take care.
The individual steps involved in HDRI are pretty simple and its the complexity of many simple steps that make the whole thing seem rather daunting.

I would recommend you step back and get familiar with post-processing algorithms. As an implementation detail this is absolutely key to HDRI. Being familiar with how to "ping pong" between render targets and how to compose your scene off-screen using 'render-to-texture' then apply pixel shaders to them when sending them to the actual visible backbuffer...

Once you've cracked that you can build up the HDRI stuff without too much difficulty. You can drop in the various bits and pieces as you go - it might look rubbish, but you can get away without luminance measuring temporarily if you just set a constant for example.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

As was the case when I was learning most of this stuff, you're probably making it out to be more complex than it really is ;)

If you need a few pointers, here's a short summary of what's involved:
-Make a high-precision render target. For this you're gonna want to have some familiarity with how DirectX handles texture formats. You probably want the A16R16G16B16F one for now, but once you get a handle on this you can experiment with HDR encoding just like Epic and Valve. (Google it!)
-Assign this to the back buffer using some of DX's helper funcs.
-Draw everything as normal.
-Do your postprocessing and write to a regular 24-bit color texture. Remember to run a tone-mapping pass! (Google some algorithms for this until you find one you like as there are lots)

That's really all there is to it! You might want to have a look at Humus' work, as he has some very nice, clean implementations of a lot of interesting effects, including an HDR pipeline. Some of it uses DX10, but there's a lot of easy-to-understand HLSL and GLSL code that shouldn't be too hard to adapt to your own nefarious ends :) As with jollyjeffers, I'd be more than willing to contribute what I can, although I think the Microsoft MVP and tute author might be the better option among us.

EDIT: Hurrr. I totally forgot about measuring luminance, which is probably the part that has you all confused. Thanks jeffers! Yeah. That's mostly just using sequentially smaller render targets until you can get it down to a nice 1x1 final value. Assuming you have the DX SDK, I *highly* recommend reading that little 'documentation' thing for the HDRLighting sample, as it provides a pretty easy-to-understand explanation of the whole process along with snippets of the actual code showing implementation.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.
I've got a quick question, to make sure I understand HDR as it's used for video games...

You basically render as if you could render a larger range of luminance, then just scale it down to the actual range?
We should do this the Microsoft way: "WAHOOOO!!! IT COMPILES! SHIP IT!"
Quote:Original post by dbzprogrammer
You basically render as if you could render a larger range of luminance, then just scale it down to the actual range?


Yes, that's basically how it works. It's also common to use hacks like Bloom to fake the appearance of certain areas being much brighter than their surroundings (like they were in the original HDR image).

This topic is closed to new replies.

Advertisement