MassFX Shader Pack

  • luluco250
  • Topic Author
More
8 years 6 days ago - 7 years 11 months ago #1 by luluco250 MassFX Shader Pack was created by luluco250


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!


Planned additions:
Warning: Spoiler!
Last edit: 7 years 11 months ago by luluco250. Reason: Added a screenshot album
The following user(s) said Thank You: matsilagi, MaxG3D, jas01, Elimina, Tycholarfero, DeMondo, piltrafus, ThundeR422, WLHM15, SSSekky and 1 other people also said thanks.

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

  • matsilagi
More
8 years 6 days ago #2 by matsilagi Replied by matsilagi on topic Physically-Based Bloom shader
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.

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

  • luluco250
  • Topic Author
More
8 years 6 days ago #3 by luluco250 Replied by luluco250 on topic Physically-Based Bloom shader

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.

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

  • ShoterXX
More
8 years 6 days ago #4 by ShoterXX Replied by ShoterXX on topic Physically-Based Bloom shader
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.

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

  • luluco250
  • Topic Author
More
8 years 6 days ago #5 by luluco250 Replied by luluco250 on topic Physically-Based Bloom shader

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.

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

  • kingeric1992
More
8 years 6 days ago - 8 years 6 days ago #6 by kingeric1992 Replied by kingeric1992 on topic Physically-Based Bloom shader
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!


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: 8 years 6 days ago by kingeric1992.

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

  • ShoterXX
More
8 years 6 days ago #7 by ShoterXX Replied by ShoterXX on topic Physically-Based Bloom shader

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.

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

  • kingeric1992
More
8 years 6 days ago - 8 years 6 days ago #8 by kingeric1992 Replied by kingeric1992 on topic Physically-Based Bloom shader

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: 8 years 6 days ago by kingeric1992.

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

  • ShoterXX
More
8 years 6 days ago #9 by ShoterXX Replied by ShoterXX on topic Physically-Based Bloom shader
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.

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

  • luluco250
  • Topic Author
More
8 years 6 days ago - 8 years 6 days ago #10 by luluco250 Replied by luluco250 on topic Physically-Based Bloom shader

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: 8 years 6 days ago by luluco250.

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

  • kingeric1992
More
8 years 6 days ago - 8 years 6 days ago #11 by kingeric1992 Replied by kingeric1992 on topic Physically-Based Bloom shader
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!
Last edit: 8 years 6 days ago by kingeric1992.
The following user(s) said Thank You: luluco250

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

  • luluco250
  • Topic Author
More
8 years 6 days ago #12 by luluco250 Replied by luluco250 on topic Physically-Based Bloom shader

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!


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.

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

  • kingeric1992
More
8 years 5 days ago - 8 years 5 days ago #13 by kingeric1992 Replied by kingeric1992 on topic Physically-Based Bloom shader
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: 8 years 5 days ago by kingeric1992.

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

  • luluco250
  • Topic Author
More
8 years 3 days ago - 8 years 3 days ago #14 by luluco250 Replied by luluco250 on topic Physically-Based Bloom shader
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: 8 years 3 days ago by luluco250.
The following user(s) said Thank You: jas01

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

  • Iddqd
More
8 years 2 days ago #15 by Iddqd Replied by Iddqd on topic Physically-Based Bloom shader
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;

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

  • Marty McFly
More
8 years 2 days ago #16 by Marty McFly Replied by Marty McFly on topic Physically-Based Bloom shader
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.

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

  • luluco250
  • Topic Author
More
8 years 2 days ago - 8 years 2 days ago #17 by luluco250 Replied by luluco250 on topic Physically-Based Bloom shader
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: 8 years 2 days ago by luluco250. Reason: avoid double posting

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

  • Marty McFly
More
8 years 2 days ago - 8 years 2 days ago #18 by Marty McFly Replied by Marty McFly on topic Physically-Based Bloom shader
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: 8 years 2 days ago by Marty McFly.
The following user(s) said Thank You: luluco250

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

  • luluco250
  • Topic Author
More
8 years 2 days ago - 8 years 2 days ago #19 by luluco250 Replied by luluco250 on topic Physically-Based Bloom shader
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: 8 years 2 days ago by luluco250.

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

  • Marty McFly
More
8 years 2 days ago #20 by Marty McFly Replied by Marty McFly on topic Physically-Based Bloom shader
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 following user(s) said Thank You: luluco250

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.