1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333 |
- #ifndef __ACES__
- #define __ACES__
- #include "Common.cginc"
- #define ACEScc_MAX 1.4679964
- #define ACEScc_MIDGRAY 0.4135884
- static const half3x3 sRGB_2_AP0 = {
- 0.4397010, 0.3829780, 0.1773350,
- 0.0897923, 0.8134230, 0.0967616,
- 0.0175440, 0.1115440, 0.8707040
- };
- static const half3x3 sRGB_2_AP1 = {
- 0.61319, 0.33951, 0.04737,
- 0.07021, 0.91634, 0.01345,
- 0.02062, 0.10957, 0.86961
- };
- static const half3x3 AP0_2_sRGB = {
- 2.52169, -1.13413, -0.38756,
- -0.27648, 1.37272, -0.09624,
- -0.01538, -0.15298, 1.16835,
- };
- static const half3x3 AP1_2_sRGB = {
- 1.70505, -0.62179, -0.08326,
- -0.13026, 1.14080, -0.01055,
- -0.02400, -0.12897, 1.15297,
- };
- static const half3x3 AP0_2_AP1_MAT = {
- 1.4514393161, -0.2365107469, -0.2149285693,
- -0.0765537734, 1.1762296998, -0.0996759264,
- 0.0083161484, -0.0060324498, 0.9977163014
- };
- static const half3x3 AP1_2_AP0_MAT = {
- 0.6954522414, 0.1406786965, 0.1638690622,
- 0.0447945634, 0.8596711185, 0.0955343182,
- -0.0055258826, 0.0040252103, 1.0015006723
- };
- static const half3x3 AP1_2_XYZ_MAT = {
- 0.6624541811, 0.1340042065, 0.1561876870,
- 0.2722287168, 0.6740817658, 0.0536895174,
- -0.0055746495, 0.0040607335, 1.0103391003
- };
- static const half3x3 XYZ_2_AP1_MAT = {
- 1.6410233797, -0.3248032942, -0.2364246952,
- -0.6636628587, 1.6153315917, 0.0167563477,
- 0.0117218943, -0.0082844420, 0.9883948585
- };
- static const half3x3 XYZ_2_REC709_MAT = {
- 3.2409699419, -1.5373831776, -0.4986107603,
- -0.9692436363, 1.8759675015, 0.0415550574,
- 0.0556300797, -0.2039769589, 1.0569715142
- };
- static const half3x3 XYZ_2_REC2020_MAT = {
- 1.7166511880, -0.3556707838, -0.2533662814,
- -0.6666843518, 1.6164812366, 0.0157685458,
- 0.0176398574, -0.0427706133, 0.9421031212
- };
- static const half3x3 XYZ_2_DCIP3_MAT = {
- 2.7253940305, -1.0180030062, -0.4401631952,
- -0.7951680258, 1.6897320548, 0.0226471906,
- 0.0412418914, -0.0876390192, 1.1009293786
- };
- static const half3 AP1_RGB2Y = half3(0.272229, 0.674082, 0.0536895);
- static const half3x3 RRT_SAT_MAT = {
- 0.9708890, 0.0269633, 0.00214758,
- 0.0108892, 0.9869630, 0.00214758,
- 0.0108892, 0.0269633, 0.96214800
- };
- static const half3x3 ODT_SAT_MAT = {
- 0.949056, 0.0471857, 0.00375827,
- 0.019056, 0.9771860, 0.00375827,
- 0.019056, 0.0471857, 0.93375800
- };
- static const half3x3 D60_2_D65_CAT = {
- 0.98722400, -0.00611327, 0.0159533,
- -0.00759836, 1.00186000, 0.0053302,
- 0.00307257, -0.00509595, 1.0816800
- };
- half3 unity_to_ACES(half3 x)
- {
- x = mul(sRGB_2_AP0, x);
- return x;
- }
- half3 ACES_to_unity(half3 x)
- {
- x = mul(AP0_2_sRGB, x);
- return x;
- }
- half3 unity_to_ACEScg(half3 x)
- {
- x = mul(sRGB_2_AP1, x);
- return x;
- }
- half3 ACEScg_to_unity(half3 x)
- {
- x = mul(AP1_2_sRGB, x);
- return x;
- }
- half ACES_to_ACEScc(half x)
- {
- if (x <= 0.0)
- return -0.35828683;
- else if (x < pow(2.0, -15.0))
- return (log2(pow(2.0, -16.0) + x * 0.5) + 9.72) / 17.52;
- else
- return (log2(x) + 9.72) / 17.52;
- }
- half3 ACES_to_ACEScc(half3 x)
- {
- x = clamp(x, 0.0, HALF_MAX);
-
- return (x < 0.00003051757) ? (log2(0.00001525878 + x * 0.5) + 9.72) / 17.52 : (log2(x) + 9.72) / 17.52;
-
- }
- half ACEScc_to_ACES(half x)
- {
-
- if (x < -0.3013698630)
- return (pow(2.0, x * 17.52 - 9.72) - pow(2.0, -16.0)) * 2.0;
- else if (x < (log2(HALF_MAX) + 9.72) / 17.52)
- return pow(2.0, x * 17.52 - 9.72);
- else
- return HALF_MAX;
- }
- half3 ACEScc_to_ACES(half3 x)
- {
- return half3(
- ACEScc_to_ACES(x.r),
- ACEScc_to_ACES(x.g),
- ACEScc_to_ACES(x.b)
- );
- }
- half3 ACES_to_ACEScg(half3 x)
- {
- return mul(AP0_2_AP1_MAT, x);
- }
- half3 ACEScg_to_ACES(half3 x)
- {
- return mul(AP1_2_AP0_MAT, x);
- }
- half rgb_2_saturation(half3 rgb)
- {
- const half TINY = 1e-10;
- half mi = Min3(rgb);
- half ma = Max3(rgb);
- return (max(ma, TINY) - max(mi, TINY)) / max(ma, 1e-2);
- }
- half rgb_2_yc(half3 rgb)
- {
- const half ycRadiusWeight = 1.75;
-
-
-
-
-
-
-
-
-
-
-
-
- half r = rgb.x;
- half g = rgb.y;
- half b = rgb.z;
- half chroma = sqrt(b * (b - g) + g * (g - r) + r * (r - b));
- return (b + g + r + ycRadiusWeight * chroma) / 3.0;
- }
- half rgb_2_hue(half3 rgb)
- {
-
-
- half hue;
- if (rgb.x == rgb.y && rgb.y == rgb.z)
- hue = 0.0;
- else
- hue = (180.0 / UNITY_PI) * atan2(sqrt(3.0) * (rgb.y - rgb.z), 2.0 * rgb.x - rgb.y - rgb.z);
- if (hue < 0.0) hue = hue + 360.0;
- return hue;
- }
- half center_hue(half hue, half centerH)
- {
- half hueCentered = hue - centerH;
- if (hueCentered < -180.0) hueCentered = hueCentered + 360.0;
- else if (hueCentered > 180.0) hueCentered = hueCentered - 360.0;
- return hueCentered;
- }
- half sigmoid_shaper(half x)
- {
-
- half t = max(1.0 - abs(x / 2.0), 0.0);
- half y = 1.0 + sign(x) * (1.0 - t * t);
- return y / 2.0;
- }
- half glow_fwd(half ycIn, half glowGainIn, half glowMid)
- {
- half glowGainOut;
- if (ycIn <= 2.0 / 3.0 * glowMid)
- glowGainOut = glowGainIn;
- else if (ycIn >= 2.0 * glowMid)
- glowGainOut = 0.0;
- else
- glowGainOut = glowGainIn * (glowMid / ycIn - 1.0 / 2.0);
- return glowGainOut;
- }
- static const half3x3 M = {
- 0.5, -1.0, 0.5,
- -1.0, 1.0, 0.0,
- 0.5, 0.5, 0.0
- };
- half segmented_spline_c5_fwd(half x)
- {
- const half coefsLow[6] = { -4.0000000000, -4.0000000000, -3.1573765773, -0.4852499958, 1.8477324706, 1.8477324706 };
- const half coefsHigh[6] = { -0.7185482425, 2.0810307172, 3.6681241237, 4.0000000000, 4.0000000000, 4.0000000000 };
- const half2 minPoint = half2(0.18 * exp2(-15.0), 0.0001);
- const half2 midPoint = half2(0.18, 0.48);
- const half2 maxPoint = half2(0.18 * exp2(18.0), 10000.0);
- const half slopeLow = 0.0;
- const half slopeHigh = 0.0;
- const int N_KNOTS_LOW = 4;
- const int N_KNOTS_HIGH = 4;
-
-
- float xCheck = x;
- if (xCheck <= 0.0) xCheck = 0.00006103515;
- half logx = log10(xCheck);
- half logy;
- if (logx <= log10(minPoint.x))
- {
- logy = logx * slopeLow + (log10(minPoint.y) - slopeLow * log10(minPoint.x));
- }
- else if ((logx > log10(minPoint.x)) && (logx < log10(midPoint.x)))
- {
- half knot_coord = (N_KNOTS_LOW - 1) * (logx - log10(minPoint.x)) / (log10(midPoint.x) - log10(minPoint.x));
- int j = knot_coord;
- half t = knot_coord - j;
- half3 cf = half3(coefsLow[j], coefsLow[j + 1], coefsLow[j + 2]);
- half3 monomials = half3(t * t, t, 1.0);
- logy = dot(monomials, mul(M, cf));
- }
- else if ((logx >= log10(midPoint.x)) && (logx < log10(maxPoint.x)))
- {
- half knot_coord = (N_KNOTS_HIGH - 1) * (logx - log10(midPoint.x)) / (log10(maxPoint.x) - log10(midPoint.x));
- int j = knot_coord;
- half t = knot_coord - j;
- half3 cf = half3(coefsHigh[j], coefsHigh[j + 1], coefsHigh[j + 2]);
- half3 monomials = half3(t * t, t, 1.0);
- logy = dot(monomials, mul(M, cf));
- }
- else
- {
- logy = logx * slopeHigh + (log10(maxPoint.y) - slopeHigh * log10(maxPoint.x));
- }
- return pow(10.0, logy);
- }
- half segmented_spline_c9_fwd(half x)
- {
- const half coefsLow[10] = { -1.6989700043, -1.6989700043, -1.4779000000, -1.2291000000, -0.8648000000, -0.4480000000, 0.0051800000, 0.4511080334, 0.9113744414, 0.9113744414 };
- const half coefsHigh[10] = { 0.5154386965, 0.8470437783, 1.1358000000, 1.3802000000, 1.5197000000, 1.5985000000, 1.6467000000, 1.6746091357, 1.6878733390, 1.6878733390 };
- const half2 minPoint = half2(segmented_spline_c5_fwd(0.18 * exp2(-6.5)), 0.02);
- const half2 midPoint = half2(segmented_spline_c5_fwd(0.18), 4.8);
- const half2 maxPoint = half2(segmented_spline_c5_fwd(0.18 * exp2(6.5)), 48.0);
- const half slopeLow = 0.0;
- const half slopeHigh = 0.04;
- const int N_KNOTS_LOW = 8;
- const int N_KNOTS_HIGH = 8;
-
-
- half xCheck = x;
- if (xCheck <= 0.0) xCheck = 1e-4;
- half logx = log10(xCheck);
- half logy;
- if (logx <= log10(minPoint.x))
- {
- logy = logx * slopeLow + (log10(minPoint.y) - slopeLow * log10(minPoint.x));
- }
- else if ((logx > log10(minPoint.x)) && (logx < log10(midPoint.x)))
- {
- half knot_coord = (N_KNOTS_LOW - 1) * (logx - log10(minPoint.x)) / (log10(midPoint.x) - log10(minPoint.x));
- int j = knot_coord;
- half t = knot_coord - j;
- half3 cf = half3(coefsLow[j], coefsLow[j + 1], coefsLow[j + 2]);
- half3 monomials = half3(t * t, t, 1.0);
- logy = dot(monomials, mul(M, cf));
- }
- else if ((logx >= log10(midPoint.x)) && (logx < log10(maxPoint.x)))
- {
- half knot_coord = (N_KNOTS_HIGH - 1) * (logx - log10(midPoint.x)) / (log10(maxPoint.x) - log10(midPoint.x));
- int j = knot_coord;
- half t = knot_coord - j;
- half3 cf = half3(coefsHigh[j], coefsHigh[j + 1], coefsHigh[j + 2]);
- half3 monomials = half3(t * t, t, 1.0);
- logy = dot(monomials, mul(M, cf));
- }
- else
- {
- logy = logx * slopeHigh + (log10(maxPoint.y) - slopeHigh * log10(maxPoint.x));
- }
- return pow(10.0, logy);
- }
- static const half RRT_GLOW_GAIN = 0.05;
- static const half RRT_GLOW_MID = 0.08;
- static const half RRT_RED_SCALE = 0.82;
- static const half RRT_RED_PIVOT = 0.03;
- static const half RRT_RED_HUE = 0.0;
- static const half RRT_RED_WIDTH = 135.0;
- static const half RRT_SAT_FACTOR = 0.96;
- half3 RRT(half3 aces)
- {
-
- half saturation = rgb_2_saturation(aces);
- half ycIn = rgb_2_yc(aces);
- half s = sigmoid_shaper((saturation - 0.4) / 0.2);
- half addedGlow = 1.0 + glow_fwd(ycIn, RRT_GLOW_GAIN * s, RRT_GLOW_MID);
- aces *= addedGlow;
-
- half hue = rgb_2_hue(aces);
- half centeredHue = center_hue(hue, RRT_RED_HUE);
- half hueWeight;
- {
-
- hueWeight = smoothstep(0.0, 1.0, 1.0 - abs(2.0 * centeredHue / RRT_RED_WIDTH));
- hueWeight *= hueWeight;
- }
- aces.r += hueWeight * saturation * (RRT_RED_PIVOT - aces.r) * (1.0 - RRT_RED_SCALE);
-
- aces = clamp(aces, 0.0, HALF_MAX);
- half3 rgbPre = mul(AP0_2_AP1_MAT, aces);
- rgbPre = clamp(rgbPre, 0, HALF_MAX);
-
-
- rgbPre = lerp(dot(rgbPre, AP1_RGB2Y).xxx, rgbPre, RRT_SAT_FACTOR.xxx);
-
- half3 rgbPost;
- rgbPost.x = segmented_spline_c5_fwd(rgbPre.x);
- rgbPost.y = segmented_spline_c5_fwd(rgbPre.y);
- rgbPost.z = segmented_spline_c5_fwd(rgbPre.z);
-
- half3 rgbOces = mul(AP1_2_AP0_MAT, rgbPost);
- return rgbOces;
- }
- half3 Y_2_linCV(half3 Y, half Ymax, half Ymin)
- {
- return (Y - Ymin) / (Ymax - Ymin);
- }
- half3 XYZ_2_xyY(half3 XYZ)
- {
- half divisor = max(dot(XYZ, (1.0).xxx), 1e-4);
- return half3(XYZ.xy / divisor, XYZ.y);
- }
- half3 xyY_2_XYZ(half3 xyY)
- {
- half m = xyY.z / max(xyY.y, 1e-4);
- half3 XYZ = half3(xyY.xz, (1.0 - xyY.x - xyY.y));
- XYZ.xz *= m;
- return XYZ;
- }
- static const half DIM_SURROUND_GAMMA = 0.9811;
- half3 darkSurround_to_dimSurround(half3 linearCV)
- {
- half3 XYZ = mul(AP1_2_XYZ_MAT, linearCV);
- half3 xyY = XYZ_2_xyY(XYZ);
- xyY.z = clamp(xyY.z, 0.0, HALF_MAX);
- xyY.z = pow(xyY.z, DIM_SURROUND_GAMMA);
- XYZ = xyY_2_XYZ(xyY);
- return mul(XYZ_2_AP1_MAT, XYZ);
- }
- half moncurve_r(half y, half gamma, half offs)
- {
-
- half x;
- const half yb = pow(offs * gamma / ((gamma - 1.0) * (1.0 + offs)), gamma);
- const half rs = pow((gamma - 1.0) / offs, gamma - 1.0) * pow((1.0 + offs) / gamma, gamma);
- if (y >= yb)
- x = (1.0 + offs) * pow(y, 1.0 / gamma) - offs;
- else
- x = y * rs;
- return x;
- }
- half bt1886_r(half L, half gamma, half Lw, half Lb)
- {
-
-
- half a = pow(pow(Lw, 1.0 / gamma) - pow(Lb, 1.0 / gamma), gamma);
- half b = pow(Lb, 1.0 / gamma) / (pow(Lw, 1.0 / gamma) - pow(Lb, 1.0 / gamma));
- half V = pow(max(L / a, 0.0), 1.0 / gamma) - b;
- return V;
- }
- half roll_white_fwd(
- half x,
- half new_wht,
- half width
- )
- {
- const half x0 = -1.0;
- const half x1 = x0 + width;
- const half y0 = -new_wht;
- const half y1 = x1;
- const half m1 = (x1 - x0);
- const half a = y0 - y1 + m1;
- const half b = 2.0 * (y1 - y0) - m1;
- const half c = y0;
- const half t = (-x - x0) / (x1 - x0);
- half o = 0.0;
- if (t < 0.0)
- o = -(t * b + c);
- else if (t > 1.0)
- o = x;
- else
- o = -((t * a + b) * t + c);
- return o;
- }
- half3 linear_to_sRGB(half3 x)
- {
- return (x <= 0.0031308 ? (x * 12.9232102) : 1.055 * pow(x, 1.0 / 2.4) - 0.055);
- }
- half3 linear_to_bt1886(half3 x, half gamma, half Lw, half Lb)
- {
-
-
- return pow(max(x, 0.0), 1.0 / 2.4);
-
-
- half invgamma = 1.0 / gamma;
- half p_Lw = pow(Lw, invgamma);
- half p_Lb = pow(Lb, invgamma);
- half3 a = pow(p_Lw - p_Lb, gamma).xxx;
- half3 b = (p_Lb / p_Lw - p_Lb).xxx;
- half3 V = pow(max(x / a, 0.0), invgamma.xxx) - b;
- return V;
- }
- #if defined(CUSTOM_WHITE_POINT)
- half CINEMA_WHITE;
- half CINEMA_BLACK;
- #else
- static const half CINEMA_WHITE = 48.0;
- static const half CINEMA_BLACK = CINEMA_WHITE / 2400.0;
- #endif
- static const half ODT_SAT_FACTOR = 0.93;
- half3 ODT_RGBmonitor_100nits_dim(half3 oces)
- {
-
- half3 rgbPre = mul(AP0_2_AP1_MAT, oces);
-
- half3 rgbPost;
- rgbPost.x = segmented_spline_c9_fwd(rgbPre.x);
- rgbPost.y = segmented_spline_c9_fwd(rgbPre.y);
- rgbPost.z = segmented_spline_c9_fwd(rgbPre.z);
-
- half3 linearCV = Y_2_linCV(rgbPost, CINEMA_WHITE, CINEMA_BLACK);
-
- linearCV = darkSurround_to_dimSurround(linearCV);
-
-
- linearCV = lerp(dot(linearCV, AP1_RGB2Y).xxx, linearCV, ODT_SAT_FACTOR.xxx);
-
-
- half3 XYZ = mul(AP1_2_XYZ_MAT, linearCV);
-
- XYZ = mul(D60_2_D65_CAT, XYZ);
-
- linearCV = mul(XYZ_2_REC709_MAT, XYZ);
-
-
- linearCV = saturate(linearCV);
-
-
-
-
- return linearCV;
- }
- half3 ODT_RGBmonitor_D60sim_100nits_dim(half3 oces)
- {
-
- half3 rgbPre = mul(AP0_2_AP1_MAT, oces);
-
- half3 rgbPost;
- rgbPost.x = segmented_spline_c9_fwd(rgbPre.x);
- rgbPost.y = segmented_spline_c9_fwd(rgbPre.y);
- rgbPost.z = segmented_spline_c9_fwd(rgbPre.z);
-
- half3 linearCV = Y_2_linCV(rgbPost, CINEMA_WHITE, CINEMA_BLACK);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- const half SCALE = 0.955;
- linearCV = min(linearCV, 1.0) * SCALE;
-
- linearCV = darkSurround_to_dimSurround(linearCV);
-
-
- linearCV = lerp(dot(linearCV, AP1_RGB2Y).xxx, linearCV, ODT_SAT_FACTOR.xxx);
-
-
- half3 XYZ = mul(AP1_2_XYZ_MAT, linearCV);
-
- linearCV = mul(XYZ_2_REC709_MAT, XYZ);
-
-
- linearCV = saturate(linearCV);
-
-
-
-
- return linearCV;
- }
- half3 ODT_Rec709_100nits_dim(half3 oces)
- {
-
- half3 rgbPre = mul(AP0_2_AP1_MAT, oces);
-
- half3 rgbPost;
- rgbPost.x = segmented_spline_c9_fwd(rgbPre.x);
- rgbPost.y = segmented_spline_c9_fwd(rgbPre.y);
- rgbPost.z = segmented_spline_c9_fwd(rgbPre.z);
-
- half3 linearCV = Y_2_linCV(rgbPost, CINEMA_WHITE, CINEMA_BLACK);
-
- linearCV = darkSurround_to_dimSurround(linearCV);
-
-
- linearCV = lerp(dot(linearCV, AP1_RGB2Y).xxx, linearCV, ODT_SAT_FACTOR.xxx);
-
-
- half3 XYZ = mul(AP1_2_XYZ_MAT, linearCV);
-
- XYZ = mul(D60_2_D65_CAT, XYZ);
-
- linearCV = mul(XYZ_2_REC709_MAT, XYZ);
-
-
- linearCV = saturate(linearCV);
-
- const half DISPGAMMA = 2.4;
- const half L_W = 1.0;
- const half L_B = 0.0;
- half3 outputCV = linear_to_bt1886(linearCV, DISPGAMMA, L_W, L_B);
-
-
-
-
-
- return outputCV;
- }
- half3 ODT_Rec709_D60sim_100nits_dim(half3 oces)
- {
-
- half3 rgbPre = mul(AP0_2_AP1_MAT, oces);
-
- half3 rgbPost;
- rgbPost.x = segmented_spline_c9_fwd(rgbPre.x);
- rgbPost.y = segmented_spline_c9_fwd(rgbPre.y);
- rgbPost.z = segmented_spline_c9_fwd(rgbPre.z);
-
- half3 linearCV = Y_2_linCV(rgbPost, CINEMA_WHITE, CINEMA_BLACK);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- const half SCALE = 0.955;
- linearCV = min(linearCV, 1.0) * SCALE;
-
- linearCV = darkSurround_to_dimSurround(linearCV);
-
-
- linearCV = lerp(dot(linearCV, AP1_RGB2Y).xxx, linearCV, ODT_SAT_FACTOR.xxx);
-
-
- half3 XYZ = mul(AP1_2_XYZ_MAT, linearCV);
-
- linearCV = mul(XYZ_2_REC709_MAT, XYZ);
-
-
- linearCV = saturate(linearCV);
-
- const half DISPGAMMA = 2.4;
- const half L_W = 1.0;
- const half L_B = 0.0;
- half3 outputCV = linear_to_bt1886(linearCV, DISPGAMMA, L_W, L_B);
-
-
-
-
-
- return outputCV;
- }
- half3 ODT_Rec2020_100nits_dim(half3 oces)
- {
-
- half3 rgbPre = mul(AP0_2_AP1_MAT, oces);
-
- half3 rgbPost;
- rgbPost.x = segmented_spline_c9_fwd(rgbPre.x);
- rgbPost.y = segmented_spline_c9_fwd(rgbPre.y);
- rgbPost.z = segmented_spline_c9_fwd(rgbPre.z);
-
- half3 linearCV = Y_2_linCV(rgbPost, CINEMA_WHITE, CINEMA_BLACK);
-
- linearCV = darkSurround_to_dimSurround(linearCV);
-
-
- linearCV = lerp(dot(linearCV, AP1_RGB2Y).xxx, linearCV, ODT_SAT_FACTOR.xxx);
-
-
- half3 XYZ = mul(AP1_2_XYZ_MAT, linearCV);
-
- XYZ = mul(D60_2_D65_CAT, XYZ);
-
- linearCV = mul(XYZ_2_REC2020_MAT, XYZ);
-
-
- linearCV = saturate(linearCV);
-
- const half DISPGAMMA = 2.4;
- const half L_W = 1.0;
- const half L_B = 0.0;
- half3 outputCV = linear_to_bt1886(linearCV, DISPGAMMA, L_W, L_B);
-
-
-
-
-
- return outputCV;
- }
- half3 ODT_P3DCI_48nits(half3 oces)
- {
-
- half3 rgbPre = mul(AP0_2_AP1_MAT, oces);
-
- half3 rgbPost;
- rgbPost.x = segmented_spline_c9_fwd(rgbPre.x);
- rgbPost.y = segmented_spline_c9_fwd(rgbPre.y);
- rgbPost.z = segmented_spline_c9_fwd(rgbPre.z);
-
- half3 linearCV = Y_2_linCV(rgbPost, CINEMA_WHITE, CINEMA_BLACK);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- const half NEW_WHT = 0.918;
- const half ROLL_WIDTH = 0.5;
- linearCV.x = roll_white_fwd(linearCV.x, NEW_WHT, ROLL_WIDTH);
- linearCV.y = roll_white_fwd(linearCV.y, NEW_WHT, ROLL_WIDTH);
- linearCV.z = roll_white_fwd(linearCV.z, NEW_WHT, ROLL_WIDTH);
-
- const half SCALE = 0.96;
- linearCV = min(linearCV, NEW_WHT) * SCALE;
-
-
- half3 XYZ = mul(AP1_2_XYZ_MAT, linearCV);
-
- linearCV = mul(XYZ_2_DCIP3_MAT, XYZ);
-
-
- linearCV = saturate(linearCV);
-
- const half DISPGAMMA = 2.6;
- half3 outputCV = pow(linearCV, 1.0 / DISPGAMMA);
-
-
-
-
- return outputCV;
- }
- #endif
|