Permalink
Browse files

Added a simple fallback to use the passthrough shader when a Gaussian…

… blur is given a 0 pixel radius.
  • Loading branch information...
1 parent 0862252 commit 41bd71149e86634e79187646b0e53c083f27050d @BradLarson committed Dec 9, 2013
@@ -1149,7 +1149,7 @@ - (void)setupFilter;
self.title = @"Gaussian Blur";
self.filterSettingsSlider.hidden = NO;
- [self.filterSettingsSlider setMinimumValue:1.0];
+ [self.filterSettingsSlider setMinimumValue:0.0];
[self.filterSettingsSlider setMaximumValue:24.0];
[self.filterSettingsSlider setValue:2.0];
@@ -49,9 +49,9 @@ void main()\n\
+ (NSString *)fragmentShaderForOptimizedBlurOfRadius:(NSUInteger)blurRadius sigma:(CGFloat)sigma;
{
- if (blurRadius == 0)
+ if (blurRadius < 1)
{
- return nil;
+ return kGPUImagePassthroughFragmentShaderString;
}
NSUInteger numberOfOptimizedOffsets = MIN(blurRadius / 2 + (blurRadius % 2), 7);
@@ -40,6 +40,11 @@ - (id)init;
+ (NSString *)vertexShaderForStandardBlurOfRadius:(NSUInteger)blurRadius sigma:(CGFloat)sigma;
{
+ if (blurRadius < 1)
+ {
+ return kGPUImageVertexShaderString;
+ }
+
// NSLog(@"Max varyings: %d", [GPUImageContext maximumVaryingVectorsForThisDevice]);
NSMutableString *shaderString = [[NSMutableString alloc] init];
@@ -85,6 +90,11 @@ void main()\n\
+ (NSString *)fragmentShaderForStandardBlurOfRadius:(NSUInteger)blurRadius sigma:(CGFloat)sigma;
{
+ if (blurRadius < 1)
+ {
+ return kGPUImagePassthroughFragmentShaderString;
+ }
+
// First, generate the normal Gaussian weights for a given sigma
GLfloat *standardGaussianWeights = calloc(blurRadius + 1, sizeof(GLfloat));
GLfloat sumOfWeights = 0.0;
@@ -157,10 +167,11 @@ void main()\n\
+ (NSString *)vertexShaderForOptimizedBlurOfRadius:(NSUInteger)blurRadius sigma:(CGFloat)sigma;
{
- if (blurRadius == 0)
+ if (blurRadius < 1)
{
- return nil;
+ return kGPUImageVertexShaderString;
}
+
// First, generate the normal Gaussian weights for a given sigma
GLfloat *standardGaussianWeights = calloc(blurRadius + 1, sizeof(GLfloat));
GLfloat sumOfWeights = 0.0;
@@ -234,10 +245,11 @@ void main()\n\
+ (NSString *)fragmentShaderForOptimizedBlurOfRadius:(NSUInteger)blurRadius sigma:(CGFloat)sigma;
{
- if (blurRadius == 0)
+ if (blurRadius < 1)
{
- return nil;
+ return kGPUImagePassthroughFragmentShaderString;
}
+
// First, generate the normal Gaussian weights for a given sigma
GLfloat *standardGaussianWeights = calloc(blurRadius + 1, sizeof(GLfloat));
GLfloat sumOfWeights = 0.0;
@@ -4,10 +4,11 @@ @implementation GPUImageSingleComponentGaussianBlurFilter
+ (NSString *)vertexShaderForOptimizedBlurOfRadius:(NSUInteger)blurRadius sigma:(CGFloat)sigma;
{
- if (blurRadius == 0)
+ if (blurRadius < 1)
{
- return nil;
+ return kGPUImageVertexShaderString;
}
+
// First, generate the normal Gaussian weights for a given sigma
GLfloat *standardGaussianWeights = calloc(blurRadius + 1, sizeof(GLfloat));
GLfloat sumOfWeights = 0.0;
@@ -81,10 +82,11 @@ void main()\n\
+ (NSString *)fragmentShaderForOptimizedBlurOfRadius:(NSUInteger)blurRadius sigma:(CGFloat)sigma;
{
- if (blurRadius == 0)
+ if (blurRadius < 1)
{
- return nil;
+ return kGPUImagePassthroughFragmentShaderString;
}
+
// First, generate the normal Gaussian weights for a given sigma
GLfloat *standardGaussianWeights = calloc(blurRadius + 1, sizeof(GLfloat));
GLfloat sumOfWeights = 0.0;

0 comments on commit 41bd711

Please sign in to comment.