MGE BlurBloomHDRv1

Post » Sun Aug 16, 2009 6:03 pm

I love what this shader does in the night/evening/rain but when it gets clear and sunny everything is blinding bright. For example:

http://yfrog.com/htmgescreenshot27p

Are there any good alternatives or some way to control the brightness?
User avatar
Kahli St Dennis
 
Posts: 3517
Joined: Tue Jun 13, 2006 1:57 am

Post » Mon Aug 17, 2009 12:58 am

I'm not sure if that shader is included in MGE, but I'll check.

What you'll want to do is either decrease the bloom multiplier (less blurry brightness) or clamp the HDR (keep it within a "good" range). How you'd do either depends on the code.
If you know HLSL/ASM, then it shouldn't be an issue. Otherwise, I'll check my copy for that shader and see if I can figure out a good way.
User avatar
Marcia Renton
 
Posts: 3563
Joined: Fri Jan 26, 2007 5:15 am

Post » Sun Aug 16, 2009 8:16 pm

I'm not sure if this is exactly what you are looking for since I haven't used the above shader but you should check out http://www.gamesas.com/bgsforums/index.php?showtopic=1048188 for a great MGE setup.
User avatar
Avril Louise
 
Posts: 3408
Joined: Thu Jun 15, 2006 10:37 pm

Post » Mon Aug 17, 2009 2:22 am

I'm not sure if that shader is included in MGE, but I'll check.

What you'll want to do is either decrease the bloom multiplier (less blurry brightness) or clamp the HDR (keep it within a "good" range). How you'd do either depends on the code.
If you know HLSL/ASM, then it shouldn't be an issue. Otherwise, I'll check my copy for that shader and see if I can figure out a good way.


I don't think that shader is default either. I have the code. I don't actually need to use this shader, just something that accomplishes similer, it just seems to me that every bloom/HDR shader I have tried washes things out WAY to much at times.

EDIT: Maybey tweak:
const static float scale = 4.5f;
//spread of bloom

const static float BloomBoost = 1.50f;
//brightness of bloom

That seems to be the area I want to mess about with. I will tinker around with it in the mean time, but if anyone has any good recommendations that would be awesome as well.

//Polik GroNak Blurry HDR Bloomtexture lastpass;texture lastshader;texture lastframe;sampler s0 = sampler_state { magfilter=linear; AddressU=Clamp; AddressV=Clamp;};sampler s1 = sampler_state { texture = <lastpass>; magfilter=linear; AddressU=Clamp; AddressV=Clamp; };sampler s2 = sampler_state { texture=<lastshader>; magfilter=linear; AddressU=Clamp; AddressV=Clamp;};const static float scale = 4.5f;//spread of bloomconst static float BloomBoost = 1.50f;//brightness of bloomfloat4 HDR = 0;//float4(0.5,0.5,0.5,0.1);const static int kernelsize = 9;const float1 blurPixs[kernelsize] = {	{-4.00},	{-3.00},	{-2.00},	{-1.00},	{0.0},	{1.000},	{2.00},	{3.00},	{4.00}};const float1 blurMags[kernelsize] = {	{0.55},	{0.70},	{0.85},	{0.95},	{1.00},	{0.95},	{0.85},	{0.70},	{0.55}};float2 rcpres;//31float4 DownScaleBloomV( float2 Tex : TEXCOORD0 ) : COLOR0{	float3 color = 0;	float3 color2 = 0;	if (Tex.x < 1.02/scale && Tex.y < 1.02/scale){	for (int i=0; i<kernelsize; i++){		color2 = tex2D( s0, (Tex + float2(0,blurPixs[i])*rcpres)*scale );		color += color2*float3(blurMags[i],blurMags[i],blurMags[i]);	}	color = pow(color, HDR.r*2+1)/(HDR.r*7+1);	}	return float4(BloomBoost*color/kernelsize, 1);}float4 DownScaleBloomH( float2 Tex : TEXCOORD0 ) : COLOR0{	float3 color = 0;	float3 color2 = 0;	if (Tex.x < 1.02/scale && Tex.y < 1.02/scale){	for (int i=0; i<kernelsize; i++){		color2 = tex2D( s1, Tex + float2(blurPixs[i],0)*rcpres );		color += color2*float3(blurMags[i],blurMags[i],blurMags[i]);	}	color = pow(color, HDR.r*2+1)/(HDR.r*7+1);	}	return float4(BloomBoost*color/kernelsize, 1);}float4 UpScaleCombine( float2 Tex : TEXCOORD0 ) : COLOR0{	float3 color = tex2D( s1, Tex/scale );	float3 color2 = tex2D( s2, Tex );	return float4(color*1*clamp((1.5-HDR.r*2)+abs(HDR.a-HDR.r),0,2)+pow(color2*1, 3-clamp((2.4-HDR.r*1.4)-abs(HDR.a-HDR.r),0,2.4)) , 1);}technique T0{	pass p1{PixelShader = compile ps_2_0 DownScaleBloomV();}	pass p1{PixelShader = compile ps_2_0 DownScaleBloomH();}	pass p1{PixelShader = compile ps_2_0 UpScaleCombine();}}

User avatar
Rhysa Hughes
 
Posts: 3438
Joined: Thu Nov 23, 2006 3:00 pm

Post » Sun Aug 16, 2009 11:58 pm

I'm not sure if this is exactly what you are looking for since I haven't used the above shader but you should check out http://www.gamesas.com/bgsforums/index.php?showtopic=1048188 for a great MGE setup.


That thread seems awesome, I will dig around with it as well. Thanks!
User avatar
Cagla Cali
 
Posts: 3431
Joined: Tue Apr 10, 2007 8:36 am

Post » Sun Aug 16, 2009 6:48 pm

I think that may be the first time I've actually seen the code for one of Polik GroNak's bloom shaders. It's... interesting. Questionably implemented. I can understand why it's washing everything out so much, it doesn't even have a proper brightpass.

The code you'll need to change to do a simple fix:
float4 UpScaleCombine( float2 Tex : TEXCOORD0 ) : COLOR0{	float3 color = tex2D( s1, Tex/scale );	float3 color2 = tex2D( s2, Tex );	return float4(color*1*clamp((1.5-HDR.r*2)+abs(HDR.a-HDR.r),0,2)+pow(color2*1, 3-clamp((2.4-HDR.r*1.4)-abs(HDR.a-HDR.r),0,2.4)) , 1);}

to:
float4 UpScaleCombine( float2 Tex : TEXCOORD0 ) : COLOR0{	float3 color = tex2D( s1, Tex/scale ) * 0.25; // THIS IS THE LINE THAT WILL DECREASE THE BLOOM	float3 color2 = tex2D( s2, Tex );	return float4(color*1*clamp((1.5-HDR.r*2)+abs(HDR.a-HDR.r),0,2)+pow(color2*1, 3-clamp((2.4-HDR.r*1.4)-abs(HDR.a-HDR.r),0,2.4)) , 1);}


There's quite a few actual problems/bugs in that code, though. The last line completely misinterprets how HDR functions in MGE and will cause the screen to flicker quite often. The downscale passes will provide a decent radius, but may lead to floating pixels and a few other bugs, and don't implement a bright pass properly, which will cause rampant over-blooming.
User avatar
kirsty williams
 
Posts: 3509
Joined: Sun Oct 08, 2006 5:56 am

Post » Mon Aug 17, 2009 12:54 am

I think that may be the first time I've actually seen the code for one of Polik GroNak's bloom shaders. It's... interesting. Questionably implemented. I can understand why it's washing everything out so much, it doesn't even have a proper brightpass.

The code you'll need to change to do a simple fix:
float4 UpScaleCombine( float2 Tex : TEXCOORD0 ) : COLOR0{	float3 color = tex2D( s1, Tex/scale );	float3 color2 = tex2D( s2, Tex );	return float4(color*1*clamp((1.5-HDR.r*2)+abs(HDR.a-HDR.r),0,2)+pow(color2*1, 3-clamp((2.4-HDR.r*1.4)-abs(HDR.a-HDR.r),0,2.4)) , 1);}

to:
float4 UpScaleCombine( float2 Tex : TEXCOORD0 ) : COLOR0{	float3 color = tex2D( s1, Tex/scale ) * 0.25; // THIS IS THE LINE THAT WILL DECREASE THE BLOOM	float3 color2 = tex2D( s2, Tex );	return float4(color*1*clamp((1.5-HDR.r*2)+abs(HDR.a-HDR.r),0,2)+pow(color2*1, 3-clamp((2.4-HDR.r*1.4)-abs(HDR.a-HDR.r),0,2.4)) , 1);}


There's quite a few actual problems/bugs in that code, though. The last line completely misinterprets how HDR functions in MGE and will cause the screen to flicker quite often. The downscale passes will provide a decent radius, but may lead to floating pixels and a few other bugs, and don't implement a bright pass properly, which will cause rampant over-blooming.


Yikes.... I may need to just use an alternative. =) Thanks for the help! I will try the code change and see how that works.
User avatar
Marie Maillos
 
Posts: 3403
Joined: Wed Mar 21, 2007 4:39 pm


Return to III - Morrowind