emoose / DLSSTweaks

Tweak DLL for NVIDIA DLSS, force DLAA on DLSS-supported titles, tweak scaling ratios & DLSS 3.1 presets, override DLSS versions without overwriting game files.
MIT License
1.31k stars 21 forks source link

DLSS 3.7: Alpha Upscaling flag #132

Open emoose opened 7 months ago

emoose commented 7 months ago

Streamline 2.4 released which includes DLSS 3.7 (info at https://www.reddit.com/r/nvidia/comments/1budh7i/streamline_sdk_240_dlss_370_dll_released/)

The SL changelog mentions the following:

Added support for a new preset sl::DLSSPreset::ePresetE. This is now the default preset for DLSS SR.
Added support for upscaling Alpha in sl.dlss.

Preset E is interesting, but the alpha upscaling is even more so, seems this has to be enabled by the game itself by setting alphaUpscalingEnabled SL flag, which then sets a DLSS creation flag:

https://github.com/NVIDIAGameWorks/Streamline/blob/7b94724d98ee6dccbf06def3ed89f18028647b35/source/plugins/sl.dlss/dlssEntry.cpp#L391

SL docs mentions the following about it:

experimental alpha upscaling, enable to upscale alpha channel of color texture

NOTE: Alpha upscaling (DLSSOptions::alphaUpscalingEnabled) is experimental, and will impact performace. This feature should be used only if the alpha channel of the color texture needs to be upscaled (if eFalse, only RGB channels will be upscaled).

NVSDK_NGX_DLSS_Feature_Flags_AlphaUpscaling is the new DLSS creation flag added, should be pretty easy to add to DLSSTweaks since we already have stuff to force AutoExposure flag, probably just need to update the DLSS headers with the new ones from SL & add code to read/set it from INI.

If anyone would like to contribute I'd be happy to review any PR, otherwise I'll look into adding something for it soon.

Klemci commented 7 months ago

This feature should be used only if the alpha channel of the color texture needs to be upscaled (if eFalse, only RGB channels will be upscaled).

Which games compatible (ALPHA thingie) ? That's the first question to answer before testings, right ?

doktorsleepelss commented 7 months ago

From the dlss programming guide

3.16 Alpha Upscaling Support By default, DLSS is intended for 3-channel RGB images, only. Experimental support for upscaling 4- channel RGBA images can be enabled by setting the NVSDK_NGX_DLSS_Feature_Flags_AlphaUpscaling flag at creation time. For best results, the RGB color should be premultiplied by alpha in the color input. Note: performance will be impacted by enabling this feature. Expect the overall execution time of DLSS to increase by 15-25% when alpha blending is enabled.

I don't know what any of this means and how we would benefit, but I want.

Klemci commented 7 months ago

@doktorsleepelss Alpha is transparency (tree foliage...), with DLSS it's like a DLAA version of SGSSAA.

emoose commented 7 months ago

Which games compatible (ALPHA thingie) ? That's the first question to answer before testings, right ?

Just noticed inside NvRTX repo readme:

r.NGX.DLSS.EnableAlphaUpscaling (false, default)

Alpha channel upscaling
0: off
1: on
Note r.PostProcessing.PropagateAlpha MUST be enabled for this feature to work.

From the code in that repo it looks like r.NGX.DLSS.EnableAlphaUpscaling just causes the NVSDK_NGX_DLSS_Feature_Flags_AlphaUpscaling flag mentioned in OP to be set, doesn't seem to make any difference to UE's rendering.

Might mean we could try forcing that flag with existing UE games, as long as r.PostProcessing.PropagateAlpha is set like the readme mentions, and hopefully will let it work properly - will look into adding a override for it to DLSSTweaks soon.

Other than that I'm not really sure how to check if a game might work with the alpha upscaling, maybe something like RenderDoc could tell us if final output is using RGBA?

emoose commented 7 months ago

If anyone wants to test it here's a build that includes OverrideAlphaUpscaling in the INI: DLSSTweaks-0.200.9.0-beta1.zip

You should be able to set the UE postprocessing cvar for RGBA by editing Engine.ini file (usually somewhere inside %APPDATA%), adding this to bottom of it should usually work:

[SystemSettings]
r.PostProcessing.PropagateAlpha=1

With that & OverrideAlphaUpscaling = 1 in DLSSTweaks.ini it should be active, I don't have any UE games installed atm so haven't tried it myself though, if you try it let us know how it goes.

Will probably be a 10-25% FPS hit like the DLSS readme mentioned, if you have the UE console unlocked it might be worth comparing r.PostProcessing.PropagateAlpha 0 vs r.PostProcessing.PropagateAlpha 1 during gameplay, sounds like changing that should change between RGB/RGBA, maybe will be able to notice some IQ difference with it (hopefully some improvement around transparencies?)

UE4SS can usually unlock dev console in most UE games: https://github.com/UE4SS-RE/RE-UE4SS/releases

Lewison78 commented 7 months ago

Do you know if its possible to get it working with other game engines? Or is it only available in UE games?

SplitCoreGaming commented 7 months ago

Do you know if its possible to get it working with other game engines? Or is it only available in UE games?

I been messing with it on Elder Scrolls Online with no luck. However the baseini setting is great as I do bounce between E/C depending on games. I also use symbolic links so still nice to have main file E / Override Preset C > Symbolic link setup. with only main parts changed.

*Or not. For example in BG3 the Hud override works, but preset C is not applied over the main files E. Weird. **Further further update. GlobalForcedPreset overrides the secondary ini files preset setting. Turned global off, got it working great now.

jpgsantos commented 7 months ago

It seems to work natively in hogwarts legacy(without "[SystemSettings] r.PostProcessing.PropagateAlpha=1"), atleast the image is diferent with it active, but the performance is more or less the same or even slightly improved. Strange so far.

doktorsleepelss commented 7 months ago

Just tested it in Talos Principles 2. I just get a ton of flickering on foliage and even on flat stone surfaces.

EDIT: Also lots of flickering in Remnant 2.

EDIT 2" Can't say I notice anything different with Hogwards and GhostRunner 2.

EDIT 3: Nothing happening in in Immortals of Avium.