Skip to content

Commit 766ec78

Browse files
committed
Added White Balance support
1 parent 222868e commit 766ec78

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

examples/Mac/FilterShowcase/FilterShowcase/FilterOperations.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ let filterOperations: Array<FilterOperationInterface> = [
7676
},
7777
filterOperationType:.singleInput
7878
),
79-
// FilterOperation(
80-
// filter:{WhiteBalance()},
81-
// listName:"White balance",
82-
// titleName:"White Balance",
83-
// sliderConfiguration:.enabled(minimumValue:2500.0, maximumValue:7500.0, initialValue:5000.0),
84-
// sliderUpdateCallback: {(filter, sliderValue) in
85-
// filter.temperature = sliderValue
86-
// },
87-
// filterOperationType:.singleInput
88-
// ),
79+
FilterOperation(
80+
filter:{WhiteBalance()},
81+
listName:"White balance",
82+
titleName:"White Balance",
83+
sliderConfiguration:.enabled(minimumValue:2500.0, maximumValue:7500.0, initialValue:5000.0),
84+
sliderUpdateCallback: {(filter, sliderValue) in
85+
filter.temperature = sliderValue
86+
},
87+
filterOperationType:.singleInput
88+
),
8989
FilterOperation(
9090
filter:{MonochromeFilter()},
9191
listName:"Monochrome",

framework/GPUImage.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
1F1A90B424BEC03D0029813E /* WhiteBalance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A81C992101015700A3B43A /* WhiteBalance.swift */; };
11+
1F1A90B524BEC03D0029813E /* WhiteBalance.metal in Sources */ = {isa = PBXBuildFile; fileRef = 79A81C9C2101016100A3B43A /* WhiteBalance.metal */; };
12+
1F1A90B624BEC03D0029813E /* WhiteBalance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79A81C992101015700A3B43A /* WhiteBalance.swift */; };
13+
1F1A90B724BEC03D0029813E /* WhiteBalance.metal in Sources */ = {isa = PBXBuildFile; fileRef = 79A81C9C2101016100A3B43A /* WhiteBalance.metal */; };
1014
4C280F76213426D6001A985C /* Posterize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C280F75213426D6001A985C /* Posterize.swift */; };
1115
4C280F77213426D6001A985C /* Posterize.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C280F75213426D6001A985C /* Posterize.swift */; };
1216
4C280F79213426EC001A985C /* Posterize.metal in Sources */ = {isa = PBXBuildFile; fileRef = 4C280F78213426EC001A985C /* Posterize.metal */; };
@@ -1110,6 +1114,7 @@
11101114
795ECAA521ED2549000EF927 /* ThresholdSobelEdgeDetection.metal in Sources */,
11111115
7954BF462214965D008402A6 /* PinchDistortion.swift in Sources */,
11121116
795ECAB121ED2E58000EF927 /* ThresholdSketch.metal in Sources */,
1117+
1F1A90B424BEC03D0029813E /* WhiteBalance.swift in Sources */,
11131118
79DD50CD213454A2004EF308 /* Vignette.metal in Sources */,
11141119
BC9294AA210513DF006C8E93 /* SepiaToneFilter.swift in Sources */,
11151120
79DD50C4213450BE004EF308 /* SwirlDistortion.swift in Sources */,
@@ -1174,6 +1179,7 @@
11741179
793D934120F693AD008A7A6E /* GammaAdjustment.swift in Sources */,
11751180
BCCFEA6222AEEDDB00C9F4CC /* Camera.swift in Sources */,
11761181
79A81CA62101266600A3B43A /* HighlightAndShadowTint.swift in Sources */,
1182+
1F1A90B524BEC03D0029813E /* WhiteBalance.metal in Sources */,
11771183
79CB6E38210A0EDE0042F87B /* SourceOverBlend.metal in Sources */,
11781184
79CB6DD22108B3F00042F87B /* ColorDodgeBlend.swift in Sources */,
11791185
79EB1B6E2125C7670049135E /* LookupFilter.metal in Sources */,
@@ -1315,6 +1321,7 @@
13151321
795ECAA621ED2549000EF927 /* ThresholdSobelEdgeDetection.metal in Sources */,
13161322
795ECAB221ED2E58000EF927 /* ThresholdSketch.metal in Sources */,
13171323
7954BF472214965D008402A6 /* PinchDistortion.swift in Sources */,
1324+
1F1A90B624BEC03D0029813E /* WhiteBalance.swift in Sources */,
13181325
79DD50CE213454A2004EF308 /* Vignette.metal in Sources */,
13191326
BC9294AB210513DF006C8E93 /* SepiaToneFilter.swift in Sources */,
13201327
79DD50C5213450BE004EF308 /* SwirlDistortion.swift in Sources */,
@@ -1379,6 +1386,7 @@
13791386
793D933620F68C1B008A7A6E /* ContrastAdjustment.swift in Sources */,
13801387
BCCFEA6322AEEDDB00C9F4CC /* Camera.swift in Sources */,
13811388
79E30E6D20F118CD005FA13C /* Texture.swift in Sources */,
1389+
1F1A90B724BEC03D0029813E /* WhiteBalance.metal in Sources */,
13821390
79A81CA72101266600A3B43A /* HighlightAndShadowTint.swift in Sources */,
13831391
BC7BA29420F6F2CB006B5F4B /* BrightnessAdjustment.metal in Sources */,
13841392
79CB6E39210A0EDE0042F87B /* SourceOverBlend.metal in Sources */,

framework/Source/Operations/WhiteBalance.metal

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
using namespace metal;
44

55
constant half3 warmFilter = half3(0.93, 0.54, 0.0);
6-
7-
constant half3x3 RGBtoYIQ = half3x3(0.299, 0.587, 0.114, 0.596, -0.274, -0.322, 0.212, -0.523, 0.311);
8-
constant half3x3 YIQtoRGB = half3x3(1.0, 0.956, 0.621, 1.0, -0.272, -0.647, 1.0, -1.105, 1.702);
6+
constant half3x3 RGBtoYIQ = half3x3(half3(0.299, 0.587, 0.114), half3(0.596, -0.274, -0.322), half3(0.212, -0.523, 0.311));
7+
constant half3x3 YIQtoRGB = half3x3(half3(1.0, 0.956, 0.621), half3(1.0, -0.272, -0.647), half3(1.0, -1.105, 1.702));
98

109
typedef struct
1110
{
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
/*
21
public class WhiteBalance: BasicOperation {
32
public var temperature:Float = 5000.0 { didSet { uniformSettings["temperature"] = temperature < 5000.0 ? 0.0004 * (temperature - 5000.0) : 0.00006 * (temperature - 5000.0) } }
43
public var tint:Float = 0.0 { didSet { uniformSettings["tint"] = tint / 100.0 } }
54

65
public init() {
76
super.init(fragmentFunctionName:"whiteBalanceFragmentShader", numberOfInputs:1)
87

9-
uniformSettings.appendUniform(5000.0)
10-
uniformSettings.appendUniform(0.0)
8+
({temperature = 5000.0})()
9+
({tint = 0.0})()
1110
}
1211
}
13-
*/

0 commit comments

Comments
 (0)