Welcome, Guest.
Username: Password: Remember me

TOPIC: Gaussian Blur / Bloom / Unsharpmask

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #1

  • Ioxa
  • Ioxa's Avatar
  • Offline
  • Posts: 267
  • Thank you received: 245
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: 1 year 2 months ago by Ioxa. Reason: Update
The administrator has disabled public write access.
The following user(s) said Thank You: crosire, Wicked Sick, kurtferro, Yazame, Insomnia

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #2

  • kurtferro
  • kurtferro's Avatar
  • Offline
  • Posts: 24
  • Thank you received: 1
Nice thanks!
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #3

  • kurtferro
  • kurtferro's Avatar
  • Offline
  • Posts: 24
  • Thank you received: 1
Game client crash at start in neverwinter online, i think need dx11 version :side:
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #4

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2438
  • Thank you received: 1387
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?
Cheers, crosire =)
Last Edit: 1 year 11 months ago by crosire.
The administrator has disabled public write access.
The following user(s) said Thank You: Nekrik

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #5

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
Your inability to make it work doesn't make it broken
Last Edit: 1 year 11 months ago by TCPIP.
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #6

  • Ioxa
  • Ioxa's Avatar
  • Offline
  • Posts: 267
  • Thank you received: 245
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.
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #7

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.
Your inability to make it work doesn't make it broken
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #8

  • kurtferro
  • kurtferro's Avatar
  • Offline
  • Posts: 24
  • Thank you received: 1
: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: 1 year 11 months ago by kurtferro.
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #9

  • Ioxa
  • Ioxa's Avatar
  • Offline
  • Posts: 267
  • Thank you received: 245
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: 1 year 11 months ago by Ioxa.
The administrator has disabled public write access.
The following user(s) said Thank You: kurtferro

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #10

  • kurtferro
  • kurtferro's Avatar
  • Offline
  • Posts: 24
  • Thank you received: 1
Ok thanks, tomorrow i will try with Insurgency and Arma3, but if you have the same problem others games are relative.
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #11

  • K-putt
  • K-putt's Avatar
  • Offline
  • Yes. It's me.
  • Posts: 2
This is great! Thanks for working on this. The gaussian shader/s are pretty essential if you ask me.
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #12

Here are working files based on lumasharpen.h:
www.mediafire.com/download/c2w7ij1xkfvw252/Shaders.zip
Your inability to make it work doesn't make it broken
Last Edit: 1 year 11 months ago by TCPIP.
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #13

  • kurtferro
  • kurtferro's Avatar
  • Offline
  • Posts: 24
  • Thank you received: 1
What is the difference from your and CeeJay version?

this is only for blur?
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #14

The difference is in method and the result, CeeJay's version sharpens the image, mine is for local contrast.
Your inability to make it work doesn't make it broken
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 11 months ago #15

  • Ioxa
  • Ioxa's Avatar
  • Offline
  • Posts: 267
  • Thank you received: 245
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 administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick

Gaussian Blur / Bloom / Unsharpmask 1 year 10 months ago #16

  • Ioxa
  • Ioxa's Avatar
  • Offline
  • Posts: 267
  • Thank you received: 245
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 administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick

Gaussian Blur / Bloom / Unsharpmask 1 year 10 months ago #17

  • Wicked Sick
  • Wicked Sick's Avatar
  • Offline
  • Die young or suffer (Forgive my poor English)
  • Posts: 360
  • Thank you received: 105
Thank you for this, Ioxa ^^

EDIT:

Just one question. Isn't there a way to turn this extra effect on and off, right?
Finding relief somewhere between a tree's branch and its shade.
Last Edit: 1 year 10 months ago by Wicked Sick.
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 10 months ago #18

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2438
  • Thank you received: 1387
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.
Cheers, crosire =)
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 10 months ago #19

  • Ioxa
  • Ioxa's Avatar
  • Offline
  • Posts: 267
  • Thank you received: 245
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.
The administrator has disabled public write access.

Gaussian Blur / Bloom / Unsharpmask 1 year 10 months ago #20

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2438
  • Thank you received: 1387
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.
Cheers, crosire =)
The administrator has disabled public write access.