Welcome, Guest.
Username: Password: Remember me

TOPIC: MassFX Shader Pack

MassFX Shader Pack 7 months 2 weeks ago #1

  • luluco250
  • luluco250's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 51


MassFX is a shader pack designed for simplicity, it is a work-in-progress and currently features the following effects:
  • Fake HDR & Tonemapping:
    Fake HDR can provide eye adaptation and tonemapping can increase the details of an image a lot, a white fix is also available for LDR games.
  • Physically-Based Bloom:
    Inspired by the bloom shaders seen in Unreal 4 and Minecraft SEUS, although technically not 100% physically based it still allows for a very realistic effect.
  • Mouse-Based Motion Blur:
    A simple motion blur effect that is based on mouse velocity and optionally depth as well.
  • Vignette:
    Simple but great, tinting is also available.
  • LUT:
    Color lookup table, color grading based on a texture, allowing for various color filters to be created with GIMP/Photoshop, a small tutorial is included as well as some presets in MassFX\Textures\LUTs.
  • Grain:
    A simple shader that simulates film grain with a pseudo-random grain pattern, it can also be affected by brightness.

I mainly made this pack for learning and because I wanted better bloom than the one offered by the framework (it's still amazing though).
I plan on updating it on a regular basis, so keep an eye out every now and then, previously existing shaders may also be optimized over time.

License: Do Whatever You Want
These shaders are free for anyone looking to re-use them, learn from them or simply include them in their presets/packs, I only ask that you give credit to the author(me, luluco250).


To install simply download the ReShade Framework, take the .dll your game needs (32 or 64 bits), the "MassFX" folder and the MassFX "ReShade.fx" and place them in your game of choice's folder.

Screenshots: Imgur

Download: GitHub

Any feedback is more than welcome!

The name is a play on "Mass Effect", a game I test this pack a lot with and mainly what I tweak it with.

Release log:
Warning: Spoiler! [ Click to expand ]


Planned additions:
Warning: Spoiler! [ Click to expand ]
Last Edit: 7 months 4 days ago by luluco250. Reason: Added a screenshot album
The administrator has disabled public write access.
The following user(s) said Thank You: matsilagi, MaxG3D, jas01, Elimina, Tycholarfero, DeMondo, piltrafus, ThundeR422, WLHM15, SSSekky

Physically-Based Bloom shader 7 months 2 weeks ago #2

  • matsilagi
  • matsilagi's Avatar
  • Offline
  • Posts: 199
  • Thank you received: 54
If you add some lensdirt which gets the same color from Bloom i will certainly use this a lot.

I know it may be hard because of the LDR colorspace but, its worth a try.
Loves to test stuff for no reason.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #3

  • luluco250
  • luluco250's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 51
matsilagi wrote:
If you add some lensdirt which gets the same color from Bloom i will certainly use this a lot.

I know it may be hard because of the LDR colorspace but, its worth a try.

Shouldn't be too hard, I'll look into it.
On gimp I usually do lens dirt using adition or overlay, I will see if the principle remains the same.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #4

  • ShoterXX
  • ShoterXX's Avatar
  • Offline
  • Posts: 53
  • Thank you received: 9
I took a quick look at it, can't you just save position and velocity in the same texture? It saves you from using 2 different textures. And IIRC, RG16F has no improvement over RGBA16F, or atleast, it doesn't seem to.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #5

  • luluco250
  • luluco250's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 51
I took a quick look at it, can't you just save position and velocity in the same texture? It saves you from using 2 different textures. And IIRC, RG16F has no improvement over RGBA16F, or atleast, it doesn't seem to.

I haven't took time to optimize the MBMB code yet, I was occupied with the PBB shader.
But I am looking forward to do so, you do have a point I could create a 2x2 texture where int2(0,0) is the last position and int2(1,1) is the velocity, will take a look at it.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #6

Gaussian and box blur are basically under same performance, and they are both considered as separable filter, using multipass setup can increase performance dramatically.

A more viable approach would be to downscale gradually with gaussian filter, to sample on the texture one scale up, instead of sampling full scale texture every time. Otherwise, local discontinuity may occurred in lower scale textures and causing visual artifacts after blending.

A simple modification to your pixel shader input:
Warning: Spoiler! [ Click to expand ]


btw, UE4 bloom has nothing to do with PBR... it is even in the description: docs.unrealengine.com/latest/INT/Engine/...cts/Bloom/index.html
The effect might not always be physically correct but it can help to hint the relative brightness of objects or add realism to the LDR (low dynamic range) image that is shown on the screen.
Last Edit: 7 months 2 weeks ago by kingeric1992.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #7

  • ShoterXX
  • ShoterXX's Avatar
  • Offline
  • Posts: 53
  • Thank you received: 9
luluco250 wrote:
I took a quick look at it, can't you just save position and velocity in the same texture? It saves you from using 2 different textures. And IIRC, RG16F has no improvement over RGBA16F, or atleast, it doesn't seem to.

I haven't took time to optimize the MBMB code yet, I was occupied with the PBB shader.
But I am looking forward to do so, you do have a point I could create a 2x2 texture where int2(0,0) is the last position and int2(1,1) is the velocity, will take a look at it.

I actualy meant in a single pixel. RG for position and BA for velocity. That way, you don't even sample twice.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #8

luluco250 wrote:
According to the Unreal 4 Elemental tech demo paper, they apply bloom the following way:
If you are referring this:
de45xmedrsdbp.cloudfront.net/Resources/f..._16x9-1248544805.pdf

then what I proposed is pretty much what they're doing. (see slider 61)

@ShoterXX
You can't read & write to a texture in same pass (except on framebuffer), meaning to acquire mouse pos from last frame by reading the texture, then calculate velocity and write to the same texture is impossible, no matter it is under 1x1 float4 format or 1x2 float2.
Last Edit: 7 months 2 weeks ago by kingeric1992.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #9

  • ShoterXX
  • ShoterXX's Avatar
  • Offline
  • Posts: 53
  • Thank you received: 9
I know, forget what I said, I hadn't taken a proper look at the code yet, I thought he only read it and calculated afterwards.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #10

  • luluco250
  • luluco250's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 51
If you are referring this:
de45xmedrsdbp.cloudfront.net/Resources/f..._16x9-1248544805.pdf

then what I proposed is pretty much what they're doing. (see slider 61)
Yeah that's the paper I referenced, like I said I'll apply that now and update the files at dropbox.
btw, UE4 bloom has nothing to do with PBR... it is even in the description: docs.unrealengine.com/latest/INT/Engine/...cts/Bloom/index.html

Yeah it's not 100% physically accurate, but I like that the bloom generated using this method is actually glaring and can be very small to very big, which is kinda how imo bloom looks irl. Maybe I should just rename it to "Next-Gen Bloom"

By the way, how would actually PBR bloom be in code? (I'm not asking for you to write any shader code just the overall idea)
Last Edit: 7 months 2 weeks ago by luluco250.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #11

Gaussian alone is a good approximation. (without stacking them, which is used to compensate the HDR range)
en.wikipedia.org/wiki/Airy_disk

Warning: Spoiler! [ Click to expand ]
Last Edit: 7 months 2 weeks ago by kingeric1992.
The administrator has disabled public write access.
The following user(s) said Thank You: luluco250

Physically-Based Bloom shader 7 months 2 weeks ago #12

  • luluco250
  • luluco250's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 51
kingeric1992 wrote:
Gaussian alone is a good approximation. (without stacking them, which is used to compensate the HDR range)
en.wikipedia.org/wiki/Airy_disk

Warning: Spoiler! [ Click to expand ]

That sounds...complicated, I'll just stick to this for now I guess. It looks good enough for me, but I'm fairly sure the actual Unreal 4 uses some sort of FFT bloom because it has some airy disk distortion near edges.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #13

It is highly unlikely if not impossible, the cost is simply too high and with limited visual gain compares to plain gaussian. totally not worth it.

3dmark11 did use it in their benchmarks:

3dmark11 WhitePaper wrote:
Bloom
The effect is computed by transforming the computed illumination to frequency domain using Fast Fourier
Transform (FFT) and applying bloom filter to the input in that domain. An inverse FFT is then applied to the
filtered image. The forward FFT, applying the bloom filter and inverse FFT are done with the Compute Shader
(CS). The effect is computed in reduced resolution. The input image resolution is halved twice and then
rounded up to nearest power of two. The FFTs are computed using DXGI_FORMAT_R32G32B32A32_FLOAT
textures. A procedurally precomputed texture is used as the bloom filter. The filter combines blur, streak,
lenticular halo and anamorphic flare effects.
s3.amazonaws.com/futuremark-static/downl...rk_11_Whitepaper.pdf

The distortion you've seen could simply be the artifact from under-sampling blur.
Last Edit: 7 months 2 weeks ago by kingeric1992.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #14

  • luluco250
  • luluco250's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 51
Did a major update on the bloom shader, it now properly blurs both while downsampling and upsampling! (I was stuck until I found out you can't use a texture as both I/O, so I implemented two target textures in a "ping-pong" scheme).

It also supports dirt textures now! I've provided a simple one I made on GIMP:


Here's a GIF to showcase the bloom:


I've decided to separate the thresholding into a separate shader because it may be useful for other shaders to have access to such thresholding. It also supports desaturating the threshold.
There's also a debug mode, 0 will display the regular image, 1 will display only the bloom and 2 will display the HDR texture.
Last Edit: 7 months 2 weeks ago by luluco250.
The administrator has disabled public write access.
The following user(s) said Thank You: jas01

Physically-Based Bloom shader 7 months 2 weeks ago #15

  • Iddqd
  • Iddqd's Avatar
  • Offline
  • Posts: 30
  • Thank you received: 22
Very nice bloom, please add tint and threshold.
If i correctly understood your shader just need add to config:

#define PBB_Threshold 0.0
#define PBB_Tint float3(1.0, 1.0, 1.0)
#define PBB_TintLevel 1.0

and to main pass add

bloom = max(0.0,bloom-PBB_Threshold);
bloom *= PBB_Tint* PBB_TintLevel;
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #16

  • Marty McFly
  • Marty McFly's Avatar
  • Offline
  • We've tried nothing and we're all out of ideas!
  • Posts: 610
  • Thank you received: 720
Kingeric, the lensflare paper you posted gets spread everywhere but their solution is not really viable for ReShade. You need a fixed light position point, while all post process lensflares we can do in ReShade transform the existing image to create lensflares of some sort.
On ENB I can do it as I can retrieve the definite XY position of a light source but not on ReShade.
There have been attempts by Ganossa and myself to find the brightest pixel onscreen or large bright areas but that's extremely twerky. To create proper polygonal lensflares, one needs a polygonal blur on the source image.

To further smoothen the result without additional cost, you could modify the texture lookup to avoid the extrema of linear sampling. Here's a good implementation but you can do virtually anything with different curves:

www.shadertoy.com/view/XsfGDn

Also instead of using a lot of textures, might as well use the way it's handled in the SEUS bloom.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #17

  • luluco250
  • luluco250's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 51
There is already threshold, take a look at HDR.fx, I save the threshold into a texture so it can be used not only by bloom but possibly other shaders (such as adaptation) in the future.

As for tint, sure I'll look forward to implement it, although it's not physically realistic at all. I'll add it as a sort of optional thing if I can.

Edit: Marty, you mean by generating the effect in various "mini screens" and then re-upsampling them? That's a bit complex for me but I guess it can't hurt to try.
Last Edit: 7 months 2 weeks ago by luluco250. Reason: avoid double posting
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #18

  • Marty McFly
  • Marty McFly's Avatar
  • Offline
  • We've tried nothing and we're all out of ideas!
  • Posts: 610
  • Thank you received: 720
Yes, that's exactly what I mean. And it's not complex at all, all you have to do is scale the texcoords. Experiment a bit with the numbers so a 0~1 coordinate system ends up in the area where you want it to, like if you want it from XY 0.3 to 0.5, use texcoord.xy / 0.2 - 0.3. * 5.0 is faster than / 0.2 but I wrote it like this to show where the 0.3 to 0.5 interval went. Compiler might optimize this away so write it how you prefer. Adjust X and Y separately to move it around onscreen. I recommend to use a bit of spacing between the single mini versions of the image to avoid blurring between them. Sonic Ether uses some padding around which is a good way to avoid the black area around the mini images to blur into them which would result in a vignette effect.

Oh and one thing with writing back and forth a texture. If you only have a single texture you want to change all the time and don't need HDR colorspace, backup the original color in one texture and use backbuffer., you can read and write to it in one pass. At the very end of your shader, when you need the original color again, just sample the backup texture.

About thresholding: my bloom shader also does it but it's not a good idea as it causes hue shift. Take float3(0.0,0.5,1.0) for example. It's greenish-blue. If you apply a thresholg of 0.5 on it, you get float3(0.0,0.0,0.5) which is pure blue. So the color after is not the same as before. Better threshold on luma by converting the color to HSV and back. For some of my WIP shaders I just use normalize(input+0.0000001) * max(0.0,length(input)-threshold) as crude approximation of luma. length(nullvector) is invalid, hence the very small incrementation.
Last Edit: 7 months 2 weeks ago by Marty McFly.
The administrator has disabled public write access.
The following user(s) said Thank You: luluco250

Physically-Based Bloom shader 7 months 2 weeks ago #19

  • luluco250
  • luluco250's Avatar
  • Offline
  • Posts: 80
  • Thank you received: 51
Thanks a lot for those tips, I'll look into applying them to the shader now!

Edit: Any idea how I could upsample those mini screens? I'm still kinda clueless about that part since I don't have to worry about it with textures.
Last Edit: 7 months 2 weeks ago by luluco250.
The administrator has disabled public write access.

Physically-Based Bloom shader 7 months 2 weeks ago #20

  • Marty McFly
  • Marty McFly's Avatar
  • Offline
  • We've tried nothing and we're all out of ideas!
  • Posts: 610
  • Thank you received: 720
Just revert the formula used before.

texcoord.xy / 0.2 - 0.3

to

(texcoord.xy + 0.3) * 0.2

Here is an effect.txt I used in one of my very old ENB mods:
pastebin.com/beP4CdxB
As I had no way to use a separate texture to do anything, I had to create bloom by putting the R G and B channel on different areas in the alpha channel, blur the alpha channel each pass and maximize it again in the last pass. Code is very old and the ENB version was very limited in features but you get the idea. First pass contains the code to write to alpha and last pass maximizes those again. If you compare the factors I used, the basic idea behind it should be very clear.
The administrator has disabled public write access.
The following user(s) said Thank You: luluco250
  • Page:
  • 1
  • 2