Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno Gonçalves committed Oct 25, 2016
0 parents commit ec1c255
Show file tree
Hide file tree
Showing 40 changed files with 3,032 additions and 0 deletions.
40 changes: 40 additions & 0 deletions GPUImageBlueValentineFilter.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#import "GPUImageBlueValentineFilter.h"

@implementation GPUImageBlueValentineFilter

- (id)init;
{
if (!(self = [super init]))
{
return nil;
}

// Blue Valentine
GPUImageSaturationFilter *saturFilter = [[GPUImageSaturationFilter alloc] init];
[saturFilter setSaturation:0.5];
[self addFilter:saturFilter];

GPUImageMonochromeFilter *monoFilter = [[GPUImageMonochromeFilter alloc] init];
[monoFilter setColor:(GPUVector4){1.0f, 1.0f, 2.0f, 1.0f}];
[monoFilter setIntensity:0.15];
[self addFilter:monoFilter];

GPUImagePixellateFilter *vigFilter = [[GPUImagePixellateFilter alloc] init];
vigFilter.fractionalWidthOfAPixel = 0.02;
[self addFilter:vigFilter];

GPUImageExposureFilter *expoFilter = [[GPUImageExposureFilter alloc] init];
[expoFilter setExposure:0.3];
[self addFilter:expoFilter];

[saturFilter addTarget:monoFilter];
[monoFilter addTarget:vigFilter];
[vigFilter addTarget:expoFilter];

[self setInitialFilters:[NSArray arrayWithObject:saturFilter]];
[self setTerminalFilter:expoFilter];

return self;
}

@end
115 changes: 115 additions & 0 deletions GPUImageFilterTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//
// GPUImageFilterTest.m
// moment
//
// Created by Nuno Gonçalves on 21/08/16.
// Copyright © 2016 Motionblink. All rights reserved.
//

#import "GPUImageFilterTest.h"

/*NSString *const kGPUImageTestFragmentShaderString = SHADER_STRING
(
precision mediump float;
uniform sampler2D inputImageTexture;
varying vec2 textureCoordinate;
const float PI = 3.1415926535;
uniform float BarrelPower;
vec2 Distort(vec2 p)
{
float theta = atan(p.y, p.x);
float radius = length(p);
radius = pow(radius, BarrelPower);
p.x = radius * cos(theta);
p.y = radius * sin(theta);
return 0.5 * (p + 1.0);
}
void main()
{
vec2 uv;
float d = length(2.0 * textureCoordinate.xy - 1.0);
if (d < 1.0)
{
uv = Distort(2.0 * textureCoordinate.xy - 1.0);
}
else
{
uv = textureCoordinate.xy;
}
vec4 c = texture2D(inputImageTexture, uv);
gl_FragColor = c;
}
);*/


NSString *const kGPUImageTestVertexShaderString = SHADER_STRING
(
precision mediump float;
varying vec4 Vertex_UV;
varying vec2 textureCoordinate;
attribute vec4 gxl3d_ModelViewProjectionMatrix;
void main()
{
//gl_Position = gxl3d_ModelViewProjectionMatrix;
//Vertex_UV = textureCoordinate;
});

NSString *const kGPUImageTestFragmentShaderString = SHADER_STRING
(
precision mediump float;
uniform sampler2D inputImageTexture;
varying vec2 textureCoordinate;
varying vec4 Vertex_UV;
const float PI = 3.1415926535;

void main()
{
float aperture = 178.0;
float apertureHalf = 0.5 * aperture * (PI / 180.0);
float maxFactor = sin(apertureHalf);

vec2 uv;
vec2 xy = 2.0 * textureCoordinate.xy - 1.0;
float d = length(xy);
if (d < (2.0-maxFactor))
{
d = length(xy * maxFactor);
float z = sqrt(1.0 - d * d);
float r = atan(d, z) / PI;
float phi = atan(xy.y, xy.x);

uv.x = r * cos(phi) + 0.5;
uv.y = r * sin(phi) + 0.5;
}
else
{
uv = textureCoordinate.xy;
}
vec4 c = texture2D(inputImageTexture, uv);
gl_FragColor = c;
}
);

@implementation GPUImageFilterTest

- (id)init;
{
//http:https://pixelshaders.com/editor/
//http:https://www.geeks3d.com/20140213/glsl-shader-library-fish-eye-and-dome-and-barrel-distortion-post-processing-filters/
/* if (!(self = [super initWithFragmentShaderFromString:kGPUImageTestFragmentShaderString sources:@[ [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"lagoapatas.jpg"]]]]))
{
return nil;
}*/

if (!(self = [self initWithFragmentShaderFromString:kGPUImageTestFragmentShaderString]))
{
return nil;
}

return self;
}


@end
Loading

0 comments on commit ec1c255

Please sign in to comment.