Nashville is one of the most amazing features of Instagram's many filters, and the unique milkshake tones give the photo a fairy-tale aesthetic feel.
Scope of application: To create a romantic aesthetic feeling.
That's true.
There are 2 input images
Vertex coloring
There are 2 sets of coordinates
NSString *const kgpuimagetwoinputtexturevertexshaderstring = shader_string
(attribute vec4 position;
The input coordinates attribute VEC4 inputtexturecoordinate; Attribute Vec4 InputTextureCoordinate2; The output coordinates, with the fragment shader varying vec2 texturecoordinate; Varying vec2 textureCoordinate2; void Main () {
Tell the fragment shader what pixels I'm dealing with gl_position = Position; Texturecoordinate = inputtexturecoordinate.xy; TextureCoordinate2 = inputtexturecoordinate2.xy;});
Fragment coloring
NSString *const kfwnashvilleshaderstring = shader_string (precision lowp float; Varying highp vec2 texturecoordinate; Uniform sampler2d inputimagetexture; Uniform sampler2d InputImageTexture2; void Main () { vec3 Texel = texture2d (inputimagetexture, texturecoordinate). RGB; Texel = vec3 ( texture2d (InputImageTexture2, VEC2 (TEXEL.R,. 16666)). R, Texture2d (InputImageTexture2, VEC2 (TEXEL.G,. 5)). G, Texture2d (InputImageTexture2, VEC2 (texel.b,. 83333)). b); Gl_fragcolor = VEC4 (Texel, 1.0);});
Initialization
-(ID) init{if(! (self =[Super Init]) { returnNil; } UIImage*image = [UIImage imagenamed:@"Nashvillemap.png"]; ImageSource=[[Gpuimagepicture alloc] initwithimage:image]; FWFilter1*filter =[[FWFilter1 alloc] init]; [Self addfilter:filter]; [ImageSource addtarget:filter attexturelocation:1]; [ImageSource Processimage]; Self.initialfilters=[Nsarray arraywithobjects:filter, Nil]; Self.terminalfilter=filter; returnSelf ;}
// // FWNashvilleFilter.h// fwmeituapp//// Created by Hzkmn on 16/1/8. // copyright©2016 year Forrestwoo Co,.ltd. All rights reserved. // "GPUImageTwoInputFilter.h"@interface FWFilter1: Gpuimagetwoinputfilter@end@interface fwnashvillefilter:gpuimagefiltergroup{ *ImageSource;} @end
////FWNASHVILLEFILTER.M//Fwmeituapp////Created by Hzkmn on 16/1/8.//copyright©2016 year Forrestwoo Co,.ltd. All rights reserved.//#import"FWNashvilleFilter.h"NSString*ConstKfwnashvilleshaderstring =shader_string (Precision lowpfloat; Varying HIGHP vec2 texturecoordinate; Uniform sampler2d inputimagetexture; Uniform sampler2d InputImageTexture2; voidMain () {VEC3 Texel=texture2d (Inputimagetexture, texturecoordinate). RGB; Texel=vec3 (texture2d (InputImageTexture2, VEC2 (TEXEL.R,.16666) . R, Texture2d (InputImageTexture2, VEC2 (TEXEL.G,.5) . G, Texture2d (InputImageTexture2, VEC2 (texel.b,.83333) . b); Gl_fragcolor= Vec4 (Texel,1.0); }); @implementation FWFilter1-(ID) init; { if(! (self =[Super initwithfragmentshaderfromstring:kfwnashvilleshaderstring])) { returnNil; } returnSelf ;} @end @implementation Fwnashvillefilter-(ID) init{if(! (self =[Super Init]) { returnNil; } UIImage*image = [UIImage imagenamed:@"Nashvillemap.png"]; ImageSource=[[Gpuimagepicture alloc] initwithimage:image]; FWFilter1*filter =[[FWFilter1 alloc] init]; [Self addfilter:filter]; [ImageSource addtarget:filter attexturelocation:1]; [ImageSource Processimage]; Self.initialfilters=[Nsarray arraywithobjects:filter, Nil]; Self.terminalfilter=filter; returnSelf ;} @end
Original
Full Project Code View I'm on GitHub
Let's look at a couple more effects.
iOS filter implementation of Nashville "Instagram"