GSdx: Add temperature setting. (#2989)

Ported libretro's white_point shader to GSdx.
Based on the work described here:
http://www.zombieprototypes.com/?p=210
This commit is contained in:
Dogway 2019-07-10 23:20:00 +01:00 committed by lightningterror
parent d0cb0f59d9
commit 3886d72e0f
2 changed files with 44 additions and 0 deletions

View File

@ -1937,6 +1937,42 @@ float4 ColorGrading(float4 color, float2 texcoord)
} }
#endif #endif
/*------------------------------------------------------------------------------
[COLOR_TEMPERATURE]
------------------------------------------------------------------------------*/
#if COLOR_TEMPERATURE == 1
float4 TemperaturePass(float4 color, float2 texcoord)
{
float temp = clamp(White_Point, 2000.0, 12000.0) / 100.0f;
// all calculations assume a scale of 255. We'll normalize this at the end
float3 wp = float3(255.0,255.0,255.0);
if (White_Point <= 6600.0) {
wp.r = 255.0;
wp.g = - 155.25485562709179 - 0.44596950469579133 * (temp - 2.0) + 104.49216199393888 * log(temp - 2.0);
wp.b = White_Point <= 1900 ? 0.0 : - 254.76935184120902 + 0.8274096064007395 * (temp - 10.0) + 115.67994401066147 * log(temp - 10.0) ;
} else {
wp.r = 351.97690566805693 + 0.114206453784165 * (temp - 55.0) - 40.25366309332127 * log(temp - 55.0);
wp.g = 325.4494125711974 + 0.07943456536662342 * (temp - 50.0) - 28.0852963507957 * log(temp - 50.0);
wp.b = 255.0;
}
// clamp and normalize
wp.rgb = clamp(wp.rgb, 0.0, 255.0) / 255.0;
float3 adjusted = color.rgb * wp;
float3 base_luma = XYZtoYxy(RGBtoXYZ(color.rgb));
float3 adjusted_luma = XYZtoYxy(RGBtoXYZ(adjusted));
adjusted = adjusted_luma + (float3(base_luma.r,0.0,0.0) - float3(adjusted_luma.r,0.0,0.0));
color = float4(XYZtoRGB(YxytoXYZ(adjusted)), 1.0);
return color;
}
#endif
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
[SCANLINES CODE SECTION] [SCANLINES CODE SECTION]
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -2457,6 +2493,10 @@ PS_OUTPUT ps_main(VS_OUTPUT input)
color = ContrastPass(color, texcoord); color = ContrastPass(color, texcoord);
#endif #endif
#if COLOR_TEMPERATURE == 1
color = TemperaturePass(color, texcoord);
#endif
#if VIGNETTE == 1 #if VIGNETTE == 1
color = VignettePass(color, texcoord); color = VignettePass(color, texcoord);
#endif #endif

View File

@ -44,6 +44,7 @@
#define CURVE_CONTRAST 0 //# S-Curve Scene Contrast Enhancement. Locally adjusts contrast using a four-point cubic bezier spline. #define CURVE_CONTRAST 0 //# S-Curve Scene Contrast Enhancement. Locally adjusts contrast using a four-point cubic bezier spline.
#define CEL_SHADING 0 //# PX Cel Shading. Simulates the look of animation/toon. Typically best suited for animated style games. #define CEL_SHADING 0 //# PX Cel Shading. Simulates the look of animation/toon. Typically best suited for animated style games.
#define PAINT_SHADING 0 //# Paint Shading. Creates the effect of a painted scene. Adapted from ENB series, it's pretty performance heavy. #define PAINT_SHADING 0 //# Paint Shading. Creates the effect of a painted scene. Adapted from ENB series, it's pretty performance heavy.
#define COLOR_TEMPERATURE 0 //# White Point Temperature. Changes the temperature of the image from D65 white point reference.
//#[TV EMU TECHNIQUES] [1=ON|0=OFF] #READ: These can all be turned on & off independently of each other. These effects are typically used to simulated older TVs/CRT etc. //#[TV EMU TECHNIQUES] [1=ON|0=OFF] #READ: These can all be turned on & off independently of each other. These effects are typically used to simulated older TVs/CRT etc.
#define LOTTES_CRT 0 //# Timothy Lottes CRT emulation effect. Similar to scanlines, but with more control options. Ported by request. #define LOTTES_CRT 0 //# Timothy Lottes CRT emulation effect. Similar to scanlines, but with more control options. Ported by request.
@ -128,6 +129,9 @@
#define GradingStrength 0.25 //[0.00 to 1.00] The overall max strength of the colour grading effect. Raise to increase, lower to decrease the amount. #define GradingStrength 0.25 //[0.00 to 1.00] The overall max strength of the colour grading effect. Raise to increase, lower to decrease the amount.
#define Correlation 1.00 //[0.10 to 1.00] Correlation between the base colour, and the grading influence. Lower = more of the scene is graded, Higher = less of the scene is graded. #define Correlation 1.00 //[0.10 to 1.00] Correlation between the base colour, and the grading influence. Lower = more of the scene is graded, Higher = less of the scene is graded.
//##[COLOR TEMPERATURE]
#define White_Point 6500.0 //[2000.0 to 12000.0] Temperature value given in Kelvin. A typical CRT has a target white point temperature of D93 (9300K)
//##[CEL SHADING] //##[CEL SHADING]
#define EdgeStrength 1.00 //[0.00 to 4.00] Overall strength of the cel edge outline effect. Affects the overall density. 0.00: no outlines. #define EdgeStrength 1.00 //[0.00 to 4.00] Overall strength of the cel edge outline effect. Affects the overall density. 0.00: no outlines.
#define EdgeFilter 0.75 //[0.10 to 2.00] Filters out fainter cel edges. Use it for balancing the cel edge density. EG: for faces, foliage, etc. #define EdgeFilter 0.75 //[0.10 to 2.00] Filters out fainter cel edges. Use it for balancing the cel edge density. EG: for faces, foliage, etc.