3D How to find an article to make HDR ?

Recommended Posts

16 minutes ago, theScore said:

Hi !

Do you know a good article which explains how to make HDR ? ( on internet or in a book )

Especially, how have to be the colors values in the pass before the tone mapping pass.


What do you mean make HDR ? This does not make much sense as a question :)

Are you talking about turning on the HDR capability of modern UHD TVs ( and available with windows 10 creator update )

Are you talking about implementing a PBR  pipeline ?

The color before the tone mapping can be whatever you want, it is past the tone mapping, when you map the content to what the output expect that is important.

Before the Tonemapping, you usually store linear colors in an unclamp float format (like R11G11B10_FLOAT ), the color space primaries are either REC709/SRGB traditionally or REC2020 for the new HDR TVs with value from 0 to whatever you accumulate their.

After the tone mapping, you need to scale down things to the range the monitor accept, either it be [0..1] or [0..10000nits], with the proper encoding, SRGB or ST2084 for the display to be correct.

Share this post

Link to post
Share on other sites

By HDR, I mean the technique used with directx or opengl to enhance colors beauty for 3D rendering.

I heard that HDR stores colors much higher values than a 256 range, so you know can I get these values which at the origin are between 0.0 and 1.0 or 0 and 255 ?

Edited by theScore

Share this post

Link to post
Share on other sites

Yes, so does not make sense afterall :)

There is only two things to get the basics.


One, render to a surface that can represent values above one, like r11g11b11_float or r16g16b16a16_float.

Second, Apply tonemapping to compress the range back to 1 the simplest be "rgb/(rgb+1)"


That is all ! Then to looks good is all in details, pbr materials to looks good under various lighting condition and plausible, the choice of a brdf (usually ggx in game)and to be energy conservative, and do not screw up colorspace( albedo are srgb to be linearize, lighting in linear space, display go back to gammaspace srgb)

Share this post

Link to post
Share on other sites

Thanks for your advices :)

But I have few questions :

What do you mean by srgb to linearize ?

What do you mean by linear space for lighting ?

The third part between the parenthesises  : "display go back to gammaspace srgb"

And can you explain me what is the "rgb/rgb+1" in the phrase : "Apply tonemapping to compress the range back to 1 the simplest be "rgb/(rgb+1)"

What is it used for ? ( for the prvious question)

Share this post

Link to post
Share on other sites

Human eyes are more sensitive to low luminance, because of that, images are stored in gamma space or sRGB to give them enough bits in the dark area ( a 50% gray at 128 in your texture is in fact only 18% luminance in linear space). It means that when you read your albedo, you first need to convert it back to linear space, it is as simple as using a format for your texture view : DXGI_FORMAT_BC7_UNORM_SRGB versus DXGI_FORMAT_BC7_UNORM. The GPU will do the conversion for you, this is step one.

Step two, you are in linear space, and it is the correct one to accumulate lighting information ( also the proper space to do alpha blending ).

Step three if you were in a LDR pipeline ( so not our case ), the rendertarget is also a sRGB variant and the GPU do the opposite conversion for you. BUT, you want to do HDR, it means you do not have a sRGB variant format and that step is of your responsibility later !

Last step, now it is time to display your final image, you have linear space values in the range [0..infinity] and they need to map to [0..1] in gamma space, it is what your display understand. This is in two sub steps, first, the tone mapping pass, the formula rgb/(rgb+1) is called a tonemap operator. if you plot the curve, you will see the result is a compressed range of [0..infinity] scaled back to [0..1], it is what we need. Second substep, take the [0..1] range that is still in linear space to gamma space, either by applying the sRGB formula yourself or using a sRGB format variant to let the GPU do it fort you.



Share this post

Link to post
Share on other sites

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

  • Forum Statistics

    • Total Topics
    • Total Posts
  • Similar Content

    • By NexusDivision
      Hello people of gamedev.net

      Me and my team have been working on a MMORPG game with Unreal Engine 4 for quite some time now.
      We are seeking beta tester's and have beta key's available to people who sign up on our website.
      Please visit the website https://nexusdivision.com
      Feel free to register on our forums, We can talk about the game and help everyone get a better idea of what type of game it is. 

      Legion is a 3D fantasy MMORPG that has features including massive scale battles, unique characters and monsters, customization of avatars, special equipment and more. Players choose between the starter stats of Warrior, Magician, Archer and character advancement occurs through a mix of questing, PvP, Guild Wars, and hunting, depending upon player preference. In Legion, completely open PvP battles take place between members of the two warring factions.

      We plan to make this game very competitive and exciting 
    • By Benjamin Shefte
      Hey there,  I have this old code im trying to compile using GCC and am running into a few issues..
      im trying to figure out how to convert these functions to gcc
      static __int64 MyQueryPerformanceFrequency() { static __int64 aFreq = 0; if(aFreq!=0) return aFreq; LARGE_INTEGER s1, e1, f1; __int64 s2, e2, f2; QueryPerformanceCounter(&s1); s2 = MyQueryPerformanceCounter(); Sleep(50); e2 = MyQueryPerformanceCounter(); QueryPerformanceCounter(&e1); QueryPerformanceFrequency(&f1); double aTime = (double)(e1.QuadPart - s1.QuadPart)/f1.QuadPart; f2 = (e2 - s2)/aTime; aFreq = f2; return aFreq; } void PerfTimer::GlobalStart(const char *theName) { gPerfTimerStarted = true; gPerfTotalTime = 0; gPerfTimerStartCount = 0; gPerfElapsedTime = 0; LARGE_INTEGER anInt; QueryPerformanceCounter(&anInt); gPerfResetTick = anInt.QuadPart; } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// void PerfTimer::GlobalStop(const char *theName) { LARGE_INTEGER anInt; QueryPerformanceCounter(&anInt); LARGE_INTEGER aFreq; QueryPerformanceFrequency(&aFreq); gPerfElapsedTime = (double)(anInt.QuadPart - gPerfResetTick)/aFreq.QuadPart*1000.0; gPerfTimerStarted = false; }  
      I also tried converting this function (original function is the first function below and my converted for gcc function is under that) is this correct?:
      #if defined(WIN32) static __int64 MyQueryPerformanceCounter() { // LARGE_INTEGER anInt; // QueryPerformanceCounter(&anInt); // return anInt.QuadPart; #if defined(WIN32) unsigned long x,y; _asm { rdtsc mov x, eax mov y, edx } __int64 result = y; result<<=32; result|=x; return result; } #else static __int64 MyQueryPerformanceCounter() { struct timeval t1, t2; double elapsedTime; // start timer gettimeofday(&t1, NULL); Sleep(50); // stop timer gettimeofday(&t2, NULL); // compute and print the elapsed time in millisec elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0; // sec to ms elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0; // us to ms return elapsedTime; } #endif Any help would be appreciated, Thank you!
    • By Matuda
      Trying to create a physics puzzle game in my "free" time.
      So far it's going very steady, but slow.
      Hope to get some feedback from you!

      Area 86 is a physics-based game, that lets you control a robot at a secret place in space.
      From simple item moving to custom imagined solutions with item picking, throwing, combining and activating!
      Explore & examine all possibilities each place has to offer and do your best to get further.
      But remember, each action has consequences and thus could break or make something unexpected.

      Quick overlook of main features:
      Physics-based gameplay with no bugs or whatsoever Tasks that give you more clue on how to do things wrong Controllable robot who can be blamed for all consequences Includes more than 1 level and each level contains less than 12 possible tasks to complete [ not in free version ] Secret places and hidden objects for extra challenge  
      What can you find in the free downloadable version:
      One fully completable level with 6 tasks and 2 hidden special items to discover.
      From the task list, 2 are main tasks which you should complete to get further and then there are 4 other tasks that should challenge your thinking.
      One of the secret items is visible instant, but you need to figure out how to collect it, while the other special item is hiding.
      Another extra feature is visual hints, that should force your thinking of discovering features.

      Download playable version for your system:


    • By Mert Oguz
      well, i have started developing games last year, alone , I made a singleplayer 3d openworld rpg on unity you can look at it on googleplaystore ( kooru stone rpg ) whatever, this year, i wanted to make mmo, which gone really fine until I first try real hosting, I was working on "wamp" until then. The reason i am desperate now is that the way my game works.
      On my pc, using wamp mysql , with localhost as host for my game, i was testing my mmorpg with using andorid emulators, ofcourse no lag no issues no restrictions, beautiful dream... But then, I wanted to get real host from web, so, I rent a basic, cheaphest ever web host ( 10$ year ), and transferred my php files along with sql database. 
      So, I launched the game, still no issues, tried to handle 2-3 players by using my pc, phone, friend's phone...  
      After a while, ( after really short time (3-4mins)) host started not to respond, beacause those web hosting were not fit to handle mmos, i predicted that.
      now what i am explaining is that my game works like this and asking what way should i use to handle it :
      - Creates web request ( like : webhost.com/game/getplayerdata.php?ID=2 )
      -Reads request ( request result be like = "ID2-GoodGuyXx-23-123-4-123-43 )
      -Builds player using result string
      -does similar requests REEAALY FREQUENTLY  ( total requests of 8 - 12 times per seconds )
      With my current ultimate cheap web hosting, i can handle 2 players with low lag ( lol ) but, i want to handle around 20-100 players,
      just need a clear path, i have been struggling with google cloud sql and other vps server dedicated server options, i dont wanna pay much and get ripped off.
    • By mister345
      Hi, I'm building a game engine using DirectX11 in c++.
      I need a basic physics engine to handle collisions and motion, and no time to write my own.
      What is the easiest solution for this? Bullet and PhysX both seem too complicated and would still require writing my own wrapper classes, it seems. 
      I found this thing called PAL - physics abstraction layer that can support bullet, physx, etc, but it's so old and no info on how to download or install it.
      The simpler the better. Please let me know, thanks!
  • Popular Now