Kabloom! GUI bloom control rev3, now in header file

share shaders here
  • Author
  • Message
Offline
User avatar
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: Simple bloom control code for use in enbeffect.fx, GUI r

@JawZ: I know about Notepad++, use it for my minecraft shadermods. But notepad doesn't have a validating/debugging function, does it?

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

Re: Simple bloom control code for use in enbeffect.fx, GUI r

No not that I can think of, maybe a plugin but it will certainly not be as good as FX Composer for such use.
And I had no way of knowing if you did know about Notepad++ before now, now atleast readers of this thread can find some useful info about it.

Offline
*master*
Posts: 117
Joined: 22 Feb 2013, 03:33

Re: Simple bloom control code for use in enbeffect.fx, GUI r

JawZ
Hey, very happy to be back and see you around still! I hope you've been well, and enjoying school and such. Thanks for putting up with my shenanigans from last time I was in "the seat", and for doing it again! Let me know if there's anything I can help you with.

prod80
Wow, thanks a bunch for these additions! I'll start playing around with them right away, and I'll add them to the code soon.

I am interested to know how people feel about making more additions at this point though; screen blending mode is much more interesting than mine and will get a spot, but I want to know whether they should be added on top of or used to replace mine. Also wanted to know whether bloom colorization is important to anyone. The levels controls is very interesting, but I don't know whether to run that after my bloom code or have a separate mode since it is accomplishing a similar task. I have started a poll for how to add new features to this code, I hope anyone with an opinion will vote as it will help me know how to continue.

Also, about the enbbloom.fx file: All my code is really doing is load whatever that file is spitting out, and run brightness, contrast, saturation, and then optionally shrink the midrange and dark values down so low that it won't be visible anymore, leading to a more tightly controlled bloom. Things like ALF, lens effects, etc will also be modified if they are in the bloom file, but depending on your settings it might be insignificant or even preferable, or not, I don't know.

Advice to people who want ALF to not be touched: there are multiple enbeffectprepass.fx files around that also have ALF, and those won't be touched by my code.

That said, I have tested my code with various different bloom files, all work as expected as far as I could tell, however may need to be configured differently to get what you want. Maybe a better place for my code would be integrated into a enbbloom.fx file to get around this, which I could look into with permission from someone with an enhanced bloom file if there is interest, or anyone else can do if they want. Blend modes could be kept as their own separate module in enbeffect.fx in that case.

Offline
*sensei*
Posts: 372
Joined: 28 Jul 2013, 23:26

Re: Simple bloom control code for use in enbeffect.fx, GUI r

Kremles
I don't get your luma math...

Code: Select all

float Luminance( float3 Color )
{
   return sqrt(dot(pow(Color.xyz, 2), float3(0.241, 0.691, 0.68)));
}
Is basically the same as

Code: Select all

float Luminance( float3 Color )
{
   return dot(Color.xyz, float3(0.2125, 0.7154, 0.0721));
}
Just adjust the float3 to whatever suits your taste as long as it sums to 1.0 (or not, like in yours which makes luma return surpass 1.0, which can create color shifts - but this may be just what you want)... or use if statement to choose different source for luma for different effects which you connect to GUI.

Can also make Luma tweakable from GUI...

Code: Select all

//GUI - color tone visible in GUI will represent which color will be the main source of luma
float3 bLuma <
string UIName="Bloom Luma Tweak";
string UIWidget="Color";
> = {0.5,0.5,0.5};

float Luminance( float3 Color )
{
   float lumaCalc = dot( bLuma.xyz, float3( 1, 1, 1 ));
   float3 Luma = bLuma.xyz / lumaCalc.xxx;  //this will make sure that whatever is selected in GUI will always sum to 1.0
   return dot(Color.xyz, Luma.xyz);
}
Just a thought ;)

PS. you can have a look at my enbbloom.fx file if you want, attached here... it's for ENB binary 254 released after 2 May 2014 and will only work on Skyrim... release date is important because Boris added SamplerDepth for me to do Z testing on bloom so you can use extremely wide bloom ranges without blurring out foreground objects into background and such.

This file doesn't go well with the code you posted here, so for anyone trying it - be aware that you should only use color.xyz += ( xcolorbloom.xyz * EBloomAmount ); inside of enbeffect file... so no Boris default code, or HD6, or this one in the thread. Won't work well, will look off, and will take a while to setup this file... not going to look nice "Out of the box"
Attachments
enbbloom.fx
(28.09 KiB) Downloaded 174 times

Offline
*master*
Posts: 117
Joined: 22 Feb 2013, 03:33

Re: Simple bloom control code for use in enbeffect.fx, GUI r

Oh wow, I missed a 0 in the blue channel. Should be (0.241, 0.691, 0.068). I updated it.

That algorithm came from here http://www.nbdtech.com/Blog/archive/200 ... Color.aspx,

I'm not in the know about this stuff but other people seemed to think it was the best luma algorithm that took human perception into account, better than the W3C weights and the non-perceptual but mathematically correct one for sRGB. No idea if I used it right, or whether it's worth the extra time (probably not for this but I was exploring how to fix a color shift I was getting), so it's great when people check my work, thanks. If it's still wrong to you, I'll revert.

I should be clear if it's not already that I'm not a programmer, I have just read the Microsoft HLSL documentation and been experimenting for a while, no real training or knowledge. I've only messed with pixel shaders in ENB so far, all else is above me at the moment. That said, I greatly appreciate anything anyone can teach me.

Rather than a configurable luma, I'd probably add a color grading shader if I was going to add coloration. Do you have complaints with this code? It's from nvidia's shader library, converted for ENB. RedVector, GreenVector, etc are float3's in the range of 0-1. I assume I can add those same lines you shared to make those sum to 1 to avoid overall brightness shifts?

Code: Select all

float3 texCol = color.xyz;
float rm = dot(texCol.xyz,RedVector);
float gm = dot(texCol.xyz,GreenVector);
float bm = dot(texCol.xyz,BlueVector);
color.xyz= float3(rm, gm, bm);
Also, I had not seen your bloom file before. That's some pretty fancy stuff; really cool. I will install skyrim again and see what I can learn from it, thank you. Do you have a preset using it?

Offline
*sensei*
Posts: 372
Joined: 28 Jul 2013, 23:26

Re: Simple bloom control code for use in enbeffect.fx, GUI r

Kermles wrote:Oh wow, I missed a 0 in the blue channel. Should be (0.241, 0.691, 0.068). I updated it.

That algorithm came from here http://www.nbdtech.com/Blog/archive/200 ... Color.aspx,

I'm not in the know about this stuff but other people seemed to think it was the best luma algorithm that took human perception into account, better than the W3C weights and the non-perceptual but mathematically correct one for sRGB. No idea if I used it right, or whether it's worth the extra time (probably not for this but I was exploring how to fix a color shift I was getting), so it's great when people check my work, thanks. If it's still wrong to you, I'll revert.

I should be clear if it's not already that I'm not a programmer, I have just read the Microsoft HLSL documentation and been experimenting for a while, no real training or knowledge. I've only messed with pixel shaders in ENB so far, all else is above me at the moment. That said, I greatly appreciate anything anyone can teach me.

Rather than a configurable luma, I'd probably add a color grading shader if I was going to add coloration. Do you have complaints with this code? It's from nvidia's shader library, converted for ENB. RedVector, GreenVector, etc are float3's in the range of 0-1. I assume I can add those same lines you shared to make those sum to 1 to avoid overall brightness shifts?

Code: Select all

float3 texCol = color.xyz;
float rm = dot(texCol.xyz,RedVector);
float gm = dot(texCol.xyz,GreenVector);
float bm = dot(texCol.xyz,BlueVector);
color.xyz= float3(rm, gm, bm);
Also, I had not seen your bloom file before. That's some pretty fancy stuff; really cool. I will install skyrim again and see what I can learn from it, thank you. Do you have a preset using it?
Well, neither am I :) I just learned it from MS documentation and experimenting a lot for the last months...

Color shifts generally come from pulling colors out of balance, for instance saturation like color.xyz = lerp( luma, color.xyz, saturation ); with values going over 1.0 on saturation will cause a shift in color... saturation should be based on original saturation of the pixel (difference of lowest value and highest value) SweetFX Vibrance has a good example of that but that code won't work well with saturation levels below 1.0... so it's best to make a small if statement there like:

Code: Select all

//Saturation control
//Saturation range is 0.0 - 2.0
float grey = dot( color.xyz, lumaValue );
float3 desat = lerp( grey, color.xyz, saturation );
float cmin	= min( min( color.x, color.y ), color.z );
float cmax	= max( max( color.x, color.y ), color.z );
float csaturation	= cmax - cmin;
float vibrance = saturation - 1.0f;
float3 sat = lerp( grey, color.xyz, (1.0 + ( vibrance * ( 1.0 - ( sign( vibrance ) * csaturation)))));
color.xyz = (saturation < 1.0) ? desat.xyz : sat.xyz;
That will avoid color shifts due to saturation...

Then there's still color.xyz *= brightness; ... but color shifts other than blowing out highlights aren't that likely.

Have to watch out with lerp function when using values above 1.0 as interpolator, especially when tied into stuff like luma which doesn't have equal values on all channels.

As for the code you posted

Code: Select all

float3 texCol = color.xyz;
float rm = dot(texCol.xyz,RedVector);
float gm = dot(texCol.xyz,GreenVector);
float bm = dot(texCol.xyz,BlueVector);
color.xyz= float3(rm, gm, bm);
Not sure if this will work out fine... haven't tried that yet... too tired now to think it through... but vectors should still sum to 1, but when dealing with pure white, color will shift towards the color of the vectors you use.

Edit: And now I thought it through... pretty sure that code will give you odd output and problems with color shifts... ie when color is white and RGB vectors are 0.3, 0.55, 0.15 then the outcome in color.xyz would be float3(0.9, 1.65, 0.45) ... color is clamped to 0.0 - 1.0 on pixelshader return... so unless you plan to compensate for it later on its pretty useless

Yes I have an ENB uploaded to Nexus... Serenity ENB, but its an ever ongoing WIP :) not too happy with interiors, but exteriors do just fine.

PS. How did this thread get 12961 views already... pretty buggy forum :)
Last edited by prod80 on 31 Jul 2014, 20:41, edited 3 times in total.

Offline
User avatar
*sensei*
Posts: 446
Joined: 17 Apr 2014, 22:12
Location: Schweden

Re: Simple bloom control code for use in enbeffect.fx, GUI r

kermles
Havent read everything... But saw that you named ALF in prepass.... ALF can be used in enblens too and those uses exact same bloom texture as enbbloom. So I suggest people start plopping ALFs in there. :)
_________________
| i5 3350p @3.1 | 16 GB RAM | GTX1060 | Skyrim on SSD |
My Flickr
My Soundcloud
CGI ENB

Offline
User avatar
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: Simple bloom control code for use in enbeffect.fx, GUI r

I don't get this ALF shader, it's so inefficient and ugly...

And this code here...

Code: Select all

float3 texCol = color.xyz;
float rm = dot(texCol.xyz,RedVector);
float gm = dot(texCol.xyz,GreenVector);
float bm = dot(texCol.xyz,BlueVector);
color.xyz= float3(rm, gm, bm);
Wouldn't it shorter with

Code: Select all

color.xyz *= float3(RedVector, GreenVector, BlueVector); 
?

Offline
*blah-blah-blah maniac*
Posts: 552
Joined: 11 Apr 2012, 03:24

Re: Simple bloom control code for use in enbeffect.fx, GUI r

Marty McFly wrote:I don't get this ALF shader, it's so inefficient and ugly...

And this code here...

Code: Select all

float3 texCol = color.xyz;
float rm = dot(texCol.xyz,RedVector);
float gm = dot(texCol.xyz,GreenVector);
float bm = dot(texCol.xyz,BlueVector);
color.xyz= float3(rm, gm, bm);
Wouldn't it shorter with

Code: Select all

color.xyz *= float3(RedVector, GreenVector, BlueVector); 
?
This isn't a slight or criticism. I just think it's funny how coders critique other people's code. I just recently started looking into making a new bloom code for my preset and I dread to think of what the more advanced coders are going to think. It's a total mess lol.
_________________
i5-6600k -- Nvidia GTX 970 -- 16Gb ram @3200mhz

Offline
*sensei*
Posts: 372
Joined: 28 Jul 2013, 23:26

Re: Simple bloom control code for use in enbeffect.fx, GUI r

Wouldn't it shorter with
Code:
color.xyz *= float3(RedVector, GreenVector, BlueVector);
?
no because his example is a dot product, which takes also G & B channel in account on the R channel, for example.
This isn't a slight or criticism. I just think it's funny how coders critique other people's code. I just recently started looking into making a new bloom code for my preset and I dread to think of what the more advanced coders are going to think. It's a total mess lol.
one goal, billion roads to get there. In the end a 10 line and a 10000 line pixel shader do the same thing... adjust RGB color between 0.0 and 1.0 values. It's all about how to get the result you like with as less lines as possible... my files aren't good examples of that because I specifically build them to make a many possible results instead of a single one :) but there are some tricks to work with larger numbers instead of sticking in the 0 - 1 range, or sticking with RGB color space. As long as you know what you're doing you can basically make really whatever you want after a couple of months learning the ropes.
Post Reply