Skip to content

Commit

Permalink
Ported a few more color adjustment filters to the Mac. Tweaked the wa…
Browse files Browse the repository at this point in the history
…y that GPUImageView works on the Mac to support resizing correctly.
  • Loading branch information
BradLarson committed Apr 26, 2013
1 parent 840d708 commit 58e680e
Show file tree
Hide file tree
Showing 16 changed files with 336 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ typedef enum {
GPUIMAGE_TRANSFORM3D,
GPUIMAGE_CROP,
GPUIMAGE_MASK,
GPUIMAGE_GAMMA,
GPUIMAGE_TONECURVE,
GPUIMAGE_HIGHLIGHTSHADOW,
GPUIMAGE_HAZE,
GPUIMAGE_SEPIA,
GPUIMAGE_PIXELLATE,
GPUIMAGE_GRAYSCALE,
GPUIMAGE_SOBELEDGEDETECTION,
Expand Down
55 changes: 55 additions & 0 deletions examples/Mac/FilterShowcase/SLSFilterShowcaseWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,51 @@ - (void)changeSelectedRow:(NSUInteger)newRowIndex;
self.enableSlider = NO;
needsSecondImage = YES;
}; break;
case GPUIMAGE_GAMMA:
{
currentlySelectedFilter = [[GPUImageGammaFilter alloc] init];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 3.0;
self.currentSliderValue = 1.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_TONECURVE:
{
currentlySelectedFilter = [[GPUImageToneCurveFilter alloc] init];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 1.0;
self.currentSliderValue = 0.5;
self.enableSlider = YES;
}; break;
case GPUIMAGE_HIGHLIGHTSHADOW:
{
currentlySelectedFilter = [[GPUImageHighlightShadowFilter alloc] init];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 1.0;
self.currentSliderValue = 1.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_HAZE:
{
currentlySelectedFilter = [[GPUImageHazeFilter alloc] init];

self.minimumSliderValue = -0.2;
self.maximumSliderValue = 0.2;
self.currentSliderValue = 0.2;
self.enableSlider = YES;
}; break;
case GPUIMAGE_SEPIA:
{
currentlySelectedFilter = [[GPUImageSepiaFilter alloc] init];

self.minimumSliderValue = 0.0;
self.maximumSliderValue = 1.0;
self.currentSliderValue = 1.0;
self.enableSlider = YES;
}; break;
case GPUIMAGE_GRAYSCALE:
{
currentlySelectedFilter = [[GPUImageGrayscaleFilter alloc] init];
Expand Down Expand Up @@ -573,6 +618,11 @@ - (void)setCurrentSliderValue:(CGFloat)newValue;
case GPUIMAGE_HUE: [(GPUImageHueFilter *)currentlySelectedFilter setHue:_currentSliderValue]; break;
case GPUIMAGE_WHITEBALANCE: [(GPUImageWhiteBalanceFilter *)currentlySelectedFilter setTemperature:_currentSliderValue]; break;
case GPUIMAGE_MONOCHROME: [(GPUImageMonochromeFilter *)currentlySelectedFilter setIntensity:_currentSliderValue]; break;
case GPUIMAGE_GAMMA: [(GPUImageGammaFilter *)currentlySelectedFilter setGamma:_currentSliderValue]; break;
case GPUIMAGE_TONECURVE: [(GPUImageToneCurveFilter *)currentlySelectedFilter setBlueControlPoints:[NSArray arrayWithObjects:[NSValue valueWithPoint:NSMakePoint(0.0, 0.0)], [NSValue valueWithPoint:NSMakePoint(0.5, _currentSliderValue)], [NSValue valueWithPoint:NSMakePoint(1.0, 0.75)], nil]]; break;
case GPUIMAGE_HIGHLIGHTSHADOW: [(GPUImageHighlightShadowFilter *)currentlySelectedFilter setHighlights:_currentSliderValue]; break;
case GPUIMAGE_HAZE: [(GPUImageHazeFilter *)currentlySelectedFilter setDistance:_currentSliderValue]; break;
case GPUIMAGE_SEPIA: [(GPUImageSepiaFilter *)currentlySelectedFilter setIntensity:_currentSliderValue]; break;
case GPUIMAGE_PIXELLATE: [(GPUImagePixellateFilter *)currentlySelectedFilter setFractionalWidthOfAPixel:_currentSliderValue]; break;
case GPUIMAGE_KUWAHARA: [(GPUImageKuwaharaFilter *)currentlySelectedFilter setRadius:round(_currentSliderValue)]; break;
case GPUIMAGE_SHARPEN: [(GPUImageSharpenFilter *)currentlySelectedFilter setSharpness:_currentSliderValue]; break;
Expand Down Expand Up @@ -639,6 +689,11 @@ - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColu
case GPUIMAGE_TRANSFORM3D: tableRowTitle = @"Transform (3-D)"; break;
case GPUIMAGE_CROP: tableRowTitle = @"Crop"; break;
case GPUIMAGE_MASK: tableRowTitle = @"Mask"; break;
case GPUIMAGE_GAMMA: tableRowTitle = @"Gamma"; break;
case GPUIMAGE_TONECURVE: tableRowTitle = @"Tone curve"; break;
case GPUIMAGE_HIGHLIGHTSHADOW: tableRowTitle = @"Highlights and shadows"; break;
case GPUIMAGE_HAZE: tableRowTitle = @"Haze"; break;
case GPUIMAGE_SEPIA: tableRowTitle = @"Sepia tone"; break;
case GPUIMAGE_GAUSSIAN: tableRowTitle = @"Gaussian blur"; break;
case GPUIMAGE_GAUSSIAN_SELECTIVE: tableRowTitle = @"Gaussian selective blur"; break;
case GPUIMAGE_GAUSSIAN_POSITION: tableRowTitle = @"Gaussian (centered)"; break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@
buildConfigurationList = BCA3F35D1723A2E800E28AEC /* Build configuration list for PBXNativeTarget "SimplePhotoFilter" */;
buildPhases = (
BCA3F3391723A2E800E28AEC /* Sources */,
BCF40F341724AF95005AE36A /* CopyFiles */,
BCA3F33A1723A2E800E28AEC /* Frameworks */,
BCA3F33B1723A2E800E28AEC /* Resources */,
BCF40F341724AF95005AE36A /* CopyFiles */,
);
buildRules = (
);
Expand Down
50 changes: 50 additions & 0 deletions framework/GPUImageMac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
BCA3F3621723A8FA00E28AEC /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCA3F3601723A8FA00E28AEC /* OpenGL.framework */; };
BCA3F3631723A8FA00E28AEC /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BCA3F3611723A8FA00E28AEC /* QuartzCore.framework */; };
BCA3F3651723A96600E28AEC /* GPUImage.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA3F3641723A96600E28AEC /* GPUImage.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCB009E6172A1BBD00DB804C /* GPUImageGammaFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB009E4172A1BBD00DB804C /* GPUImageGammaFilter.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCB009E7172A1BBD00DB804C /* GPUImageGammaFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = BCB009E5172A1BBD00DB804C /* GPUImageGammaFilter.m */; };
BCB009EA172A1BE800DB804C /* GPUImageToneCurveFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB009E8172A1BE800DB804C /* GPUImageToneCurveFilter.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCB009EB172A1BE800DB804C /* GPUImageToneCurveFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = BCB009E9172A1BE800DB804C /* GPUImageToneCurveFilter.m */; };
BCB009F0172A23AA00DB804C /* GPUImageHazeFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB009EC172A23A900DB804C /* GPUImageHazeFilter.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCB009F1172A23AA00DB804C /* GPUImageHazeFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = BCB009ED172A23A900DB804C /* GPUImageHazeFilter.m */; };
BCB009F2172A23AA00DB804C /* GPUImageHighlightShadowFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB009EE172A23AA00DB804C /* GPUImageHighlightShadowFilter.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCB009F3172A23AA00DB804C /* GPUImageHighlightShadowFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = BCB009EF172A23AA00DB804C /* GPUImageHighlightShadowFilter.m */; };
BCB009F6172A243400DB804C /* GPUImageSepiaFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB009F4172A243300DB804C /* GPUImageSepiaFilter.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCB009F7172A243400DB804C /* GPUImageSepiaFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = BCB009F5172A243400DB804C /* GPUImageSepiaFilter.m */; };
BCB009FA172A246E00DB804C /* GPUImageColorMatrixFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB009F8172A246D00DB804C /* GPUImageColorMatrixFilter.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCB009FB172A246E00DB804C /* GPUImageColorMatrixFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = BCB009F9172A246E00DB804C /* GPUImageColorMatrixFilter.m */; };
BCF40F1217247D68005AE36A /* GPUImageContext.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF40F1017247D68005AE36A /* GPUImageContext.h */; settings = {ATTRIBUTES = (Public, ); }; };
BCF40F1317247D68005AE36A /* GPUImageContext.m in Sources */ = {isa = PBXBuildFile; fileRef = BCF40F1117247D68005AE36A /* GPUImageContext.m */; };
BCF40F1617247FD8005AE36A /* GLProgram.h in Headers */ = {isa = PBXBuildFile; fileRef = BCF40F1417247FD8005AE36A /* GLProgram.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -166,6 +178,18 @@
BCA3F3601723A8FA00E28AEC /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
BCA3F3611723A8FA00E28AEC /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
BCA3F3641723A96600E28AEC /* GPUImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImage.h; path = Source/Mac/GPUImage.h; sourceTree = SOURCE_ROOT; };
BCB009E4172A1BBD00DB804C /* GPUImageGammaFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageGammaFilter.h; path = Source/GPUImageGammaFilter.h; sourceTree = SOURCE_ROOT; };
BCB009E5172A1BBD00DB804C /* GPUImageGammaFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageGammaFilter.m; path = Source/GPUImageGammaFilter.m; sourceTree = SOURCE_ROOT; };
BCB009E8172A1BE800DB804C /* GPUImageToneCurveFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageToneCurveFilter.h; path = Source/GPUImageToneCurveFilter.h; sourceTree = SOURCE_ROOT; };
BCB009E9172A1BE800DB804C /* GPUImageToneCurveFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageToneCurveFilter.m; path = Source/GPUImageToneCurveFilter.m; sourceTree = SOURCE_ROOT; };
BCB009EC172A23A900DB804C /* GPUImageHazeFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageHazeFilter.h; path = Source/GPUImageHazeFilter.h; sourceTree = SOURCE_ROOT; };
BCB009ED172A23A900DB804C /* GPUImageHazeFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageHazeFilter.m; path = Source/GPUImageHazeFilter.m; sourceTree = SOURCE_ROOT; };
BCB009EE172A23AA00DB804C /* GPUImageHighlightShadowFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageHighlightShadowFilter.h; path = Source/GPUImageHighlightShadowFilter.h; sourceTree = SOURCE_ROOT; };
BCB009EF172A23AA00DB804C /* GPUImageHighlightShadowFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageHighlightShadowFilter.m; path = Source/GPUImageHighlightShadowFilter.m; sourceTree = SOURCE_ROOT; };
BCB009F4172A243300DB804C /* GPUImageSepiaFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageSepiaFilter.h; path = Source/GPUImageSepiaFilter.h; sourceTree = SOURCE_ROOT; };
BCB009F5172A243400DB804C /* GPUImageSepiaFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageSepiaFilter.m; path = Source/GPUImageSepiaFilter.m; sourceTree = SOURCE_ROOT; };
BCB009F8172A246D00DB804C /* GPUImageColorMatrixFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageColorMatrixFilter.h; path = Source/GPUImageColorMatrixFilter.h; sourceTree = SOURCE_ROOT; };
BCB009F9172A246E00DB804C /* GPUImageColorMatrixFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageColorMatrixFilter.m; path = Source/GPUImageColorMatrixFilter.m; sourceTree = SOURCE_ROOT; };
BCF40F1017247D68005AE36A /* GPUImageContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImageContext.h; path = Source/Mac/GPUImageContext.h; sourceTree = SOURCE_ROOT; };
BCF40F1117247D68005AE36A /* GPUImageContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = GPUImageContext.m; path = Source/Mac/GPUImageContext.m; sourceTree = SOURCE_ROOT; };
BCF40F1417247FD8005AE36A /* GLProgram.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GLProgram.h; path = Source/GLProgram.h; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -465,6 +489,18 @@
BCF867DF17278D1900912E34 /* GPUImageGrayscaleFilter.m */,
BCF867E61728477200912E34 /* GPUImageFalseColorFilter.h */,
BCF867E71728477200912E34 /* GPUImageFalseColorFilter.m */,
BCB009E4172A1BBD00DB804C /* GPUImageGammaFilter.h */,
BCB009E5172A1BBD00DB804C /* GPUImageGammaFilter.m */,
BCB009E8172A1BE800DB804C /* GPUImageToneCurveFilter.h */,
BCB009E9172A1BE800DB804C /* GPUImageToneCurveFilter.m */,
BCB009EE172A23AA00DB804C /* GPUImageHighlightShadowFilter.h */,
BCB009EF172A23AA00DB804C /* GPUImageHighlightShadowFilter.m */,
BCB009EC172A23A900DB804C /* GPUImageHazeFilter.h */,
BCB009ED172A23A900DB804C /* GPUImageHazeFilter.m */,
BCB009F8172A246D00DB804C /* GPUImageColorMatrixFilter.h */,
BCB009F9172A246E00DB804C /* GPUImageColorMatrixFilter.m */,
BCB009F4172A243300DB804C /* GPUImageSepiaFilter.h */,
BCB009F5172A243400DB804C /* GPUImageSepiaFilter.m */,
BCF8689B1728861E00912E34 /* GPUImageOpacityFilter.h */,
BCF8689C1728861F00912E34 /* GPUImageOpacityFilter.m */,
);
Expand Down Expand Up @@ -658,6 +694,12 @@
BCF86899172883A300912E34 /* GPUImageMaskFilter.h in Headers */,
BCF8689D1728862100912E34 /* GPUImageOpacityFilter.h in Headers */,
BCF868A11728866400912E34 /* GPUImageAlphaBlendFilter.h in Headers */,
BCB009E6172A1BBD00DB804C /* GPUImageGammaFilter.h in Headers */,
BCB009EA172A1BE800DB804C /* GPUImageToneCurveFilter.h in Headers */,
BCB009F0172A23AA00DB804C /* GPUImageHazeFilter.h in Headers */,
BCB009F2172A23AA00DB804C /* GPUImageHighlightShadowFilter.h in Headers */,
BCB009F6172A243400DB804C /* GPUImageSepiaFilter.h in Headers */,
BCB009FA172A246E00DB804C /* GPUImageColorMatrixFilter.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -793,6 +835,12 @@
BCF8689A172883A300912E34 /* GPUImageMaskFilter.m in Sources */,
BCF8689E1728862100912E34 /* GPUImageOpacityFilter.m in Sources */,
BCF868A21728866400912E34 /* GPUImageAlphaBlendFilter.m in Sources */,
BCB009E7172A1BBD00DB804C /* GPUImageGammaFilter.m in Sources */,
BCB009EB172A1BE800DB804C /* GPUImageToneCurveFilter.m in Sources */,
BCB009F1172A23AA00DB804C /* GPUImageHazeFilter.m in Sources */,
BCB009F3172A23AA00DB804C /* GPUImageHighlightShadowFilter.m in Sources */,
BCB009F7172A243400DB804C /* GPUImageSepiaFilter.m in Sources */,
BCB009FB172A246E00DB804C /* GPUImageColorMatrixFilter.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -826,6 +874,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INSTALL_PATH = "@loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -853,6 +902,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INSTALL_PATH = "@loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.6;
SDKROOT = macosx;
};
Expand Down
4 changes: 2 additions & 2 deletions framework/Source/GPUImageChromaKeyBlendFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ - (void)setColorToReplaceRed:(GLfloat)redComponent green:(GLfloat)greenComponent
[self setVec3:colorToReplace forUniform:colorToReplaceUniform program:filterProgram];
}

- (void)setThresholdSensitivity:(CGFloat)newValue;
- (void)setThresholdSensitivity:(GLfloat)newValue;
{
_thresholdSensitivity = newValue;

[self setFloat:_thresholdSensitivity forUniform:thresholdSensitivityUniform program:filterProgram];
}

- (void)setSmoothing:(CGFloat)newValue;
- (void)setSmoothing:(GLfloat)newValue;
{
_smoothing = newValue;

Expand Down
22 changes: 21 additions & 1 deletion framework/Source/GPUImageColorMatrixFilter.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "GPUImageColorMatrixFilter.h"

#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
NSString *const kGPUImageColorMatrixFragmentShaderString = SHADER_STRING
(
varying highp vec2 textureCoordinate;
Expand All @@ -16,7 +17,26 @@ void main()

gl_FragColor = (intensity * outputColor) + ((1.0 - intensity) * textureColor);
}
);
);
#else
NSString *const kGPUImageColorMatrixFragmentShaderString = SHADER_STRING
(
varying vec2 textureCoordinate;

uniform sampler2D inputImageTexture;

uniform mat4 colorMatrix;
uniform float intensity;

void main()
{
vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
vec4 outputColor = textureColor * colorMatrix;

gl_FragColor = (intensity * outputColor) + ((1.0 - intensity) * textureColor);
}
);
#endif

@implementation GPUImageColorMatrixFilter

Expand Down
2 changes: 1 addition & 1 deletion framework/Source/GPUImageFilterGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
// Filter management
- (void)addFilter:(GPUImageOutput<GPUImageInput> *)newFilter;
- (GPUImageOutput<GPUImageInput> *)filterAtIndex:(NSUInteger)filterIndex;
- (int)filterCount;
- (NSUInteger)filterCount;

@end
2 changes: 1 addition & 1 deletion framework/Source/GPUImageFilterGroup.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ - (void)addFilter:(GPUImageOutput<GPUImageInput> *)newFilter;
return [filters objectAtIndex:filterIndex];
}

- (int)filterCount;
- (NSUInteger)filterCount;
{
return [filters count];
}
Expand Down
17 changes: 17 additions & 0 deletions framework/Source/GPUImageGammaFilter.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "GPUImageGammaFilter.h"

#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
NSString *const kGPUImageGammaFragmentShaderString = SHADER_STRING
(
varying highp vec2 textureCoordinate;
Expand All @@ -14,6 +15,22 @@ void main()
gl_FragColor = vec4(pow(textureColor.rgb, vec3(gamma)), textureColor.w);
}
);
#else
NSString *const kGPUImageGammaFragmentShaderString = SHADER_STRING
(
varying vec2 textureCoordinate;

uniform sampler2D inputImageTexture;
uniform float gamma;

void main()
{
vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);

gl_FragColor = vec4(pow(textureColor.rgb, vec3(gamma)), textureColor.w);
}
);
#endif

@implementation GPUImageGammaFilter

Expand Down
30 changes: 26 additions & 4 deletions framework/Source/GPUImageHazeFilter.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#import "GPUImageHazeFilter.h"

#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
NSString *const kGPUImageHazeFragmentShaderString = SHADER_STRING
(
varying highp vec2 textureCoordinate;
Expand All @@ -18,15 +19,36 @@ void main()

highp vec4 c = texture2D(inputImageTexture, textureCoordinate) ; // consider using unpremultiply


c = (c - d * color) / (1.0 -d);
c = (c - d * color) / (1.0 -d);

gl_FragColor = c; //consider using premultiply(c);
}
);
#else
NSString *const kGPUImageHazeFragmentShaderString = SHADER_STRING
(
varying vec2 textureCoordinate;

uniform sampler2D inputImageTexture;

uniform float distance;
uniform float slope;

void main()
{
//todo reconsider precision modifiers
vec4 color = vec4(1.0);//todo reimplement as a parameter


float d = textureCoordinate.y * slope + distance;

vec4 c = texture2D(inputImageTexture, textureCoordinate) ; // consider using unpremultiply

c = (c - d * color) / (1.0 -d);

gl_FragColor = c; //consider using premultiply(c);
}
);

#endif



Expand Down
Loading

0 comments on commit 58e680e

Please sign in to comment.