1-
21// <ACEStransformID>urn:ampas:aces:transformId:v1.5 :LMT.VWG.GamutCompress.a1.v1</ACEStransformID>
32// <ACESuserName>ACES 1.3 Look - Gamut Compress</ACESuserName>
43
@@ -24,30 +23,30 @@ import "ACESlib.Transform_Common";
2423
2524/* --- Gamut Compress Parameters --- */
2625// Distance from achromatic which will be compressed to the gamut boundary
27- const float lim_cyan = 1.147 ;
28- const float lim_magenta = 1.264 ;
29- const float lim_yellow = 1.312 ;
26+ const float LIM_CYAN = 1.147 ;
27+ const float LIM_MAGENTA = 1.264 ;
28+ const float LIM_YELLOW = 1.312 ;
3029
3130// Percentage of the core gamut to protect
32- const float thr_cyan = 0.815 ;
33- const float thr_magenta = 0.803 ;
34- const float thr_yellow = 0.880 ;
31+ const float THR_CYAN = 0.815 ;
32+ const float THR_MAGENTA = 0.803 ;
33+ const float THR_YELLOW = 0.880 ;
3534
3635// Agressiveness of the compression curve
37- const float pwr = 1.2 ;
36+ const float PWR = 1.2 ;
3837
3938
4039
4140// Calculate compressed distance
4241float compress(float dist, float lim, float thr, float pwr, bool invert)
4342{
44- float compr_dist ;
43+ float comprDist ;
4544 float scl;
4645 float nd;
4746 float p;
4847
4948 if (dist < thr) {
50- compr_dist = dist; // No compression below threshold
49+ comprDist = dist; // No compression below threshold
5150 }
5251 else {
5352 // Calculate scale factor for y = 1 intersect
@@ -58,19 +57,19 @@ float compress(float dist, float lim, float thr, float pwr, bool invert)
5857 p = pow(nd, pwr);
5958
6059 if (!invert) {
61- compr_dist = thr + scl * nd / (pow(1.0 + p, 1.0 / pwr)); // Compress
60+ comprDist = thr + scl * nd / (pow(1.0 + p, 1.0 / pwr)); // Compress
6261 }
6362 else {
6463 if (dist > (thr + scl)) {
65- compr_dist = dist; // Avoid singularity
64+ comprDist = dist; // Avoid singularity
6665 }
6766 else {
68- compr_dist = thr + scl * pow(-(p / (p - 1.0 )), 1.0 / pwr); // Uncompress
67+ comprDist = thr + scl * pow(-(p / (p - 1.0 )), 1.0 / pwr); // Uncompress
6968 }
7069 }
7170 }
7271
73- return compr_dist ;
72+ return comprDist ;
7473}
7574
7675
@@ -92,10 +91,10 @@ void main
9291 float ACES[3 ] = {rIn, gIn, bIn};
9392
9493 // Convert to ACEScg
95- float lin_AP1 [3 ] = mult_f3_f44(ACES, AP0_2_AP1_MAT);
94+ float linAP1 [3 ] = mult_f3_f44(ACES, AP0_2_AP1_MAT);
9695
9796 // Achromatic axis
98- float ach = max_f3(lin_AP1 );
97+ float ach = max_f3(linAP1 );
9998
10099 // Distance from the achromatic axis for each color component aka inverse RGB ratios
101100 float dist[3 ];
@@ -105,27 +104,27 @@ void main
105104 dist[2 ] = 0.0 ;
106105 }
107106 else {
108- dist[0 ] = (ach - lin_AP1 [0 ]) / fabs(ach);
109- dist[1 ] = (ach - lin_AP1 [1 ]) / fabs(ach);
110- dist[2 ] = (ach - lin_AP1 [2 ]) / fabs(ach);
107+ dist[0 ] = (ach - linAP1 [0 ]) / fabs(ach);
108+ dist[1 ] = (ach - linAP1 [1 ]) / fabs(ach);
109+ dist[2 ] = (ach - linAP1 [2 ]) / fabs(ach);
111110 }
112111
113112 // Compress distance with parameterized shaper function
114- float compr_dist [3 ] = {
115- compress(dist[0 ], lim_cyan, thr_cyan, pwr , invert),
116- compress(dist[1 ], lim_magenta, thr_magenta, pwr , invert),
117- compress(dist[2 ], lim_yellow, thr_yellow, pwr , invert)
113+ float comprDist [3 ] = {
114+ compress(dist[0 ], LIM_CYAN, THR_CYAN, PWR , invert),
115+ compress(dist[1 ], LIM_MAGENTA, THR_MAGENTA, PWR , invert),
116+ compress(dist[2 ], LIM_YELLOW, THR_YELLOW, PWR , invert)
118117 };
119118
120119 // Recalculate RGB from compressed distance and achromatic
121- float compr_lin_AP1 [3 ] = {
122- ach - compr_dist [0 ] * fabs(ach),
123- ach - compr_dist [1 ] * fabs(ach),
124- ach - compr_dist [2 ] * fabs(ach)
120+ float comprLinAP1 [3 ] = {
121+ ach - comprDist [0 ] * fabs(ach),
122+ ach - comprDist [1 ] * fabs(ach),
123+ ach - comprDist [2 ] * fabs(ach)
125124 };
126125
127126 // Convert back to ACES2065-1
128- ACES = mult_f3_f44(compr_lin_AP1 , AP1_2_AP0_MAT);
127+ ACES = mult_f3_f44(comprLinAP1 , AP1_2_AP0_MAT);
129128
130129 // Write output
131130 rOut = ACES[0 ];
0 commit comments