[HLSL code] Original postprocess SSE.ver
Posted: 03 Nov 2016, 14:12
It start with loading textures:
The UV coord of bloom texture has a scaling factor controlled by clamps and a on/off switch.
then, the tonemapper"s"
A additional switch for switching between Reinhard-modified and Filmic ALU by Heji
then do the bloom blending, this part is identical to the old Skyrim.
And the imagespace modifiers, mostly the same as the old Skyrim,
but it has a inactive process with Params01[6].w, seemly supposed to have a gamma ops there.
The UV coord of bloom texture has a scaling factor controlled by clamps and a on/off switch.
Code: Select all
bool scalebloom = (0.5<=Params01[0].x);
float2 scaleduv = clamp(0.0, Params01[6].zy, Params01[6].xy * IN.txcoord0.xy);
float4 color = TextureColor.Sample(Sampler0, IN.txcoord0.xy); //hdr scene color, point sampler
float4 bloom = TextureBloom.Sample(Sampler1, (scalebloom)? IN.txcoord0.xy: scaleduv); //linear sampler
float2 middlegray = TextureAdaptation.Sample(Sampler1, IN.txcoord0.xy).xy; //.x == current, .y == previous
middlegray.y = 1.0; //bypass for enbadaptation format
then, the tonemapper"s"
A additional switch for switching between Reinhard-modified and Filmic ALU by Heji
Code: Select all
bool UseFilmic = (0.5<Params01[2].z);
float WhiteFactor = Params01[2].y;
float original_lum = max( dot(LUM_709, color.rgb), DELTA);
float lum_scaled = original_lum * middlegray.y / middlegray.x;
float lum_filmic = max( lum_scaled - 0.004, 0.0);
lum_filmic = lum_filmic * (lum_filmic * 6.2 + 0.5) / (lum_filmic * (lum_filmic * 6.2 + 1.7) + 0.06);
lum_filmic = pow(lum_filmic, 2.2); //de-gamma-correction for gamma-corrected tonemapper
lum_filmic = lum_filmic * WhiteFactor; //linear scale
float lum_reinhard = lum_scaled * (lum_scaled * WhiteFactor + 1.0) / (lum_scaled + 1.0);
float lum_mapped = (UseFilmic)? lum_filmic : lum_reinhard; //if filmic
color.rgb = color.rgb * lum_mapped / original_lum;
then do the bloom blending, this part is identical to the old Skyrim.
Code: Select all
float bloomfactor = Params01[2].x;
color.rgb = color.rgb + bloom.rgb * saturate(bloomfactor - lum_mapped);
but it has a inactive process with Params01[6].w, seemly supposed to have a gamma ops there.
Code: Select all
float saturation = Params01[3].x; // 0 == gray scale
float contrast = Params01[3].z; // 0 == no contrast
float brightness = Params01[3].w; // intensity
float3 tint_color = Params01[4].rgb; // tint color
float tint_weight = Params01[4].w; // 0 == no tint
float3 fade = Params01[5].xyz; // fade current scene to specified color, mostly used in special effects
float fade_weight = Params01[5].w; // 0 == no fade
color.a = dot(color.rgb, LUM_709);
color.rgb = lerp(color.a, color.rgb, saturation);
color.rgb = lerp(color.rgb, tint_color * color.a , tint_weight);
color.rgb = lerp(middlegray.x, color.rgb * brightness, contrast);
// color.rgb = pow(saturate(color.rgb), Params01[6].w); //this line is unused??
color.rgb = lerp(color.rgb, fade, fade_weight);
color.a = 1.0;