Add HDR10 output support to the DX11 renderer#63
Add HDR10 output support to the DX11 renderer#63themrdemonized merged 4 commits intothemrdemonized:all-in-one-vs2022-wpofrom
Conversation
Changes: - Duplicated libraries/x64, moved the original library files to libraries/x64.old, the new libraries are in libraries/x64. This contains the latest DirectX libraries from the Windows 10 SDK (version 10.0.22000.0\um\x64). Obviously committing binaries like this isn't a good idea (for security and practicality) but this was the simplest way to get the DX11 renderer to build using the new interfaces (specifically CreateDXGIFactory2) required for HDR support, and there were already old DX SDK library binaries in the repo. I'm in favor of removing these if there's a better way of providing libraries from the Windows SDK (there probably is but I'm not familiar with VS configuration and how it prioritizes library search directories, or how to do that in a way that works outside my machine) - Added HDR parameters to the console variables and global shader constants. `ps_r4_hdr_whitepoint_nits` should be set to the monitor's HDR whitepoint (max brightness). `ps_r4_hdr_ui_nits` is the UI brightness in nits and should be set below the whitepoint at a level that is comfortable for the user. `ps_r4_hdr_pda` isn't a console variable, but a global I'm using as a flag to determine when the PDA's UI is being rendered, this is to avoid applying HDR tonemapping twice since it is also rendered in the world as a texture. `ps_r4_hdr_on` controls whether HDR is enabled or not (requires game restart so the render targets are created in the correct format) - In order for the renderer to support HDR output the swapchain and DX 11 version had to be updated to use the dxgi11_4/d3d11_4 interfaces, HDR also requires using a different swapchain flip effect, this also has performance benefits for borderless and windowed modes (see: https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/for-best-performance--use-dxgi-flip-model ) making them perform the same as exclusive fullscreen. There are probably other performance improvements available, one flag I haven't turned on is `D3D11_CREATE_DEVICE_SINGLETHREADED` which should improve performance provided the renderer is singlethreaded (I think it is, but not sure if someone wants to comment on that) - I had to rework some of the GUID symbols in the xrNetEngine because their symbol names collide with symbols in the Windows SDK `dxguid.lib` which would cause linker errors when building Issues: - Built in screenshots won't work in HDR mode because the backbuffer is a different texture format than the code expects, I put a TODO in because even if it was fixed there are other issues that make them useless (output format would require HDR support) - The PDA global is a shitty hack, maybe there's a better way that someone could suggest? - HDR should probably be toggleable from the Modded Exes section of the menu, haven't figured out how to do that yet - I'm not sure the way I've integrated the HDR option is the best (just a global console var), it seems like there are options that e.g. SSFX uses that are in RImplementation, I probably need to look into how all that works - To get the UI to be HDR tonemapped, I had to modify the `stub_default.ps` shader to apply HDR tonemapping. I'm not sure if this breaks anything else that uses this shader (visually I haven't noticed any issues). A better solution would be to modify the logic the game uses for selecting the shader for UI and have it pick something else, but it's not clear how best to do that or if it is even required Requirements: - For the HDR output to be tonemapped correctly into the ST2084 colorspace the monitor expects, the shaders here are required: https://github.com/deggua/xray-hdr10-shaders - I've provided shaders for Anomaly and GAMMA (GAMMA is really just SSS's `combine_2_naa.ps` shader modified to apply the HDR tonemapping)
|
Some other issues I've noticed in testing:
|
|
It does not make sense to me. You did not removed tonemapping curves from other shaders. |
It's not color or gamma correct in quite a few places then. I'll look at fixing the ones you mentioned and see if I can find any other shaders with issues. Anything tonemapped from HDR won't look right for sure and is probably why some things look blown out or too dark (imo sky is too bright currently and translucents are too dark). |
|
Forgive my large amount of ignorance, i've actually done very little work in the code side of things, but considering that a lot of emphasis is placed on HDR in this conversation, I wanted to posit that the HBAO, HDAO, and SSAO might be better replaced with a type of GI with Path/Raytracing if at all possible, allowing for a better color palette and more authentic lighting. considering that, would it be possible to add a D3D11on12 API, then add Path tracing in that manner? Or use DXVX to pull the Vulkan API and ray trace from there? I know that SSRTGI is basically created from implied depth, but integrated PT/RT uses both screen space and the actual engine positions and so on to ray trace. If you had access to DX12 or Vulkan HDR10 should also be easier to implement overall due to the way that the API handles it. https://github.com/microsoft/D3D11On12 |
Is it as simple as modifying the
I believe the above change to the |
|
I updated the shaders associated with this PR. These should remove SDR tonemapping when HDR is enabled (which should not be applied as LVutner pointed out), they also attenuate the sun and lens flare effects since those seemed too bright, and I found a better way to apply HDR tonemapping to the HUD that should avoid applying HDR tonemapping to other effects that use the |
|
I'll check it out later, thanks. Let me know if your changes are final and ready to go |
There's some cleanup to be done in |
|
yea, you should put all shader files that you changed and are requried into gamedata/gamedata/shaders/r3. |
- Added color space selection and console command for HDR10. Options are Rec.709, DCI-P3, and Rec.2020. - Added shaders required for HDR10 output to work correctly - Added `_RELEASE` calls where original interface is discarded in `dx10HW.cpp`
I think everything is ready. My editor or my git config might have messed up the text encoding on some of the files with Cyrillic characters, so you might want to check that. I think I fixed it for I also added a colorspace option since most HDR games let you choose that. |
|
Alright, i was running shaders mod before testing, on an absolute clean install it looks much better. I lowered nits to 600. So it raises a mod compatibility problem. The previous screenshot had i think Beef's NVG enabled, and it overwrites shader files from modded exes install. I guess someone has to update the mods to have correct HDR support. I can issue a warning for that case. |
Add HDR10 output support to the DX11 renderer (cherry picked from commit 4ba6d43)
I have an OLED as well, the 1000 nits mode w/ r4_hdr_whitepoint_nits = 1000 looked very blown out (sky especially), if it has a HDR 400 mode try that w/ r4_hdr_whitepoint_ntis = 400. In the 1000 nits mode I had to lower the whitepoint to 800 before it looked reasonable, but there were still weird problems with auto-brightness limiting darkening the whole screen. Also try changing the color space to DCI-P3 or Rec.2020 if it's too saturated. There is some shader incompatibility, I put the patch required for GAMMA (SSS + Enhanced Shaders + Beef's NVGs) here: https://github.com/deggua/xray-hdr10-shaders I've been playing GAMMA for the last few days with it on and it looks good imo, although a little dark by default, but tweaking gamma and brightness fixed that. Also, if you want to take HDR screenshots, the best way (if you have nvidia at least) I've found is to use the Nvidia overlay and screenshot with Alt+F1. This will save it as JPEG XR in HDR, viewing JPEG XR files in HDR requires an HDR image viewer, this one works for me: https://13thsymphony.github.io/hdrimageviewer/ |
|
ever since your HDR10 update to modded exes, all macOS and linux users are unable to play anymore....linux players can turn off some mods like SSS to continue play as I heard, macOS is totally unable to play |
Please read the latest message there #95 |



Changes:
libraries/x64, moved the original library files tolibraries/x64.old, the new libraries are inlibraries/x64. This contains the latest DirectX libraries from the Windows 10 SDK (version10.0.22000.0\um\x64). Obviously committing binaries like this isn't a good idea (for security and practicality) but this was the simplest way to get the DX11 renderer to build using the new interfaces (specificallyCreateDXGIFactory2) required for HDR support, and there were already old DX SDK library binaries in the repo. I'm in favor of removing these if there's a better way of providing libraries from the Windows SDK (there probably is but I'm not familiar with VS configuration and how it prioritizes library search directories, or how to do that in a way that works outside my machine)ps_r4_hdr_whitepoint_nitsshould be set to the monitor's HDR whitepoint (max brightness).ps_r4_hdr_ui_nitsis the UI brightness in nits and should be set below the whitepoint at a level that is comfortable for the user.ps_r4_hdr_pdaisn't a console variable, but a global I'm using as a flag to determine when the PDA's UI is being rendered, this is to avoid applying HDR tonemapping twice since it is also rendered in the world as a texture.ps_r4_hdr_oncontrols whether HDR is enabled or not (requires game restart so the render targets are created in the correct format)D3D11_CREATE_DEVICE_SINGLETHREADEDwhich should improve performance provided the renderer is singlethreaded (I think it is, but not sure if someone wants to comment on that)dxguid.libwhich would cause linker errors when buildingIssues:
To get the UI to be HDR tonemapped, I had to modify thestub_default.psshader to apply HDR tonemapping. I'm not sure if this breaks anything else that uses this shader (visually I haven't noticed any issues). A better solution would be to modify the logic the game uses for selecting the shader for UI and have it pick something else, but it's not clear how best to do that or if it is even requiredhud_default.sand ahud_cursor.sto specify the pixel shaders as separate filesRequirements:
combine_2_naa.psshader modified to apply the HDR tonemapping)Any feedback is appreciated. If you want to direct message me my Discord name is Antagonist in the GAMMA discord (username:
@antag0n1st)