Académique Documents
Professionnel Documents
Culture Documents
//+++++++++++++++++++++++++++++
//internal parameters, can be modified
//+++++++++++++++++++++++++++++
//float3 EColorFilter=float3(1.0, 0.9, 0.9);
//POSTPROCESS 2
//float EBrightnessV2=2.5;
float EAdaptationMinV2=0.05;
float EAdaptationMaxV2=0.05;//0.125;
float EToneMappingCurveV2=8.0;
float EIntensityContrastV2=1.0;
float EColorSaturationV2=1.0;
float EToneMappingOversaturationV2=180.0;
//POSTPROCESS 3
float EAdaptationMinV3=0.05;
float EAdaptationMaxV3=0.125;
float EToneMappingCurveV3=4.0;
float EToneMappingOversaturationV3=60.0;
//POSTPROCESS 4
float EAdaptationMinV4=0.2;
float EAdaptationMaxV4=0.125;
float EBrightnessCurveV4=0.7;
float EBrightnessMultiplierV4=0.45;
float EBrightnessToneMappingCurveV4=0.5;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Postprocessing 6 by Kermles
#if POSTPROCESS == 6
//DAY
float EBrightnessV6Day = 2.9; //higher
than normal values needed for shadow and brightspot to work correctly
float EIntensityContrastV6Day = 2.2; //very
powerful, be careful of high values
float EColorSaturationV6Day = 2.0; //very powerful,
be careful of high values
float HCompensateSatV6Day = 2.9;
//higher than normal values needed for shadow and brightspot to work
correctly
float EAdaptationMinV6Day = 0.64; //works
differently than usual, be careful with too high/too low values
float EAdaptationMaxV6Day = 0.24; //works
differently than usual, be careful with too high/too low values
float EAdaptationCompensateV6Day = 1.0; //darkening that
happens after adaptation, higher is darker
float EBrightnessMinV6Day = 0.0; //clamps rgb
brightness, range 0-1
float EBrightnessMaxV6Day = 1.0; //clamps rgb
brightness, range 0-1
float EToneMappingCurveV6Day = 8;
float EToneMappingOversaturationV6Day = 2500.0;
float EHSVDesatCurveDay = 1.444444;
//intelligent desaturation, idea credit goes to saltr. higher is less
saturated
///////////////////////////////////Red Green Blue
float3 EMoodColorDay = float3(0.0, 0.0, 0.0);
float EMoodAmountDay = 0.0; //higher is
stronger, range 0-1
float EMoodCurveDay = 4.0; //lower is
stronger, be careful of going under 1.0
/////////////////////////////////////Red Green Blue
float3 EShadowColorDay = float3(0.0, 0.0, 0.55); //unlike other two
color controls, colors shadows/dark spots only. max is 2.55
float EShadowThresholdDay = 1.0; //lower is
stronger, be careful of low values under 0.4
float EShadowCurveDay = 16.0;
//lower is stronger, be careful of low values under 4
//////////////////////////////////////////Red Green Blue
float3 EBrightSpotColorDay = float3(0.0, 0.25, 2.55);
float EBrightSpotThresholdDay = 1.0; //lower is
stronger, be careful of low values under 0.4
float EBrightSpotCurveDay = 24.0; //lower is
stronger, be careful of low values under 4
////////////////////////////////////////////////////////////
#endif
float3 HUEtoRGB(in float H)
{
float R = abs(H * 6.0 - 3.0) - 1.0;
float G = 2.0 - abs(H * 6.0 - 2.0);
float B = 2.0 - abs(H * 6.0 - 4.0);
return saturate(float3(R,G,B));
}
//+++++++++++++++++++++++++++++
//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
//x=generic timer in range 0..1, period of 16777216 ms (4.6 hours), w=frame time
elapsed (in seconds)
float4 Timer;
//x=Width, y=1/Width, z=ScreenScaleY, w=1/ScreenScaleY
float4 ScreenSize;
//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;
//enb version of bloom applied, ignored if original post processing used
float EBloomAmount;
struct VS_OUTPUT_POST
{
float4 vpos : POSITION;
float2 txcoord0 : TEXCOORD0;
};
struct VS_INPUT_POST
{
float3 pos : POSITION;
float2 txcoord0 : TEXCOORD0;
};
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VS_OUTPUT_POST VS_Quad(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;
return OUT;
}
float4 r0;
float4 r1;
float4 r2;
float4 r3;
float4 r4;
float4 r5;
float4 r6;
float4 r7;
float4 r8;
float4 r9;
float4 r10;
float4 r11;
float4 _v0=0.0;
_v0.xy=IN.txcoord0.xy;
r1=tex2D(_s0, _v0.xy); //color
//apply bloom
float4 xcolorbloom=tex2D(_s3, _v0.xy);
xcolorbloom.xyz=xcolorbloom-r1;
xcolorbloom.xyz=max(xcolorbloom, 0.0);
r1.xyz+=xcolorbloom*EBloomAmount;
#ifdef APPLYGAMECOLORCORRECTION
//apply original
// float3 BlurScale;
// float4 Cinematic;
// sampler2D DestBlend;
// float4 Fade;
// float4 HDRParam;
// sampler2D Src0;
// float4 Tint;
// Registers:
// Name Reg Size
// ------------ ----- ----
// HDRParam c1 1
// BlurScale c2 1
// Cinematic c19 1
// Tint c20 1
// Fade c22 1
// Src0 s0 1
// DestBlend s1 1
//todo apply uv offsets to coordinates
r0=tex2D(_s0, IN.txcoord0.xy);//r0=tex2D(_s0, IN.txcoord1.xy);
r1=tex2D(_s1, IN.txcoord0.xy);
r0.w=max(r1.w, _c1.x);
r0.w=1.0/r0.w;
r1.w=r0.w * 0.5;
r0.w=r0.w * _c1.x;
r1.xyz=r1 * r1.w;
r2.xyz=max(r1, 0.0);
r0.xyz=r0.w * r0 + r2.xyz;
r0.w=dot(r0.xyz, float3(0.298999995, 0.587000012, 0.114));
r1.xyz=lerp(r0.w, r0, _c19.x);
r0.xyz=_c20 * r0.w - r1;
r0.xyz=_c20.w * r0 + r1;
r0.xyz=_c19.w * r0 - _c19.y;
r0.xyz=_c19.z * r0 + _c19.y;
r1.xyz=lerp(r0, _c22, _c22.w);
r1.w=_c2.z;
_oC0=r1;
#endif //APPLYGAMECOLORCORRECTION
float4 color=_oC0;
//adaptation in time
float4 Adaptation=tex2D(_s4, 0.5);
float grayadaptation=max(max(Adaptation.x, Adaptation.y), Adaptation.z);
#if (POSTPROCESS==1)
grayadaptation=max(grayadaptation, 0.0);
grayadaptation=min(grayadaptation, 50.0);
color.xyz=color.xyz/
(grayadaptation*EAdaptationMaxV1+EAdaptationMinV1);//*tempF1.x
float3 luma=color.xyz;
float lumamax=300.0;
color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz +
EToneMappingCurveV1);
#endif
#if (POSTPROCESS==2)
grayadaptation=max(grayadaptation, 0.0);
grayadaptation=min(grayadaptation, 50.0);
color.xyz=color.xyz/
(grayadaptation*EAdaptationMaxV2+EAdaptationMinV2);//*tempF1.x
//color.xyz*=EBrightnessV2;
color.xyz+=0.000001;
float3 xncol=normalize(color.xyz);
float3 scl=color.xyz/xncol.xyz;
scl=pow(scl, EIntensityContrastV2);
xncol.xyz=pow(xncol.xyz, EColorSaturationV2);
color.xyz=scl*xncol.xyz;
float lumamax=EToneMappingOversaturationV2;
color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz +
EToneMappingCurveV2);
#endif
#if (POSTPROCESS==3)
grayadaptation=max(grayadaptation, 0.0);
grayadaptation=min(grayadaptation, 50.0);
color.xyz=color.xyz/
(grayadaptation*EAdaptationMaxV3+EAdaptationMinV3);//*tempF1.x
float lumamax=EToneMappingOversaturationV3;
color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz +
EToneMappingCurveV3);
#endif
#if (POSTPROCESS==4)
grayadaptation=max(grayadaptation, 0.0);
grayadaptation=min(grayadaptation, 50.0);
color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV4+EAdaptationMinV4);
color.xyz=max(color.xyz, 0.0);
color.xyz=color.xyz/(color.xyz+EBrightnessToneMappingCurveV4);
#endif
#if (POSTPROCESS==6)
//Postprocessing V6 by Kermles
//hd6/ppv2///////////////////////////////////////////
float EIntensityContrastV6 = EIntensityContrastV6Day;
float EColorSaturationV6 = EColorSaturationV6Day;
float HCompensateSatV6 = HCompensateSatV6Day;
float EToneMappingCurveV6 = EToneMappingCurveV6Day;
float EBrightnessV6 = EBrightnessV6Day;
float EToneMappingOversaturationV6 =
EToneMappingOversaturationV6Day;
float EAdaptationMaxV6 = EAdaptationMaxV6Day;
float EAdaptationMinV6 = EAdaptationMinV6Day;
float lumamax = EToneMappingOversaturationV6;
//kermles////////////////////////////////////////////
float EAdaptationCompensateV6 = EAdaptationCompensateV6Day;
float EBrightnessMaxV6 = EBrightnessMaxV6Day;
float EBrightnessMinV6 = EBrightnessMinV6Day;
float3 moodColor = EMoodColorDay;
float moodAmount = EMoodAmountDay;
float moodCurve = EMoodCurveDay;
float3 shadowColor = EShadowColorDay;
float shadowThreshold = EShadowThresholdDay;
float shadowCurve = EShadowCurveDay;
float3 brightSpotColor = EBrightSpotColorDay;
float brightSpotThreshold = EBrightSpotThresholdDay;
float brightSpotCurve = EBrightSpotCurveDay / 10;
float hsvDesatCurve = EHSVDesatCurveDay;
float PPAmount = 1.0; //controls interpolation
between vanilla colors and PP6 colors
float4 ncolor; //temporary variable for
color adjustments
float avgbr; //temporary variable for
color adjustments
//begin pp code/////////////////////////////////////////////////
//store vanilla colors//////////////////////////////////////////
float4 oldcolor = color;
//convert to hsv////////////////////////////////////////////////
float3 hsvncolor = RGBtoHSV( color.xyz );
hsvncolor.y = max( hsvncolor.y, 0.0 );
hsvncolor.z = max( hsvncolor.z, 0.0 );
//desaturate based on original saturation then resaturate///////
hsvncolor.y = pow( hsvncolor.y, hsvDesatCurve );
hsvncolor.y = saturate(hsvncolor.y * EColorSaturationV6);
//convert back to rgb///////////////////////////////////////////
hsvncolor.y = max( hsvncolor.y, 0.0 );
color.xyz = HSVtoRGB( hsvncolor );
//brightness clamping///////////////////////////////////////////
color.xyz=clamp(color.xyz, EBrightnessMinV6, EBrightnessMaxV6);
//ppv2 modified by kermles//////////////////////////////////////
grayadaptation = clamp(grayadaptation, 0, 50);
color.xyz *= EBrightnessV6;
float3 xncol = normalize(color.xyz);
float3 scl = color.xyz/xncol.xyz;
scl = pow(scl, EIntensityContrastV6);
xncol.xyz = pow(xncol.xyz, EColorSaturationV6);
color.xyz = scl*xncol.xyz;
color.xyz *= HCompensateSatV6;
color.xyz = (color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz +
EToneMappingCurveV6);
//mood coloring/////////////////////////////////////////////////
ncolor = color;
avgbr = (ncolor.x + ncolor.y + ncolor.z)/3;
moodColor.xyz = lerp( moodColor/10, moodColor, saturate( avgbr * 2 ) );
moodColor.xyz = lerp( moodColor, 1, saturate( avgbr - 0.5 ) * 2 );
moodColor.xyz = lerp( ncolor, moodColor, saturate(avgbr / moodCurve));
ncolor.xyz = lerp( ncolor, moodColor, saturate( avgbr * moodAmount ) );
color.xyz = max(0, ncolor);
//shadows///////////////////////////////////////////////////////
ncolor = color;
avgbr = (ncolor.x + ncolor.y + ncolor.z)/3;
shadowColor = lerp(0.1*(2.55-shadowColor), 2.55-shadowColor,
saturate(avgbr*2));
shadowColor = lerp(shadowColor, 1, saturate(avgbr-0.5)*2);
ncolor.xyz = max(ncolor, pow(ncolor, ((1.0+ncolor) *
(shadowColor))*shadowThreshold)/shadowCurve);
color.xyz = saturate(ncolor);
//brightspots///////////////////////////////////////////////////
brightSpotColor = lerp(brightSpotColor/10, brightSpotColor,
saturate(avgbr*2));
brightSpotColor = lerp(brightSpotColor, 1, saturate(avgbr-0.5)*2);
ncolor = 1-color;
ncolor.xyz = max(ncolor, pow(ncolor, ((1.0 + ncolor) *
(brightSpotColor))*brightSpotThreshold)/brightSpotCurve);
color.xyz = saturate(1-ncolor);
//convert to hsv////////////////////////////////////////////////
hsvncolor = RGBtoHSV( color.xyz );
hsvncolor.y = max( hsvncolor.y, 0.0 );
hsvncolor.z = max( hsvncolor.z, 0.0 );
//adaptation/contrast///////////////////////////////////////////
hsvncolor.z = pow(hsvncolor.z,
(grayadaptation*EAdaptationMaxV6+EAdaptationMinV6));
//convert back to rgb///////////////////////////////////////////
hsvncolor.y = max( hsvncolor.y, 0.0 );
hsvncolor.z = max( hsvncolor.z, 0.0 );
color.xyz = HSVtoRGB( hsvncolor );
color.xyz /= grayadaptation*EAdaptationMaxV6+EAdaptationMinV6;
color.xyz /= EAdaptationCompensateV6;
//rerun ppv2////////////////////////////////////////////////////
color.xyz *= EBrightnessV6;
xncol = normalize(color.xyz);
scl = color.xyz/xncol.xyz;
scl = pow(scl, EIntensityContrastV6);
xncol.xyz = pow(xncol.xyz, EColorSaturationV6);
color.xyz = scl*xncol.xyz;
color.xyz *= HCompensateSatV6;
color.xyz = (color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz +
EToneMappingCurveV6);
//lerp between vanilla and pp6 colors///////////////////////////
color = lerp(oldcolor, color, PPAmount);
#endif
_oC0.w=1.0;
_oC0.xyz=color.xyz;
return _oC0;
}
ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
ZEnable=FALSE;
ZWriteEnable=FALSE;
CullMode=NONE;
AlphaTestEnable=FALSE;
AlphaBlendEnable=FALSE;
SRGBWRITEENABLE=FALSE;
}
}