[HLSL CODE] Technicolor 3 strip & 2 strip

share shaders here
Post Reply
  • Author
  • Message
Offline
*sensei*
Posts: 372
Joined: 28 Jul 2013, 23:26

[HLSL CODE] Technicolor 3 strip & 2 strip

Hello all.

More code mess.

Technicolor effect 3 strip (2 strip after it). 3 Strip method collides with SSS as both will increase red saturation in skin, so be aware of that.

3Strip a bit more funky.

GUI ELEMENTS

Code: Select all

bool   Section_TC <
	string UIName =  "------Technicolor Effect----";
> = {false};	
bool use_technicolor <
	string UIName="Enable Technicolor";
> = {false};
float3 colStrengthD <
	string UIName="Technicolor Color Strength Day";
	string UIWidget="Color";
> = {0.5, 0.5, 0.5};
float brightnessD <
	string UIName="Technicolor Brightness Day";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {1.0};
float techStrengthD <
	string UIName="Technicolor Amount Day";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {1.0};
float3 colStrengthN <
	string UIName="Technicolor Color Strength Night";
	string UIWidget="Color";
> = {0.5, 0.5, 0.5};
float brightnessN <
	string UIName="Technicolor Brightness Night";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {1.0};
float techStrengthN <
	string UIName="Technicolor Amount Night";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {1.0};
float3 colStrengthI <
	string UIName="Technicolor Color Strength Interior";
	string UIWidget="Color";
> = {0.5, 0.5, 0.5};
float brightnessI <
	string UIName="Technicolor Brightness Interior";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {1.0};
float techStrengthI <
	string UIName="Technicolor Amount Interior";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {1.0};
PIXEL SHADER PART

Code: Select all

////////////////////////////////////
//           Technicolor          //
////////////////////////////////////
//By prod80 [ http://www.nexusmods.com/skyrim/users/6440158/ ]
//Source: Rework of this Final Cut effect: http://pistolerapost.com/tech/2strip.html
if (use_technicolor==true)
{
	float3 colStrength	= lerp( lerp( colStrengthN, colStrengthD, ENightDayFactor ), colStrengthI, EInteriorFactor );
	float brightness	= lerp( lerp( brightnessN, brightnessD, ENightDayFactor ), brightnessI, EInteriorFactor );
	float techStrength	= lerp( lerp( techStrengthN, techStrengthD, ENightDayFactor ), techStrengthI, EInteriorFactor );

	float3 source		= saturate( color.rgb );
	float3 temp 		= 1-source.rgb;
	float3 target 		= temp.grg;
	float3 target2		= temp.bbr;
	float3 temp2 		= source.rgb * target.rgb;
	temp2.rgb			*= target2.rgb;
	
	temp.rgb 			= temp2.rgb * colStrength.rgb;
	temp2.rgb 			*= brightness;
	
	target.rgb 			= temp.grg;
	target2.rgb 		= temp.bbr;
	
	temp.rgb 			= source.rgb - target.rgb;
	temp.rgb 			+= temp2.rgb;
	temp2.rgb 			= temp.rgb - target2.rgb;
	
	color.rgb 			= lerp( source.rgb, temp2.rgb, techStrength );
}
------------------------------------------------------------------------------------------------
2 STRIP
------------------------------------------------------------------------------------------------

GUI ELEMENTS

Code: Select all

bool   Section_TC2 <
	string UIName =  "------Technicolor 2 Strip---";
> = {false};
bool use_t2s <
	string UIName="Enable Technicolor 2 Strip";
> = {false};
float3 rChannelD <
	string UIName="Technicolor 2s Red Day";
	string UIWidget="Color";
> = {1, 0.165, 0};
float3 gChannelD <
	string UIName="Technicolor 2s Green Day";
	string UIWidget="Color";
> = {0.294, 1, 0};
float3 bChannelD <
	string UIName="Technicolor 2s Blue Day";
	string UIWidget="Color";
> = {0.0588, 0.902, 0};
float3 rChannelN <
	string UIName="Technicolor 2s Red Night";
	string UIWidget="Color";
> = {1, 0.165, 0};
float3 gChannelN <
	string UIName="Technicolor 2s Green Night";
	string UIWidget="Color";
> = {0.294, 1, 0};
float3 bChannelN <
	string UIName="Technicolor 2s Blue Night";
	string UIWidget="Color";
> = {0.0588, 0.902, 0};
float3 rChannelI <
	string UIName="Technicolor 2s Red Interior";
	string UIWidget="Color";
> = {1, 0.165, 0};
float3 gChannelI <
	string UIName="Technicolor 2s Green Interior";
	string UIWidget="Color";
> = {0.294, 1, 0};
float3 bChannelI <
	string UIName="Technicolor 2s Blue Interior";
	string UIWidget="Color";
> = {0.0588, 0.902, 0};
float strip2vibD <
	string UIName="Technicolor 2s Saturation Boost Day";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {1.0};
float strip2vibN <
	string UIName="Technicolor 2s Saturation Boost Night";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {1.0};
float strip2vibI <
	string UIName="Technicolor 2s Saturation Boost Interior";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {0.3};
float techStrength2D <
	string UIName="Technicolor 2s Amount Day";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {1.0};
float techStrength2N <
	string UIName="Technicolor 2s Amount Night";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {1.0};
float techStrength2I <
	string UIName="Technicolor 2s Amount Interior";
	string UIWidget="Spinner";
	float UIMin=0.0;
	float UIMax=1.0;
	float UIStep=0.001;
> = {1.0};
HELPER FUNCTIONS (HSL COLOR SPACE CONVERSION) REQUIRED FOR SATURATION MATH

Code: Select all

float3 HUEToRGB(in float H)
{
	float R = abs(H * 6 - 3) - 1;
	float G = 2 - abs(H * 6 - 2);
	float B = 2 - abs(H * 6 - 4);
	return saturate(float3(R,G,B));
}

float Epsilon = 1e-10;

float3 RGBToHCV(in float3 RGB)
{
	// Based on work by Sam Hocevar and Emil Persson
	float4 P = (RGB.g < RGB.b) ? float4(RGB.bg, -1.0, 2.0/3.0) : float4(RGB.gb, 0.0, -1.0/3.0);
	float4 Q = (RGB.r < P.x) ? float4(P.xyw, RGB.r) : float4(RGB.r, P.yzx);
	float C = Q.x - min(Q.w, Q.y);
	float H = abs((Q.w - Q.y) / (6 * C + Epsilon) + Q.z);
	return float3(H, C, Q.x);
}

float3 RGBToHSL(in float3 RGB)
{
	float3 HCV = RGBToHCV(RGB);
	float L = HCV.z - HCV.y * 0.5;
	float S = HCV.y / (1 - abs(L * 2 - 1) + Epsilon);
	return float3(HCV.x, S, L);
}

float3 HSLToRGB(in float3 HSL)
{
	float3 RGB = HUEToRGB(HSL.x);
	float C = (1 - abs(2 * HSL.z - 1)) * HSL.y;
	return (RGB - 0.5) * C + HSL.z;
}
PIXEL SHADER PART

Code: Select all

////////////////////////////////////
//       Technicolor 2-Strip      //
////////////////////////////////////
//By prod80, based on PS Channel Mixer effect [ http://www.nexusmods.com/skyrim/users/6440158/ ]
if ( use_t2s == true ) 
{
	float3 rChannel		= lerp( lerp( rChannelN, rChannelD, ENightDayFactor ), rChannelI, EInteriorFactor );
	float3 gChannel		= lerp( lerp( gChannelN, gChannelD, ENightDayFactor ), gChannelI, EInteriorFactor );
	float3 bChannel		= lerp( lerp( bChannelN, bChannelD, ENightDayFactor ), bChannelI, EInteriorFactor );
	float strip2vib		= lerp( lerp( strip2vibN, strip2vibD, ENightDayFactor ), strip2vibI, EInteriorFactor );
	float techStrength2	= lerp( lerp( techStrength2N, techStrength2D, ENightDayFactor ), techStrength2I, EInteriorFactor );
	
	color.rgb			= saturate( color.rgb );
	float t2stripRed	= dot( color.rgb, rChannel.rgb / dot( rChannel.rgb, 1 ));
	float t2stripGreen	= dot( color.rgb, gChannel.rgb / dot( gChannel.rgb, 1 ));
	float t2stripBlue	= dot( color.rgb, bChannel.rgb / dot( bChannel.rgb, 1 ));
	
	float3 t2scolor		= float3( t2stripRed, t2stripGreen, t2stripBlue );
	
	t2scolor.rgb		= saturate( t2scolor.rgb );
	t2scolor.rgb		= RGBToHSL( t2scolor.rgb );
	t2scolor.g			= t2scolor.g + (( 1.0f - t2scolor.g ) * ( strip2vib * t2scolor.g ));
	t2scolor.rgb		= HSLToRGB( t2scolor.rgb );
	color.rgb			= lerp( color.rgb, t2scolor.rgb, techStrength2 );
}
Last edited by prod80 on 19 Nov 2014, 23:25, edited 4 times in total.

Offline
User avatar
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: [HLSL CODE] Technicolor 3 strip & 2 strip

As always I need dem permissionz to port it to MasterEffect :D

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

Re: [HLSL CODE] Technicolor 3 strip & 2 strip

Use as you see fit.
Technicolor process 4 (3 strip) doesn't work that nice on ENB anyway because collision with other effects that add red, like SSS for skin. I'm working out a more accurate attempt by following tech documents about the process itself... but anyway the technique is so old that it's extremely complicated to duplicate digitally (read: impossible). But lets see if I can get something closer to the current. The same is for 2 strip but it's much more accurate than the 3 strip.

Only thing I would wish for is GUI color picker having a range of -2...2, it's so limited with just a 0...1 range :(

The color tinting effect in the other thread does function very well and fully as it should though, so in case you like feel free to add.

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

Re: [HLSL CODE] Technicolor 3 strip & 2 strip

Some change for 3 Strip process

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

Re: [HLSL CODE] Technicolor 3 strip & 2 strip

Another wonderfully easy and straight forward Technicolor 3 strip code;

Code: Select all

float3 source		= saturate( color.rgb );
float3 target2		= source.grg;
float3 target3		= source.bbr;
float3 substitute	= source.rgb - target2.rgb;
substitute.rgb		= source.rgb + substitute.rgb;
substitute.rgb		= substitute.rgb - target3.rgb;
substitute.rgb		= 1-substitute.rgb;
target2.rgb			= substitute.grg;
target3.rgb			= substitute.bbr;
substitute.rgb		= source.rgb * target2.rgb;
substitute.rgb		*= target3.rgb;
color.rgb			= substitute.rgb;
Reworked code in OP again, should be a heck of a lot better for 3 strip process.

Cheers.
Doesn't get any easier than this.
Source: http://pistolerapost.com/tech/2strip.html (converted the Final Cut code file for 3 strip to HLSL)

Offline
User avatar
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: [HLSL CODE] Technicolor 3 strip & 2 strip

Uhm, what are the values you use for 3 strip? The default ones look ... odd. I triple checked if I made any implementation mistakes but I don't seem to be able to find them.

EDIT: forget that. Should've quadruple checked.

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

Re: [HLSL CODE] Technicolor 3 strip & 2 strip

default is up to you...
but .5's may be too red for ENB use.
3 strip is very saturated coloring, but different from just plainly increasing saturation through the roof
Post Reply