Jump to content
  • Advertisement
Sign in to follow this  
simotix

Learning HDR ...

This topic is 3758 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!