ENBBloom imported from GTA4 to Skyrim, Problem

share shaders here
Post Reply
  • Author
  • Message
Offline
Posts: 86
Joined: 24 Jan 2012, 05:49

ENBBloom imported from GTA4 to Skyrim, Problem

flickering only in 3rd person mode.
is there any difference between these two games' ENB?

code from CRYENB v3

Code: Select all

//+++++++++++++++++++++++++++++
//external parameters, do not modify
//+++++++++++++++++++++++++++++
//keyboard controlled temporary variables (in some versions exists in the config file). Press and hold key 1,2,3...8 together with PageUp or PageDown to modify. By default all set to 1.0
float4	tempF1; //0,1,2,3
float4	tempF2; //5,6,7,8
float4	tempF3; //9,0

float4	BloomParameters;
float4	TempParameters;
float4	ScreenSize;

//x=generic timer in range 0..1, period of 16777216 ms (4.6 hours), w=frame time elapsed (in seconds)
float4	Timer;

//changes in range 0..1, 0 means that night time, 1 - day time
float	ENightDayFactor;
//changes 0 or 1. 0 means that exterior, 1 - interior
float	EInteriorFactor;
//changes in range 0..1, 0 means full quality, 1 lowest dynamic quality (0.33, 0.66 are limits for quality levels)
float	EAdaptiveQualityFactor;

//fov in degrees
float	FieldOfView;

float	BloomRadius3
<
string UIName = "Radius 3";
string UIWidget = "Spinner";
float UIMin = 32;
float UIMax = 64;
> = { 32 };

float	BloomRadius4
<
string UIName = "Radius 4";
string UIWidget = "Spinner";
float UIMin = 32;
float UIMax = 64;
> = { 64 };

float	MixFactor
<
string UIName = "Mix Factor";
string UIWidget = "Spinner";
float UIMin = 0.0;
float UIMax = 1.0;
> = { 0.3 };

float	Smoothness
<
string UIName = "Smoothness";
string UIWidget = "Spinner";
float UIMin = 1;
float UIMax = 10;
> = { 6 };

float	bloomthres
<
string UIName = "Threshold";
string UIWidget = "Spinner";
float UIMin = 0.0;
float UIMax = 1.0;
> = { 1.0 };

float4 LenzParameters = 0.05;

float3 violetpremierepasse = float3(0.81, 0.81, 0.98);
float3 violetsoleil = float3(1.0, 1.0, 1.0);
float3 couleurglobale = float3(0.81, 0.81, 0.98);


struct VS_OUTPUT_POST
{
	float4 vpos  : POSITION;
	float2 txcoord0 : TEXCOORD0;
};
struct VS_INPUT_POST
{
	float3 pos  : POSITION;
	float2 txcoord0 : TEXCOORD0;
};



texture2D texBloom1;
texture2D texBloom2;
texture2D texBloom3;
texture2D texBloom4;
texture2D texBloom5;

sampler2D SamplerBloom1 = sampler_state
{
    Texture   = <texBloom1>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE;//NONE;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

sampler2D SamplerBloom2 = sampler_state
{
    Texture   = <texBloom2>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE;//NONE;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

sampler2D SamplerBloom3 = sampler_state
{
    Texture   = <texBloom3>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE;//NONE;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

sampler2D SamplerBloom4 = sampler_state
{
    Texture   = <texBloom4>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE;//NONE;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

sampler2D SamplerBloom5 = sampler_state
{
    Texture   = <texBloom5>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE;//NONE;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VS_OUTPUT_POST VS_Bloom(VS_INPUT_POST IN)
{
	VS_OUTPUT_POST OUT;

	OUT.vpos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);

	OUT.txcoord0.xy=IN.txcoord0.xy+TempParameters.xy;//1.0/(bloomtexsize*2.0)

	return OUT;
}


//zero pass HQ, input texture is fullscreen
//SamplerBloom1 - fullscreen texture
float4 PS_BloomPrePass(VS_OUTPUT_POST In) : COLOR
{
	float4 bloomuv;

	float4 bloom=tex2D(SamplerBloom1, In.txcoord0);
	const float2 offset[8]=
	{
/*		float2(0.707, 0.707),
		float2(0.707, -0.707),
		float2(-0.707, 0.707),
		float2(-0.707, -0.707),*/
		float2(1.0, 1.0),
		float2(0.0, -1.0),
		float2(-1.0, 1.0),
		float2(-1.0, -1.0),
		float2(0.0, 1.0),
		float2(0.0, -1.0),
		float2(1.0, 0.0),
		float2(-1.0, 0.0)
	};
	float2 screenfact=1.0;
	screenfact.y*=ScreenSize.z;
	screenfact.xy*=TempParameters.z*1.5;
	float4 srcbloom=bloom;
	for (int i=0; i<8; i++)
	{
		bloomuv.xy=offset[i];
		bloomuv.xy=(bloomuv.xy*screenfact.xy)+In.txcoord0.xy;//-(1.0/256.0);//-(1.0/512.0);
		float4 tempbloom=tex2D(SamplerBloom1, bloomuv.xy) - bloomthres;
		tempbloom = max(tempbloom,0.0);
		bloom.xyz+=tempbloom.xyz;
	}
	bloom*=0.175;//0.125;

	bloom.w=1.0;
	return bloom;
}



//first and second passes draw to every texture
//twice, after computations of these two passes,
//result is set as input to next cycle

//first pass
//SamplerBloom1 is result of prepass or second pass from cycle
float4 PS_BloomTexture1(VS_OUTPUT_POST In) : COLOR
{
	float4 bloomuv;
	float4 bloomuv2;

	float4 bloom=tex2D(SamplerBloom1, In.txcoord0);
	const float2 offset[16] =
	{
		float2(-0.94201624, -0.39906216),
		float2(0.94558609, -0.76890725),
		float2(-0.09418410, -0.92938870),
		float2(0.34495938,  0.29387760),
		float2(-0.91588581,  0.45771432),
		float2(-0.81544232, -0.87912464),
		float2(-0.38277543,  0.27676845),
		float2(0.97484398,  0.75648379),
		float2(0.44323325, -0.97511554),
		float2(0.53742981, -0.47373420),
		float2(-0.26496911, -0.41893023),
		float2(0.79197514,  0.19090188),
		float2(-0.24188840,  0.99706507),
		float2(-0.81409955,  0.91437590),
		float2(0.19984126,  0.78641367),
		float2(0.14383161, -0.14100790)
	};
	float2 screenfact = 1.0;
	screenfact.y *= ScreenSize.z;
	screenfact.xy /= ScreenSize.x;
	float4 srcbloom=bloom;
	float step = (TempParameters.w - 0.5);//*1.5;
	screenfact.xy *= step;

	float4 bloomadd=bloom;

	for (int i=0; i<16; i++)
	{
		bloomuv.xy = offset[i] * BloomParameters.x;
		bloomuv.xy = (bloomuv.xy*screenfact.xy) + In.txcoord0.xy;//-(1.0/256.0);//-(1.0/512.0);


		bloomuv2.xy = offset[i] * BloomRadius3;
		bloomuv2.xy = (bloomuv2.xy*screenfact.xy) + In.txcoord0.xy;
		
		//v2
		float4 tempbloom1 = tex2D(SamplerBloom1, bloomuv.xy);
		float4 tempbloom2 = tex2D(SamplerBloom1, bloomuv2.xy);

		float4 tempbloom = lerp(tempbloom1, tempbloom2, MixFactor);
		bloomadd += tempbloom;

		bloom.xyz = max(bloom.xyz, tempbloom.xyz*0.99);
	}
	//v1
	bloomadd *= 0.111111;
	//v0
	bloom.xyz = lerp(bloomadd.xyz, bloom.xyz, BloomParameters.w);

	//float3 violet=float3(0.78, 0.5, 1.0);
	//float3 violet=float3(0.6, 0.4, 1.0);//v2
	float3 violet = violetpremierepasse;//v3


	//float gray=0.104*dot(srcbloom.xyz, 0.333);//max(srcbloom.x, max(srcbloom.y, srcbloom.z));

	float ttt=dot(bloom.xyz, 0.333)-dot(srcbloom.xyz, 0.333);
	ttt=max(ttt, 0.0);
	float gray=BloomParameters.z*ttt;//max(srcbloom.x, max(srcbloom.y, srcbloom.z));
	float mixfact=(gray/(1.0+gray));
	mixfact*=1.0-saturate((TempParameters.w-1.0)*0.3);
	violet.xy+=saturate((TempParameters.w-1.0)*0.3);
	violet.xy=saturate(violet.xy);
	bloom.xyz*=lerp(1.0, violet.xyz, mixfact);

	bloom.w=1.0;
	return bloom;
}



float4 PS_BloomTexture2(VS_OUTPUT_POST In) : COLOR
{
	float4 bloomuv;
	float4 bloomuv2;

	float4 bloom=tex2D(SamplerBloom1, In.txcoord0);
		const float2 offset[16] =
	{
		float2(-0.94201624, -0.39906216),
		float2(0.94558609, -0.76890725),
		float2(-0.09418410, -0.92938870),
		float2(0.34495938,  0.29387760),
		float2(-0.91588581,  0.45771432),
		float2(-0.81544232, -0.87912464),
		float2(-0.38277543,  0.27676845),
		float2(0.97484398,  0.75648379),
		float2(0.44323325, -0.97511554),
		float2(0.53742981, -0.47373420),
		float2(-0.26496911, -0.41893023),
		float2(0.79197514,  0.19090188),
		float2(-0.24188840,  0.99706507),
		float2(-0.81409955,  0.91437590),
		float2(0.19984126,  0.78641367),
		float2(0.14383161, -0.14100790)
	};
	float2 screenfact = 1.0;
	screenfact.y *= ScreenSize.z;
	screenfact.xy /= ScreenSize.x;
	float4 srcbloom=bloom;

	float step=(TempParameters.w-0.5)*1.2;//v3
	screenfact.xy*=step;
	float4 rotvec=0.0;
	sincos(0.19635, rotvec.x, rotvec.y);
	for (int i=0; i<16; i++)
	{

		bloomuv.xy=offset[i];
		bloomuv.xy=reflect(bloomuv.xy, rotvec.xy);
		bloomuv.xy*=BloomParameters.y;
		
		bloomuv.xy=(bloomuv.xy*screenfact.xy)+In.txcoord0.xy;//-(1.0/256.0);//-(1.0/512.0);

		float4 tempbloom1 = tex2D(SamplerBloom1, bloomuv.xy);



		bloomuv2.xy=offset[i];
		bloomuv2.xy=reflect(bloomuv2.xy, rotvec.xy);
		bloomuv2.xy*=BloomRadius4;
		bloomuv2.xy=(bloomuv2.xy*screenfact.xy)+In.txcoord0.xy;//-(1.0/256.0);//-(1.0/512.0);
		float4 tempbloom2 = tex2D(SamplerBloom1, bloomuv2.xy);

		float4 tempbloom = lerp(tempbloom1, tempbloom2, MixFactor);

		bloom+=tempbloom;

	}
	float3 violet = couleurglobale;
	float ttt = dot(bloom.xyz, 0.333) - dot(srcbloom.xyz, 0.333);
	ttt = max(ttt, 0.0);
	float gray = BloomParameters.z*ttt;//max(srcbloom.x, max(srcbloom.y, srcbloom.z));
	float mixfact = (gray / (1.0 + gray));
	mixfact *= 1.0 - saturate((TempParameters.w - 1.0)*0.3);
	violet.xy += saturate((TempParameters.w - 1.0)*0.3);
	violet.xy = saturate(violet.xy);
	bloom.xyz *= lerp(1.0, violet.xyz, mixfact);
	bloom *= 0.05;//0.125;

	bloom.w = 1.0;
	return bloom;
}


float4 PS_BloomPostPass(VS_OUTPUT_POST In) : COLOR
{
	float4 bloom;
	float4 temp;
	//v1
	bloom = tex2D(SamplerBloom1, In.txcoord0);
	bloom += tex2D(SamplerBloom2, In.txcoord0);
	bloom += tex2D(SamplerBloom3, In.txcoord0);
	bloom += tex2D(SamplerBloom4, In.txcoord0);
	bloom += tex2D(SamplerBloom5, In.txcoord0);
	bloom *= 0.2;
	temp = bloom;

	//v2
	float4 bloom1 = tex2D(SamplerBloom1, In.txcoord0);
		float4 bloom2 = tex2D(SamplerBloom2, In.txcoord0);
		float4 bloom3 = tex2D(SamplerBloom3, In.txcoord0);
		float4 bloom4 = tex2D(SamplerBloom4, In.txcoord0);
		float4 bloom5 = tex2D(SamplerBloom5, In.txcoord0);
		bloom = max(bloom1, bloom2);
	bloom = max(bloom, bloom3);
	bloom = max(bloom, bloom4);
	bloom = max(bloom, bloom5);

	bloom = lerp(temp, bloom, 0.3);

	float3 lenz = 0;
		float2 lenzuv = 0.0;

		const float3 offset[18] =
	{
		float3(0.9, 0.01, 4),
		float3(0.7, 0.25, 25),
		float3(0.3, 0.25, 15),

		float3(1, 1.0, 5),

		float3(-0.15, 20, 1),
		float3(-0.3, 20, 1),

		float3(0.5, 0.1, 1),
		float3(0.01, 10, 1),
		float3(20, 0.25, 1),
		float3(1000, 5, 100),

		float3(0.15, 10, 1),
		float3(0.2, 10, 1),
		float3(0.4, 1, 10),

		float3(0.5, -0.5, 2),

		float3(2, 2, -5),

		float3(-5, 0.2, 0.2),

		float3(0.15, 0.5, 20),
		float3(0.4, 1, 10)
	};

	const float3 factors[18] =
	{
		float3(0.5, 0.5, 0),
		float3(0, 0.5, 0),
		float3(0, 0, 0.5),

		float3(0.2, 0.25, 0),

		float3(0.15, 0, 0.0),
		float3(0, 0.0, 0.15),

		float3(0.2, 0.2, 0.05),
		float3(0.25, 0.25, 0.25),
		float3(1, 1, 1),
		float3(0, 0.25, 1),

		float3(0, 1, 0.0),
		float3(0, 0.0, 1),
		float3(10, 0, 0),

		float3(0, 0,0.0),

		float3(0, 0, 1),

		float3(2, 2, 2),
		float3(1, 1, 0.25),
		float3(0.0, 0, 0.2)

	};

	//lenzuv.xy=0.5-lenzuv.xy;
	//distfact=0.5-lenzuv.xy-0.5;

	if (LenzParameters.x>0.00001)
	{
		for (int i = 0; i<18; i++)
		{
			float2 distfact = (In.txcoord0.xy - 0.5);
				lenzuv.xy = offset[i].x*distfact;
			lenzuv.xy *= pow(2.0*length(float2(distfact.x*ScreenSize.z,distfact.y)), offset[i].y);
			lenzuv.xy *= offset[i].z;
			//lenzuv.xy=0.5-lenzuv.xy;//v1
			lenzuv.xy = In.txcoord0.xy - lenzuv.xy;//v2
			float3 templenz = tex2D(SamplerBloom2, lenzuv.xy);
				templenz = templenz*factors[i];
			distfact = (lenzuv.xy - 0.5);
			distfact *= 2.0;
			templenz *= saturate(1.0 - dot(distfact,distfact));//limit by uv 0..1
															   //		templenz=factors[i] * (1.0-dot(distfact,distfact));
			float maxlenz = max(templenz.x, max(templenz.y, templenz.z));
			/*			float3 tempnor=(templenz.xyz/maxlenz);
			tempnor=pow(tempnor, tempF1.z);
			templenz.xyz=tempnor.xyz*maxlenz;
			*/
			float tempnor = (maxlenz / (1.0 + maxlenz));
			tempnor = pow(tempnor, LenzParameters.y);
			templenz.xyz *= tempnor;

			//		templenz*=maxlenz*maxlenz;
			lenz += templenz;
			//		lenz.xyz=max(lenz.xyz, templenz.xyz*0.99);
		}
		lenz.xyz *= 0.25*LenzParameters.x;

		bloom.xyz += lenz.xyz;
		//		bloom.w=dot(lenz.xyz, 0.333);
		bloom.w = max(lenz.xyz, max(lenz.y, lenz.z));
	}

	//bloom =tex2D(SamplerBloom1, In.txcoord0);

	bloom.w = 1.0;
	return bloom;
}

technique BloomPrePass
{
    pass p0
    {
	VertexShader = compile vs_3_0 VS_Bloom();
	PixelShader  = compile ps_3_0 PS_BloomPrePass();

	ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
	CullMode=NONE;
	AlphaBlendEnable = TRUE;
	AlphaTestEnable=FALSE;
	SEPARATEALPHABLENDENABLE=FALSE;
	FogEnable=FALSE;
	SRGBWRITEENABLE=FALSE;
	}
}
technique BloomTexture1
{
    pass p0
    {
	VertexShader = compile vs_3_0 VS_Bloom();
	PixelShader  = compile ps_3_0 PS_BloomTexture1();

	ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
	CullMode=NONE;
	AlphaBlendEnable = TRUE;
	AlphaTestEnable=FALSE;
	SEPARATEALPHABLENDENABLE=FALSE;
	FogEnable=FALSE;
	SRGBWRITEENABLE=FALSE;
	}
}
technique BloomTexture2
{
    pass p0
    {
	VertexShader = compile vs_3_0 VS_Bloom();
	PixelShader  = compile ps_3_0 PS_BloomTexture2();

	ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
	CullMode=NONE;
	AlphaBlendEnable = TRUE;
	AlphaTestEnable=FALSE;
	SEPARATEALPHABLENDENABLE=FALSE;
	FogEnable=FALSE;
	SRGBWRITEENABLE=FALSE;
	}
}
technique BloomPostPass
{
    pass p0
    {
	VertexShader = compile vs_3_0 VS_Bloom();
	PixelShader  = compile ps_3_0 PS_BloomPostPass();

	ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
	CullMode=NONE;
	AlphaBlendEnable=TRUE;
	AlphaTestEnable=FALSE;
	SEPARATEALPHABLENDENABLE=FALSE;
	FogEnable=FALSE;
	SRGBWRITEENABLE=FALSE;
	}
}

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17553
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: ENBBloom imported from GTA4 to Skyrim, Problem

AlphaBlendEnable = TRUE; WTF???
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
Posts: 86
Joined: 24 Jan 2012, 05:49

Re: ENBBloom imported from GTA4 to Skyrim, Problem

ENBSeries wrote:AlphaBlendEnable = TRUE; WTF???
can I ask you another thing?

Seems like this bloom doesn't affect adaptation; of course it affects image, but before adaptation.
I think bloom should be calculated after adaptation done.

I'll appreciate if you teach me any solution for this.

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17553
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: ENBBloom imported from GTA4 to Skyrim, Problem

No. Bloom and adaptation are not linked to each other in real world. Bloom is artifact of not perfectly clear optics, while adaptation is just brightness change by aperture and time based loss of sensitivity in case of eyes.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
*sensei*
Posts: 373
Joined: 07 Mar 2013, 10:14

Re: ENBBloom imported from GTA4 to Skyrim, Problem

In your enbeffect.fx file simply multiply in the result from bloom after adaptation if you so please.

However it will be tricky to get any sort of logical behavior when you do that due to the dynamic nature of adaptation. Also it will in general limit what you can do without visual artifacts... depending on your bloom settings.

Offline
Posts: 66
Joined: 08 May 2014, 00:00

Re: ENBBloom imported from GTA4 to Skyrim, Problem

enbbloom.fx only calculates the blurring of the picture. Bloom is just a blurred version of the picture added on top and is applied in enbeffect.fx. If you want it to be after adaptation, go into the enbeffect.fx and move it ( probably looks like "color.xyz += bloom.xyz * EBloomAmount" ) to after adaptation ( probably looks like "color.xyz = color.xyz / (greyadaptation * EAdaptationMax - EAdaptationMin)" ). It probably won't look good though.

And I don't see any reason to use bloom from gta in skyrim, if there is any difference between the two, the skyrim one will probably be better anyway.
Post Reply