forked from BradLarson/GPUImage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28c0e08
commit e64d638
Showing
12 changed files
with
135 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
framework/Source/GPUImageTwoInputCrossTextureSamplingFilter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
framework/Source/GPUImageTwoInputCrossTextureSamplingFilter.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#import "GPUImageFilter.h" | ||
|
||
@interface GPUImageZoomBlurFilter : GPUImageFilter | ||
|
||
/** A multiplier for the blur size, ranging from 0.0 on up, with a default of 1.0 | ||
*/ | ||
@property (readwrite, nonatomic) CGFloat blurSize; | ||
|
||
/** The normalized center of the blur. (0.5, 0.5) by default | ||
*/ | ||
@property (readwrite, nonatomic) CGPoint blurCenter; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#import "GPUImageZoomBlurFilter.h" | ||
|
||
NSString *const kGPUImageZoomBlurFragmentShaderString = SHADER_STRING | ||
( | ||
varying highp vec2 textureCoordinate; | ||
|
||
uniform sampler2D inputImageTexture; | ||
|
||
uniform highp vec2 blurCenter; | ||
uniform highp float blurSize; | ||
|
||
void main() | ||
{ | ||
// TODO: Do a more intelligent scaling based on resolution here | ||
highp vec2 samplingOffset = 1.0/100.0 * (blurCenter - textureCoordinate) * blurSize; | ||
|
||
lowp vec4 fragmentColor = texture2D(inputImageTexture, textureCoordinate) * 0.18; | ||
fragmentColor += texture2D(inputImageTexture, textureCoordinate + samplingOffset) * 0.15; | ||
fragmentColor += texture2D(inputImageTexture, textureCoordinate + (2.0 * samplingOffset)) * 0.12; | ||
fragmentColor += texture2D(inputImageTexture, textureCoordinate + (3.0 * samplingOffset)) * 0.09; | ||
fragmentColor += texture2D(inputImageTexture, textureCoordinate + (4.0 * samplingOffset)) * 0.05; | ||
fragmentColor += texture2D(inputImageTexture, textureCoordinate - samplingOffset) * 0.15; | ||
fragmentColor += texture2D(inputImageTexture, textureCoordinate - (2.0 * samplingOffset)) * 0.12; | ||
fragmentColor += texture2D(inputImageTexture, textureCoordinate - (3.0 * samplingOffset)) * 0.09; | ||
fragmentColor += texture2D(inputImageTexture, textureCoordinate - (4.0 * samplingOffset)) * 0.05; | ||
|
||
gl_FragColor = fragmentColor; | ||
} | ||
); | ||
|
||
@interface GPUImageZoomBlurFilter() | ||
{ | ||
GLint blurSizeUniform, blurCenterUniform; | ||
} | ||
@end | ||
|
||
@implementation GPUImageZoomBlurFilter | ||
|
||
@synthesize blurSize = _blurSize; | ||
@synthesize blurCenter = _blurCenter; | ||
|
||
#pragma mark - | ||
#pragma mark Initialization and teardown | ||
|
||
- (id)init; | ||
{ | ||
if (!(self = [super initWithFragmentShaderFromString:kGPUImageZoomBlurFragmentShaderString])) | ||
{ | ||
return nil; | ||
} | ||
|
||
blurSizeUniform = [filterProgram uniformIndex:@"blurSize"]; | ||
blurCenterUniform = [filterProgram uniformIndex:@"blurCenter"]; | ||
|
||
self.blurSize = 1.0; | ||
self.blurCenter = CGPointMake(0.5, 0.5); | ||
|
||
return self; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Accessors | ||
|
||
- (void)setInputRotation:(GPUImageRotationMode)newInputRotation atIndex:(NSInteger)textureIndex; | ||
{ | ||
[super setInputRotation:newInputRotation atIndex:textureIndex]; | ||
[self setBlurCenter:self.blurCenter]; | ||
} | ||
|
||
- (void)setBlurSize:(CGFloat)newValue; | ||
{ | ||
_blurSize = newValue; | ||
|
||
[self setFloat:_blurSize forUniform:blurSizeUniform program:filterProgram]; | ||
} | ||
|
||
- (void)setBlurCenter:(CGPoint)newValue; | ||
{ | ||
_blurCenter = newValue; | ||
|
||
CGPoint rotatedPoint = [self rotatedPoint:_blurCenter forRotation:inputRotation]; | ||
[self setPoint:rotatedPoint forUniform:blurCenterUniform program:filterProgram]; | ||
} | ||
|
||
@end |