AmbientLight.fx (with dither toggle)

  • SoZ
  • Topic Author
More
7 years 3 weeks ago - 7 years 3 weeks ago #1 by SoZ AmbientLight.fx (with dither toggle) was created by SoZ
TL;DR: A version of Ganossa's AmbientLight.fx with a toggle to turn dithering off. Try it if you encounter diagonal lines running through your image.

Download: pastebin.com/Pjqg0unK


I am completely new to ReShade and this is my first post here, so apologies in advance if I'm doing anything wrong. I've seen plenty of ReShade/SweetFX screenshots over the years but I hadn't looked into using ReShade before today. I wanted to make my screenshots a little more interesting, so I figured I would download it and give it a go.

After an hour or so of fiddling, I am very happy with the results, but the AmbientLight.fx shader was introducing a pattern of diagonal lines running through the image. Unable to find any mention of the issue on this forum, I traced the source of the pattern back to the "dither" code within the shader. Funnily enough, determining the origin of the problem gave me the keyword I had been missing to search for other posts on the topic on the forum, such as this one where Marty McFly had identified the cause of the problem previously: TOPIC: Shaders Problems

I have modified the version of AmbientLight.fx that was automatically downloaded when I installed ReShade earlier to allow dithering to be turned on and off via the AL_Dither toggle in the UI. It fixes my problem and I figured I would share the modification in case it's of use to anyone else. Hopefully there are no issues with sharing modifications to existing shaders that are already publicly available here; the forum rules weren't clear.

Regarding the dither code itself, not having used ReShade before, I am unsure whether or not it is working as intended. While it is technically a dither, the harsh pattern produced is very distracting. A more subtle pattern or random noise might produce a better result. Perhaps I'll experiment when I have more time.
Last edit: 7 years 3 weeks ago by SoZ. Reason: Additional thoughts on the existing dither code
The following user(s) said Thank You: Wicked Sick, Apocalypso, One3rd, acknowledge, andrew, Uncle Crassius, WalterDasTrevas, Exilium, Marty, Sinclair and 2 other people also said thanks.

Please Log in or Create an account to join the conversation.

  • One3rd
More
6 years 8 months ago #2 by One3rd Replied by One3rd on topic AmbientLight.fx (with dither toggle)
Thanks for this! That pattern had been bugging me for a while but I wasn't actually sure what was causing it. It had actually stopped me from using the AmbientLight shader in a number of situations due to this. The strange thing was it only showed up in some games and not all and I couldn't pin down why.

Please Log in or Create an account to join the conversation.

  • Diego0920
More
4 years 10 months ago #3 by Diego0920 Replied by Diego0920 on topic AmbientLight.fx (with dither toggle)
Godsend.

Please Log in or Create an account to join the conversation.

  • aaronth07
More
4 years 9 months ago #4 by aaronth07 Replied by aaronth07 on topic AmbientLight.fx (with dither toggle)
Thanks, testing it now.

You should consider submitting a pull request on Github, so that this can replace the normal ambient light.

Please Log in or Create an account to join the conversation.

  • HekutoruMAC
More
4 years 6 days ago - 4 years 6 days ago #5 by HekutoruMAC Replied by HekutoruMAC on topic AmbientLight.fx (with dither toggle)
Hello. After finding it by chance I updated and corrected this shader mod to make the pull possible.
If anybody wishes to confirm it is working as intended, be my guest!

Code: Pastebin

Differences between SoZ original version and my update:
AmbientLightDither2017 vs AmbientLightDither2020

Differences between current github version and my update:
AmbientLight2020 vs AmbientLightDither2020

In short, it now uses some constants from ReShadeUI.fxh and fixes the logic of dither and adaptation.
Thanks to SoZ for making your contribution public and Ganossa for the awesome shader.
Last edit: 4 years 6 days ago by HekutoruMAC.
The following user(s) said Thank You: Wicked Sick, acknowledge, Viper_Joe, Marty, aaronth07, canceralp

Please Log in or Create an account to join the conversation.

  • canceralp
More
3 years 4 months ago #6 by canceralp Replied by canceralp on topic AmbientLight.fx (with dither toggle)

HekutoruMAC wrote: Hello. After finding it by chance I updated and corrected this shader mod to make the pull possible.
If anybody wishes to confirm it is working as intended, be my guest!

Code: Pastebin

Differences between SoZ original version and my update:
AmbientLightDither2017 vs AmbientLightDither2020

Differences between current github version and my update:
AmbientLight2020 vs AmbientLightDither2020

In short, it now uses some constants from ReShadeUI.fxh and fixes the logic of dither and adaptation.
Thanks to SoZ for making your contribution public and Ganossa for the awesome shader.


Thank you.
I just got the chance to try it. However, dithering option still causes diagonal stripes. It is slightly less visible than the 2017 version.

I use it with Lightroom (increased contrast) and some sharpening. Considering they all add banding issues, I always add a very tiny amount of film grain at the end to compensate.

BTW, would you please explain what is different in the "new logic of adaptation" part? Is the 2020 adaptation more accurate? or performance-friendly?

Please Log in or Create an account to join the conversation.

  • Daemonjax
More
2 years 11 months ago - 2 years 11 months ago #7 by Daemonjax Replied by Daemonjax on topic AmbientLight.fx (with dither toggle)
I think the only real way to completely remove patterns cause by the dithering function is to use random noise in that function. Nowhere in the shader does it do that -- that would have to be added. Not hard to do.  Basically just completely replace how the dithering is done to use random noise instead of a deterministic function which the eye can easilly pick up patterns in.  Hell, the eye and brain is so good at finding patterns, it'll even find them in random noise if you cranked it up.  The dithering should only be applied to the effect added. 

Making it texture based might be good enough (a static noise texture)... would look more like screen dirt if you looked closely enough, though, but would be fine at lower strength levels.  I mean, how much dithering is really necessary to remove banding?  Because that's all you'd need.  I'd start with a static noise texture because it's easier, faster, and easier to play with different pixel sizes of noise.
Last edit: 2 years 11 months ago by Daemonjax.

Please Log in or Create an account to join the conversation.

  • Reticuli
More
1 year 9 months ago #8 by Reticuli Replied by Reticuli on topic AmbientLight.fx (with dither toggle)
What ever became of this? AmbientLight is too blotchy without dither, but the dither technique is awful, and on my machine is also causing certain CTDs that go away with dither off. Is there an improved version?

Please Log in or Create an account to join the conversation.

  • Jesped
More
11 months 2 weeks ago #9 by Jesped Replied by Jesped on topic AmbientLight.fx (with dither toggle)
Yep. It would be great to have a fixed version of AmbientLight. It's still a very useful shader.

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.