Gaussian Blur / Bloom / Unsharpmask

  • Ioxa
  • Topic Author
More
9 years 3 months ago - 8 years 6 months ago #1 by Ioxa Gaussian Blur / Bloom / Unsharpmask was created by Ioxa
This is my attempt to port the the GAUSSIAN shader by Boulotaur2024 to ReShade. Some settings from the original are missing and I have added some other settings to achieve certain looks. None of this is my original work.

This shader is included in the CustomFX section of the Framework. The file available for download here is meant to be used with ReShade + SweetFX or ReShade + MasterEffect.

**Update for the ReShade + Framework version of the shade**
Updated 10/04/2015
I made some changes to the blur passes in this shader to reduce the performance cost, results that were taking 11 or more passes in the current version are now being achieved in 2 or 3 passes (3 or 4 passes for bloom). I'm still making some adjustments and looking for ways to reduce GaussianBlur and Unsharpmask to 2 passes max and GaussianBloom to 3 passes max but it may be awhile before I can work on it again so I figured I'd upload what I have.

Download Gaussian Perfromance Test

The GaussQuality and GaussBloomQuality settings now go from 0 to 3 instead of 0 to 12. Setting to 1 is equivalent to 3, 2 is equivalent to 9, and 3 is equivalent to 12.

Install instructions for Gaussian Blur / Bloom / Unsharpmask for use with SweetFX or MasterEffect.
1. Place the included ReShade.fx file in the same folder as SweetFX.fx or MasterEffect (ReShade.fx).
1.a) If using with MasterEffect, rename MasterEffects ReShade.fx file to ReShadeME.fx.

2. Place the included GAUSS_settings.h file in your SweetFX folder (if you don't have one, make one).
If using this with SweetFX, the definitions from GAUSS_settings.h may be cut and pasted into SweetFX_settings.txt.
If you do this, leave the last definitions in the GAUSS_settings.h file.
*Keeping the definitions in both files will cause errors.

3. Open GAUSS_settings.h and set "Compatibility" to 1 if using with SweetFX.
Set "Compatibility" to 2 if using with MasterEffect.
Leaving "Compatibility" set to 0 will only load the Gaussian effects.

Download

I know very very little about coding and only got this working with a lot of help from crosire, so if you find any problems or have any recomendations please let me know.
Last edit: 8 years 6 months ago by Ioxa. Reason: Update
The following user(s) said Thank You: crosire, Wicked Sick, kurtferro, Yazame, Insomnia

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

  • kurtferro
More
9 years 3 months ago #2 by kurtferro Replied by kurtferro on topic Gaussian Blur / Bloom / Unsharpmask
Nice thanks!

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

  • kurtferro
More
9 years 3 months ago #3 by kurtferro Replied by kurtferro on topic Gaussian Blur / Bloom / Unsharpmask
Game client crash at start in neverwinter online, i think need dx11 version :side:

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

  • crosire
More
9 years 3 months ago - 9 years 3 months ago #4 by crosire Replied by crosire on topic Gaussian Blur / Bloom / Unsharpmask

kurtferro wrote: think need dx11 version

Nah, it's ReShade, you don't need different shaders for D3D9 or D3D11 here =). ReShade translates it all automaticly under the hood (it may be a good idea to remove that "_DX9" postfix to clarify that).

But there is problem with the shader, line 140 needs to be replaced by:
return tex2D(frameSampler, IN.UVCoord);
Or otherwise you are reading and writing to the same texture (origFrameTex) at the same time, which is impossible. Maybe causes a crash in D3D11, but I would be highly surprised by that, I don't think the crash is related to this shader, because shaders don't usually can cause such a thing.

ALso, out of curiosity, why did you disable the brightpassfilter pass?
Last edit: 9 years 3 months ago by crosire.
The following user(s) said Thank You: Nekrik

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

  • TCPIP
More
9 years 3 months ago - 9 years 3 months ago #5 by TCPIP Replied by TCPIP on topic Gaussian Blur / Bloom / Unsharpmask
Strange, but this simple code works faster than gauss shader you posted, it's a local contrast shader btw
#define sharp_strength 0.2
#define offset_bias 89.0

float4 LumaSharpenPass(float2 tex)
{
	float4 blur_ori;
	float4 ori = tex2D(s0, tex);
	for(int j = -10; j <= 10; ++j)
		{
		for(int i = -10; i <= 10; ++i)
			{
			blur_ori += tex2D(s0, tex + float2((i * 0.1) * px,(j * 0.1) * py) * offset_bias);
			}
		}
	blur_ori = blur_ori / 441;
	float4 sharp = ori - blur_ori;
	float4 sharp_mask = sharp * sharp_strength;
	float4 done = ori + sharp_mask;
	return done;
}
As you can see it was based on LumaSharpen shader
Last edit: 9 years 3 months ago by TCPIP.

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

  • Ioxa
  • Topic Author
More
9 years 3 months ago #6 by Ioxa Replied by Ioxa on topic Gaussian Blur / Bloom / Unsharpmask

kurtferro wrote: Game client crash at start in neverwinter online, i think need dx11 version :side:


I've used it with a couple DX11 games and haven't had any issues. I'll test it with some others to check for problems but I don't own Neverwinter so I can't try to reproduce your crash.

Thanks Crosire, I'll fix that. And it seemed like the brightpassfilter was making the final image much darker than it should be and overall lessening the effect. It was most noticeable when using blur, when I would increase GaussStrength the image would get darker. I never saw that happen when using it in Boulotaurs injector so not sure why it's happening now. I left it in there so I could mess with it some more but I was happy with the result when I disabled it.

TCPIP, I could try adding that in as an option. I am curious to see how the performance compares though, it looks like it does a lot of texture fetches to create the blurred image. Going by the line "blur_ori = blur_ori / 441;" I'm gonna guess roughly 441 texture fetches. It looks like it saves a lot of time when creating the sharpened image though. I'll see if I can get it working and try to compare the two.

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

  • TCPIP
More
9 years 3 months ago #7 by TCPIP Replied by TCPIP on topic Gaussian Blur / Bloom / Unsharpmask
It is a working shader, i use it in games. The number of fetches is so high because you need a stronger blur for effects like local contrast, in the gauss shader you do 18 fetches because of the separate horizontal and vertical passes, if you did this in 1 pass it would be 81 so the multipass way should have been faster, but it isn't which is quite strange.

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

  • kurtferro
More
9 years 3 months ago - 9 years 3 months ago #8 by kurtferro Replied by kurtferro on topic Gaussian Blur / Bloom / Unsharpmask
:dry:


i tryed too disabling all effect in sweetfx, but the result does not change

i try with TCPIP code now.

edit: if i paste TCPIP code i get errors in compiling
I do not have the necessary knowledge :angry:

there is some tutorials to understand something?


PS: Neverwinter online is free 2 play
Last edit: 9 years 3 months ago by kurtferro.

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

  • Ioxa
  • Topic Author
More
9 years 3 months ago - 9 years 3 months ago #9 by Ioxa Replied by Ioxa on topic Gaussian Blur / Bloom / Unsharpmask
I'm downloading Neverwinter right now, I'll see if I can figure out the problem.

Are you getting the same result when using it with other games?

The code that TCPIP posted might work as a custom shader in SweetFX, it won't work as is in a .fx file though.

In the meantime you can try using this one . I fixed the part Crosire pointed out. I've also added an option to use bloom along with blur or sharpening, still a work in progress but it's been working fine for me.

EDIT: Just tried Neverwinter and it crashed just like in your video. No clue what the problem may be but I'll see if I can figure it out.
Last edit: 9 years 3 months ago by Ioxa.
The following user(s) said Thank You: kurtferro

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

  • kurtferro
More
9 years 3 months ago #10 by kurtferro Replied by kurtferro on topic Gaussian Blur / Bloom / Unsharpmask
Ok thanks, tomorrow i will try with Insurgency and Arma3, but if you have the same problem others games are relative.

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

  • K-putt
More
9 years 3 months ago #11 by K-putt Replied by K-putt on topic Gaussian Blur / Bloom / Unsharpmask
This is great! Thanks for working on this. The gaussian shader/s are pretty essential if you ask me.

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

  • TCPIP
More
9 years 3 months ago - 9 years 3 months ago #12 by TCPIP Replied by TCPIP on topic Gaussian Blur / Bloom / Unsharpmask
Here are working files based on lumasharpen.h:
www.mediafire.com/download/c2w7ij1xkfvw252/Shaders.zip
Last edit: 9 years 3 months ago by TCPIP.

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

  • kurtferro
More
9 years 3 months ago #13 by kurtferro Replied by kurtferro on topic Gaussian Blur / Bloom / Unsharpmask
What is the difference from your and CeeJay version?

this is only for blur?

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

  • TCPIP
More
9 years 3 months ago #14 by TCPIP Replied by TCPIP on topic Gaussian Blur / Bloom / Unsharpmask
The difference is in method and the result, CeeJay's version sharpens the image, mine is for local contrast.

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

  • Ioxa
  • Topic Author
More
9 years 3 months ago #15 by Ioxa Replied by Ioxa on topic Gaussian Blur / Bloom / Unsharpmask

K-putt wrote: This is great! Thanks for working on this. The gaussian shader/s are pretty essential if you ask me.

No problem! And I agree. I particularly like the bloom and hoping to eventually get the sigma, threshold, and exposure working, but I'm learning as I go so it may be awhile.
The following user(s) said Thank You: Wicked Sick

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

  • Ioxa
  • Topic Author
More
9 years 3 months ago #16 by Ioxa Replied by Ioxa on topic Gaussian Blur / Bloom / Unsharpmask
Updated the OP with a new version. Just added some more options, still a work in progress.

Still causing Neverwinter to crash which means there are probably other games that will have issues. If anyone has any ideas on how to fix this let me know.
The following user(s) said Thank You: Wicked Sick

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

  • Wicked Sick
More
9 years 3 months ago - 9 years 3 months ago #17 by Wicked Sick Replied by Wicked Sick on topic Gaussian Blur / Bloom / Unsharpmask
Thank you for this, Ioxa ^^

EDIT:

Just one question. Isn't there a way to turn this extra effect on and off, right?
Last edit: 9 years 3 months ago by Wicked Sick.

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

  • crosire
More
9 years 3 months ago #18 by crosire Replied by crosire on topic Gaussian Blur / Bloom / Unsharpmask

Wicked Sick wrote: Just one question. Isn't there a way to turn this extra effect on and off, right?

Easy, simply add "toggle = [KEYCODE];" right after "enabled = true;" in the technique line (which btw. would benefit from a nicer name, something like "technique GAUSS ...") and replace "[KEYCODE]" with the hexadecimal code of the desired key taken from here .

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

  • Ioxa
  • Topic Author
More
9 years 3 months ago #19 by Ioxa Replied by Ioxa on topic Gaussian Blur / Bloom / Unsharpmask

Wicked Sick wrote: Thank you for this, Ioxa ^^

EDIT:

Just one question. Isn't there a way to turn this extra effect on and off, right?


No problem Wicked! Is there a specific effect you want to turn on and off or do you want to do what Crosire said and toggle everything in GAUSS on and off?

Also, thats a great idea Crosire, I'll add that in.

On a side note, I've been having some issues with this recently. I tried using it with DOF and it gave everything a red tint. I tried restarting the game and sometimes it would crash and other times it would keep running but with the red tint. Then I tried turning off DOF but the red tint remained. I even reinstalled ReShade + SweetFX, made sure that worked fine, then added GAUSS again, and I STILL got the red screen along with occasional crashing. Using that same GAUSS.fx file in another game worked just fine. I'm going through each effect one by one trying to find the problem but I can't figure out why the problem persisted after reinstalling everything and going back to a previously working configuration.

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

  • crosire
More
9 years 3 months ago #20 by crosire Replied by crosire on topic Gaussian Blur / Bloom / Unsharpmask

Ioxa wrote: On a side note, I've been having some issues with this recently. I tried using it with DOF and it gave everything a red tint. I tried restarting the game and sometimes it would crash and other times it would keep running but with the red tint. Then I tried turning off DOF but the red tint remained. I even reinstalled ReShade + SweetFX, made sure that worked fine, then added GAUSS again, and I STILL got the red screen along with occasional crashing. Using that same GAUSS.fx file in another game worked just fine. I'm going through each effect one by one trying to find the problem but I can't figure out why the problem persisted after reinstalling everything and going back to a previously working configuration.

OpenGL game + you are on NVIDIA, right? Cause then you ran into the NVIDIA driver bug I'm wrapping my head round for a while now already, switches the red and blue color channel under OpenGL in certain circumstances.

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.