Kabloom! GUI bloom control rev3, now in header file

share shaders here
  • Author
  • Message
Offline
*master*
Posts: 117
Joined: 22 Feb 2013, 03:33

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

prod80
Well, neither am I :) I just learned it from MS documentation and experimenting a lot for the last months...
Aha, a smarter person than me I see. You've posted some really impressive stuff around here; I'm inspired.

I misunderstood what your configurable luma code was doing I think, sorry about that. I get it now, it makes sense to add. The color grading code is probably not the best way to do what I'm thinking and it's tough to configure for people who don't understand it, but I had the dumb idea that your luma code was supposed to be doing something similar. Thinking it through more, brightness would be difficult to maintain, wouldn't just need the vectors to sum to 1 or 3, because a higher/lower weight will not necessarily account for a large difference between channel intensities. Nevermind all that.

If you don't mind me asking, do you have a preferred method for changing color balance or individual color saturation? I know a few ways but they're probably not the greatest. Another thing that I have problems with is HDR values, when 0-1 range is expected. I cannot wait until Boris adds the histogram. Don't let me be a nuisance though, I have no shortage of questions.

I am trying to wrap my head around what you're sharing still, but that saturation code is pretty cool, those are some tricks I never thought of. I need to read up some more on this stuff, but thanks very much for the improvements you've shared. This is a big help, I'll be posting an update today. I'll also try out your preset soon and see what that fancy bloom file does, but the screens you have on the nexus are wonderful. Very nice understated look to your preset in my opinion.
PS. How did this thread get 12961 views already... pretty buggy forum :)
I'll take what I can get :lol:

Insomnia
About the ALF, it's not actually about the file that it's in but if it gets incorporated to the bloom texture tex2d(_s3, _v0), which is what xcolorbloom is initialized as. That texture is what my code messes with and if ALF is in that instead of the DOF prepass then it'll be altered. I dunno anything about the new lens effect, this was added while I wasn't paying attention. If it's still going into that texture though, then ALF is probably best to stay in enbeffectprepass for use with my code and probably other bloom methods. I haven't tested my code out with the lens effect, I'll start doing that. I'll also see if I can't find good settings for prod80's file in case someone wants to use it with my code, but that may be doubtful it seems.

Evok99
Don't be afraid to post it somewhere! Maybe someone can help out with what you're trying to do.

Thanks everyone for your constructive input!

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

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

Im in no way smart :)

as for color balance is use almost the same code as that luma code here (actually I don't use that luma code myself, but I should... just lazy to again update the code in my preset)... just it sums to 3.0, as to not mess with luminosity again.

Code: Select all

//GUI element, DN/I it if you want, this is just example
float3 cbalance <
string UIName"Color Balance";
string UIWidget="Color";
> = {0.5, 0.5, 0.5};

float balanceCalc = dot( cbalance.xyz, float3( 0.33333332, 0.33333332, 0.33333332 ));
//or use this, but hardly matters, just / operator costs a bit more performance
//float balanceCalc = dot( cbalance.xyz, 1.0f/3.0f);
//float balanceCalc = dot( cbalance.xyz, 0.33333332f);

float3 adjBalance = cbalance.xyz / balanceCalc.xxx;
Color.xyz *= adjBalance.xyz;
The above code will just adjust each channel by the difference in channel set in GUI... ie GUI set to 200, 200, 200 is the same as 50, 50, 50... but when you put for instance in GUI 110, 114, 121 as balance it will evaluate to:

color.xyz *= float3( 0.95652178, 0.99130439, 1.05217396 );

Which is a more blue tint, just like what you would see in GUI.

...I'm still looking into code in which you can desaturate individual colors... ie, make image B&W but only leave red color. But that is a lot more challenging, or I'm just thinking too complicated.

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

Prod80;

I remember a ENBDev user created such a shader for fun a long time ago, sadly I do not remember the name of this individual or if he released here on the ENBDev forum
or Nexus or even at all. But if it is a "Sin City" shader you're looking for, being able make every color channel black and white and only allowing one color to be rendered
here are some topics with that in mind;

http://www.minecraftforum.net/topic/115 ... ld-shader/

http://www.reddit.com/r/gamedev/comment ... ng_a_hlsl/

http://www.nexusmods.com/skyrim/images/6368/?

http://kodemongki.blogspot.se/2011/06/k ... ample.html

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

MasterEffect 2.

Code: Select all

float luma = dot(color.rgb, float3(0.30f,0.59f,0.11f));
	if(color.r > (color.g + 0.2f) && color.r > (color.b + 0.025f))
	{
		color.rgb = float3(luma, 0, 0)*1.5;
	}
	else
	{
		color.rgb = luma;
	}

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

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

Stayed up all night trying to find some bug that was keeping it from working in ENB, however the code would compile just fine in FX Composer. I found out that I had saved the file with the wrong editor at some point and it changed the character encoding to something unusable, but the code was fine. I almost lost it :lol: Sorry for delays.

Now I have another strange problem though, can anybody help me figure out what's wrong with this switch statement? Once again, it compiles in FX Composer, but doesn't work in ENB. If I comment out the switch statement, and move the blend code out of it, it's fine, but I want the blend code to be GUI switchable somehow.

Code: Select all

	switch( BlendMode )			
	{
		case 1: 			//Addition
			color.rgb +=    xcolorbloom.rgb * EBloomAmount;
		break;
		case 2:				//Opacity
			color.rgb =     lerp( color.rgb, xcolorbloom.rgb, EBloomAmount );
		break;
		case 3:				//Lighten
			color.rgb =     max( color.rgb, xcolorbloom * EBloomAmount );
		break;
		case 4: 			//Lighten/opacity hybrid
			color.rgb =    	max( color.rgb, lerp( color.rgb, xcolorbloom.rgb, EBloomAmount ) );	
		break;
		case 5:				//Brightness-dependent
			color.rgb =    	lerp( xcolorbloom.rgb, color.rgb, 
	                    	saturate( pow( cLuma( saturate( xcolorbloom.rgb ), lumaWeights.rgb ), max( 0.0f,  EBloomAmount * cLuma( saturate( xcolorbloom.rgb ), lumaWeights.rgb ) ) ) ) );
		break;
		case 6: 			//Screen
			color.rgb = 	(1.0f - ( 1.0f - saturate( xcolorbloom.rgb ) ) * ( 1.0f - saturate( xcolorbloom.rgb * EBloomAmount ) ) );
		break;		
		case 7: 			//Screen/opacity hybrid
			color.rgb = 	lerp( color.rgb, ( 1.0f - ( 1.0f - saturate( xcolorbloom.rgb ) ) * ( 1.0f - saturate( xcolorbloom.rgb * EBloomAmount ) ) ), EBloomAmount );
		break;
		case 8:				//Screen/lighten/opacity hybrid
			color.rgb = 	max( color.rgb, lerp( color.rgb, ( 1.0f - ( 1.0f - saturate( xcolorbloom.rgb ) ) * ( 1.0f - saturate( xcolorbloom.rgb * EBloomAmount ) ) ), EBloomAmount ) );
		break;
	}
Did I make some newb mistake? Does ENB not support switch statements? I tried all the different attributes, no change.

Edit: tried it with equivalent if statements, works fine. Weird.

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

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

Just posted a significant refactoring of the code and expanded the features some, it's a little bigger now but I think it is significantly more versatile and should actually be easier to configure and get what you want. Everything is now done in the GUI aside from saving your settings. There are now additional controls and blend modes, however what was there before should still work mostly the same. There should be less artifacts and color shifts with sane settings, however certain combinations will still do strange things, although there should be no reason to use settings like that. I have been surprised to find that a great deal more seems possible with it now and it generally just works and looks better, so I suggest that you use this latest revision. If anyone finds problems with it, please let me know.

Any feedback or bug reports are appreciated, thanks everyone who has shown interest and especially prod80 for the contributions and advice. Cheers all, I need to go refill my coffee!

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

Re: Kabloom! GUI bloom modulation in enbeffect, revision 2

never used switch()

but likely should just be:

Code: Select all

switch( blendmode ) {
case 1:
  color.xyz = ... ;
case 2:
  color.xyz = ... ;
default:
  color.xyz = ... ;
}
similar to selectcase in other languages... not sure why "break;" is there, makes no sense to me. But both switch() and if() do similar things

some feedback, screen blendmode shouldn't be a lerp between those values... well, at least not using the same variable. values above 1.0 don't give strange results? Maybe the interpolator should be EBloomAmount / ( EBloomAmount + 1 )... that way it will never exceed 1.0

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

Re: Kabloom! GUI bloom modulation in enbeffect, revision 2

Thanks; I actually tried it that way first and was thrown compiler errors, break needs to be there. Also used "default:", tried [branch], [flatten], removing cases, using floats instead of ints, removing brackets, adding brackets, moving stuff around, everything. No idea why it wasn't working, according to MSDN switch statements are equivalent to a series of if>then?else if>else statements when compiled. And they were compiling, ENB just didn't want to work.

I had screen blend mode originally being applied using the = operator, I didn't like the result though. I split it into three modes that are basically this:

Code: Select all

color += screncode*EBloomAmount, 

color = lerp(color, screencode, saturate(EBloomAmount) 

color = max(color, lerp(color, screencode, saturate(EBloomAmount))
The lerp did give me weird values, so I added the saturate. Does that not work? Supposed to clamp to (0, 1) range.

Edit: oops, just noticed that somehow that didn't make it in on the web version, updating, derp. Thanks!

Edit 2: Should be fixed now, but if anyone encounters weird stuff with the blend modes please let me know. I probably will switch some out for a few from photoshop sometime soon.
Last edited by Kermles on 16 Jun 2014, 08:54, edited 2 times in total.

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

Re: Kabloom! GUI bloom modulation in enbeffect, revision 2

yea saturate() will do just fine, perhaps better even

@Jawz (forgot)
Yea something like that... if you have photoshop - I wanna code photoshop's color balance as well, which is extremely nice, but works in odd ways... cant find any reference online about that either, oddly. But I have a way by transforming my recoded NVidia sepia shader, I think.

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

Re: Kabloom! GUI bloom modulation for enbeffect.fx, revision

prod80
Maybe this code does something like what you're looking for. It is basically the effect JawZ shared combined with your saturation and color balance code, it can desaturate individual colors. The functions it calls are on the front page of this topic.

Code: Select all

float3 channelSat( in float3 color, in float3 colorBalance, in float3 channelPersistence, in float colorSaturation, in float colorDesaturation )
{
	float 	tLuma =	pLuma( color.rgb );
	float3	tColor =	color.rgb;
	color.rgb *=	sumTo( colorBalance.rgb, 3 );
	color.rgb =	saturation( color.rgb, colorSaturation );
	tColor.rgb =	 lerp( tLuma, max( tLuma, color.rgb ), saturate( channelPersistence.rgb ) );
	color.rgb = lerp( color.rgb, tColor.rgb, saturate( colorDesaturation ) );
	return 	color.rgb;
}
colorDesaturation and colorPersistence together will retain certain colors that are above luma, and you can use the color balance to control which colors fall above luma and their overall strength. You could maybe also do it with the configurable luma code you shared. I can't figure out how to do something like this with fewer controls, but I think this is probably the closest I know how to get at the moment unless I can find code for a curves equivalent.
Post Reply