duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

LUT.fx (2634B)


      1 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      2 // ReShade effect file
      3 // visit facebook.com/MartyMcModding for news/updates
      4 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      5 // Marty's LUT shader 1.0 for ReShade 3.0
      6 // Copyright © 2008-2016 Marty McFly
      7 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      8 
      9 #ifndef fLUT_TextureName
     10 	#define fLUT_TextureName "lut.png"
     11 #endif
     12 #ifndef fLUT_TileSizeXY
     13 	#define fLUT_TileSizeXY 32
     14 #endif
     15 #ifndef fLUT_TileAmount
     16 	#define fLUT_TileAmount 32
     17 #endif
     18 
     19 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     20 //
     21 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     22 
     23 #include "ReShadeUI.fxh"
     24 
     25 uniform float fLUT_AmountChroma < __UNIFORM_SLIDER_FLOAT1
     26 	ui_min = 0.00; ui_max = 1.00;
     27 	ui_label = "LUT chroma amount";
     28 	ui_tooltip = "Intensity of color/chroma change of the LUT.";
     29 > = 1.00;
     30 
     31 uniform float fLUT_AmountLuma < __UNIFORM_SLIDER_FLOAT1
     32 	ui_min = 0.00; ui_max = 1.00;
     33 	ui_label = "LUT luma amount";
     34 	ui_tooltip = "Intensity of luma change of the LUT.";
     35 > = 1.00;
     36 
     37 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     38 //
     39 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     40 
     41 #include "ReShade.fxh"
     42 texture texLUT < source = fLUT_TextureName; > { Width = fLUT_TileSizeXY*fLUT_TileAmount; Height = fLUT_TileSizeXY; Format = RGBA8; };
     43 sampler	SamplerLUT 	{ Texture = texLUT; };
     44 
     45 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     46 //
     47 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     48 
     49 void PS_LUT_Apply(float4 vpos : SV_Position, float2 texcoord : TEXCOORD, out float4 res : SV_Target0)
     50 {
     51 	float4 color = tex2D(ReShade::BackBuffer, texcoord.xy);
     52 	float2 texelsize = 1.0 / fLUT_TileSizeXY;
     53 	texelsize.x /= fLUT_TileAmount;
     54 
     55 	float3 lutcoord = float3((color.xy*fLUT_TileSizeXY-color.xy+0.5)*texelsize.xy,color.z*fLUT_TileSizeXY-color.z);
     56 	float lerpfact = frac(lutcoord.z);
     57 	lutcoord.x += (lutcoord.z-lerpfact)*texelsize.y;
     58 
     59 	float3 lutcolor = lerp(tex2D(SamplerLUT, lutcoord.xy).xyz, tex2D(SamplerLUT, float2(lutcoord.x+texelsize.y,lutcoord.y)).xyz,lerpfact);
     60 
     61 	color.xyz = lerp(normalize(color.xyz), normalize(lutcolor.xyz), fLUT_AmountChroma) * 
     62 	            lerp(length(color.xyz),    length(lutcolor.xyz),    fLUT_AmountLuma);
     63 
     64 	res.xyz = color.xyz;
     65 	res.w = 1.0;
     66 }
     67 
     68 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     69 //
     70 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     71 
     72 
     73 technique LUT
     74 {
     75 	pass LUT_Apply
     76 	{
     77 		VertexShader = PostProcessVS;
     78 		PixelShader = PS_LUT_Apply;
     79 	}
     80 }