@@ -55,6 +55,9 @@ inline fixed3 mix3(fixed3 a, fixed3 b, fixed t)
55
55
return a * (1 - t) + b * t;
56
56
}
57
57
58
+ /**
59
+ Pre-Normalized detail mixing function for RGB input.
60
+ **/
58
61
inline fixed3 recolorStandard (fixed3 diffuseSample, fixed3 maskSample, fixed norm, fixed detailMult, fixed3 userColor1, fixed3 userColor2, fixed3 userColor3)
59
62
{
60
63
fixed mixFactor = getMaskMix (maskSample);
@@ -71,7 +74,7 @@ inline fixed3 recolorStandard(fixed3 diffuseSample, fixed3 maskSample, fixed nor
71
74
72
75
//extracts a +/- 0 detail value
73
76
//will be NAN if normalization value is zero (unmasked pixels)
74
- fixed detail = (( luminance - norm) / norm) * userMix;
77
+ fixed detail = (luminance - norm) * userMix;
75
78
76
79
//user selected coloring, plus details as applied in a renormalized fashion
77
80
fixed3 userPlusDetail = (userSelectedColor * detail * detailMult) + userSelectedColor;
@@ -81,15 +84,28 @@ inline fixed3 recolorStandard(fixed3 diffuseSample, fixed3 maskSample, fixed nor
81
84
return saturate (userPlusDetail) + baseOutput;
82
85
}
83
86
87
+ /**
88
+ Same function as above, but for single-channel inputs
89
+ **/
84
90
inline fixed recolorStandard (fixed sample1, fixed3 maskSample, fixed norm, fixed detailMult, fixed user1, fixed user2, fixed user3)
85
91
{
86
92
fixed mixFactor = getMaskMix (maskSample);
93
+ fixed userMix = 1 - mixFactor;
94
+
95
+ //the value to use from the recoloring channels
87
96
fixed userSelectedValue = getUserValue (maskSample, user1, user2, user3);
88
- fixed baseOutput = sample1 * mixFactor;
89
- // dt = (1 - 0) * ( 1 )
90
- // upd = (1 / 0) * 1 * 1 + 1
91
- fixed detail = (sample1 - norm) * (1 - mixFactor) * userSelectedValue * detailMult;
92
- fixed userPlusDetail = detail + userSelectedValue;
97
+
98
+ //the value of the original sample
99
+ fixed luminance = sample1;
100
+
101
+ //output factor of original texture values, used in unmasked or partially masked pixels
102
+ fixed baseOutput = mixFactor * sample1;
103
+
104
+ //detail value of pixel
105
+ fixed detail = (luminance - norm) * userMix;
106
+
107
+ fixed userPlusDetail = (userSelectedValue * detail * detailMult) + userSelectedValue;
108
+
93
109
return saturate (userPlusDetail) + baseOutput;
94
110
}
95
111
0 commit comments