├── README.md ├── 综合滤镜处理.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── liangxinchang.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── liangxinchang.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist └── 综合滤镜处理 ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Filter ├── Cirlce │ ├── Cirlce.fsh │ └── Cirlce.vsh ├── Glitch │ ├── Glitch.fsh │ └── Glitch.vsh ├── Gray │ ├── Gray.fsh │ └── Gray.vsh ├── HexagonMosaic │ ├── HexagonMosaic.fsh │ └── HexagonMosaic.vsh ├── Mosaic │ ├── Mosaic.fsh │ └── Mosaic.vsh ├── Normal │ ├── Normal.fsh │ └── Normal.vsh ├── Reversal │ ├── Reversal.fsh │ └── Reversal.vsh ├── Scale │ ├── Scale.fsh │ └── Scale.vsh ├── Shake │ ├── Shake.fsh │ └── Shake.vsh ├── ShineWhite │ ├── ShineWhite.fsh │ └── ShineWhite.vsh ├── SoulOut │ ├── SoulOut.fsh │ └── SoulOut.vsh └── TriangularMosaic │ ├── TriangularMosaic.fsh │ └── TriangularMosaic.vsh ├── Info.plist ├── Tool ├── FilterBar.h ├── FilterBar.m ├── FilterBarCell.h └── FilterBarCell.m ├── ViewController.h ├── ViewController.m ├── kaixin.jpg ├── main.m └── meimei.jpg /README.md: -------------------------------------------------------------------------------- 1 | # zonghelvjing 2 | 使用 OpenGL ES写的综合滤镜 3 | ![1949959-a030f702856392f5](https://user-images.githubusercontent.com/20158605/178395887-588027be-3fb7-4ce6-827f-e0a3bfedb4a9.jpg) 4 | ![1949959-017fc2355c5e0816](https://user-images.githubusercontent.com/20158605/178396039-cc6d20da-8fbd-4c7f-8d65-7141dc976a3d.jpg) 5 | ![1949959-cdbdcdd016b64a15](https://user-images.githubusercontent.com/20158605/178396046-887d1ed2-27d5-4363-a074-7bba170ecffc.jpg) 6 | ![1949959-03616de02a194826](https://user-images.githubusercontent.com/20158605/178396051-c7ea6977-fd48-4507-b74a-475f25c9ac72.jpg) 7 | -------------------------------------------------------------------------------- /综合滤镜处理.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | AC578F1622D2EBA2005AE0FB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AC578F1522D2EBA2005AE0FB /* AppDelegate.m */; }; 11 | AC578F1922D2EBA2005AE0FB /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AC578F1822D2EBA2005AE0FB /* ViewController.m */; }; 12 | AC578F1C22D2EBA2005AE0FB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AC578F1A22D2EBA2005AE0FB /* Main.storyboard */; }; 13 | AC578F1E22D2EBA3005AE0FB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AC578F1D22D2EBA3005AE0FB /* Assets.xcassets */; }; 14 | AC578F2122D2EBA3005AE0FB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AC578F1F22D2EBA3005AE0FB /* LaunchScreen.storyboard */; }; 15 | AC578F2422D2EBA3005AE0FB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AC578F2322D2EBA3005AE0FB /* main.m */; }; 16 | AC578F2F22D2EBD0005AE0FB /* FilterBarCell.m in Sources */ = {isa = PBXBuildFile; fileRef = AC578F2B22D2EBD0005AE0FB /* FilterBarCell.m */; }; 17 | AC578F3022D2EBD0005AE0FB /* FilterBar.m in Sources */ = {isa = PBXBuildFile; fileRef = AC578F2C22D2EBD0005AE0FB /* FilterBar.m */; }; 18 | AC578F3322D2EE60005AE0FB /* meimei.jpg in Resources */ = {isa = PBXBuildFile; fileRef = AC578F3222D2EE60005AE0FB /* meimei.jpg */; }; 19 | AC578F3522D2EE74005AE0FB /* kaixin.jpg in Resources */ = {isa = PBXBuildFile; fileRef = AC578F3422D2EE74005AE0FB /* kaixin.jpg */; }; 20 | ACA0452222D4270D00B2FA88 /* Normal.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACA0452122D4270D00B2FA88 /* Normal.fsh */; }; 21 | ACA0452422D4273000B2FA88 /* Normal.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACA0452322D4273000B2FA88 /* Normal.vsh */; }; 22 | ACA0452722D4371E00B2FA88 /* TriangularMosaic.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACA0452622D4371E00B2FA88 /* TriangularMosaic.fsh */; }; 23 | ACA0452922D4372F00B2FA88 /* TriangularMosaic.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACA0452822D4372F00B2FA88 /* TriangularMosaic.vsh */; }; 24 | ACA0452C22D43A9500B2FA88 /* Gray.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACA0452B22D43A9500B2FA88 /* Gray.fsh */; }; 25 | ACA0452E22D43AA400B2FA88 /* Gray.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACA0452D22D43AA400B2FA88 /* Gray.vsh */; }; 26 | ACBC4D0C22DF20D200A4FE75 /* Reversal.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D0A22DF20D200A4FE75 /* Reversal.fsh */; }; 27 | ACBC4D0D22DF20D200A4FE75 /* Reversal.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D0B22DF20D200A4FE75 /* Reversal.vsh */; }; 28 | ACBC4D1122DF216200A4FE75 /* Cirlce.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D0F22DF216100A4FE75 /* Cirlce.vsh */; }; 29 | ACBC4D1222DF216200A4FE75 /* Cirlce.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D1022DF216100A4FE75 /* Cirlce.fsh */; }; 30 | ACBC4D1622DF216D00A4FE75 /* Mosaic.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D1422DF216D00A4FE75 /* Mosaic.vsh */; }; 31 | ACBC4D1722DF216D00A4FE75 /* Mosaic.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D1522DF216D00A4FE75 /* Mosaic.fsh */; }; 32 | ACBC4D1B22DF217400A4FE75 /* HexagonMosaic.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D1922DF217300A4FE75 /* HexagonMosaic.fsh */; }; 33 | ACBC4D1C22DF217400A4FE75 /* HexagonMosaic.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D1A22DF217300A4FE75 /* HexagonMosaic.vsh */; }; 34 | ACBC4D2F22DF21E200A4FE75 /* Glitch.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D1E22DF21E200A4FE75 /* Glitch.vsh */; }; 35 | ACBC4D3022DF21E200A4FE75 /* Glitch.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D1F22DF21E200A4FE75 /* Glitch.fsh */; }; 36 | ACBC4D3122DF21E200A4FE75 /* ShineWhite.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D2122DF21E200A4FE75 /* ShineWhite.vsh */; }; 37 | ACBC4D3222DF21E200A4FE75 /* ShineWhite.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D2222DF21E200A4FE75 /* ShineWhite.fsh */; }; 38 | ACBC4D3322DF21E200A4FE75 /* Scale.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D2422DF21E200A4FE75 /* Scale.vsh */; }; 39 | ACBC4D3422DF21E200A4FE75 /* Scale.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D2522DF21E200A4FE75 /* Scale.fsh */; }; 40 | ACBC4D3522DF21E200A4FE75 /* Shake.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D2722DF21E200A4FE75 /* Shake.fsh */; }; 41 | ACBC4D3622DF21E200A4FE75 /* Shake.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D2822DF21E200A4FE75 /* Shake.vsh */; }; 42 | ACBC4D3722DF21E200A4FE75 /* SoulOut.vsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D2A22DF21E200A4FE75 /* SoulOut.vsh */; }; 43 | ACBC4D3822DF21E200A4FE75 /* SoulOut.fsh in Resources */ = {isa = PBXBuildFile; fileRef = ACBC4D2B22DF21E200A4FE75 /* SoulOut.fsh */; }; 44 | /* End PBXBuildFile section */ 45 | 46 | /* Begin PBXFileReference section */ 47 | AC578F1122D2EBA2005AE0FB /* 综合滤镜处理.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "综合滤镜处理.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | AC578F1422D2EBA2005AE0FB /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 49 | AC578F1522D2EBA2005AE0FB /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 50 | AC578F1722D2EBA2005AE0FB /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 51 | AC578F1822D2EBA2005AE0FB /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 52 | AC578F1B22D2EBA2005AE0FB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 53 | AC578F1D22D2EBA3005AE0FB /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 54 | AC578F2022D2EBA3005AE0FB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 55 | AC578F2222D2EBA3005AE0FB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | AC578F2322D2EBA3005AE0FB /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 57 | AC578F2B22D2EBD0005AE0FB /* FilterBarCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FilterBarCell.m; sourceTree = ""; }; 58 | AC578F2C22D2EBD0005AE0FB /* FilterBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FilterBar.m; sourceTree = ""; }; 59 | AC578F2D22D2EBD0005AE0FB /* FilterBarCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilterBarCell.h; sourceTree = ""; }; 60 | AC578F2E22D2EBD0005AE0FB /* FilterBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilterBar.h; sourceTree = ""; }; 61 | AC578F3222D2EE60005AE0FB /* meimei.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = meimei.jpg; sourceTree = ""; }; 62 | AC578F3422D2EE74005AE0FB /* kaixin.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = kaixin.jpg; sourceTree = ""; }; 63 | ACA0452122D4270D00B2FA88 /* Normal.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = Normal.fsh; sourceTree = ""; }; 64 | ACA0452322D4273000B2FA88 /* Normal.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = Normal.vsh; sourceTree = ""; }; 65 | ACA0452622D4371E00B2FA88 /* TriangularMosaic.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = TriangularMosaic.fsh; sourceTree = ""; }; 66 | ACA0452822D4372F00B2FA88 /* TriangularMosaic.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = TriangularMosaic.vsh; sourceTree = ""; }; 67 | ACA0452B22D43A9500B2FA88 /* Gray.fsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = Gray.fsh; sourceTree = ""; }; 68 | ACA0452D22D43AA400B2FA88 /* Gray.vsh */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; path = Gray.vsh; sourceTree = ""; }; 69 | ACBC4D0A22DF20D200A4FE75 /* Reversal.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Reversal.fsh; sourceTree = ""; }; 70 | ACBC4D0B22DF20D200A4FE75 /* Reversal.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Reversal.vsh; sourceTree = ""; }; 71 | ACBC4D0F22DF216100A4FE75 /* Cirlce.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Cirlce.vsh; sourceTree = ""; }; 72 | ACBC4D1022DF216100A4FE75 /* Cirlce.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Cirlce.fsh; sourceTree = ""; }; 73 | ACBC4D1422DF216D00A4FE75 /* Mosaic.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Mosaic.vsh; sourceTree = ""; }; 74 | ACBC4D1522DF216D00A4FE75 /* Mosaic.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Mosaic.fsh; sourceTree = ""; }; 75 | ACBC4D1922DF217300A4FE75 /* HexagonMosaic.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = HexagonMosaic.fsh; sourceTree = ""; }; 76 | ACBC4D1A22DF217300A4FE75 /* HexagonMosaic.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = HexagonMosaic.vsh; sourceTree = ""; }; 77 | ACBC4D1E22DF21E200A4FE75 /* Glitch.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Glitch.vsh; sourceTree = ""; }; 78 | ACBC4D1F22DF21E200A4FE75 /* Glitch.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Glitch.fsh; sourceTree = ""; }; 79 | ACBC4D2122DF21E200A4FE75 /* ShineWhite.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ShineWhite.vsh; sourceTree = ""; }; 80 | ACBC4D2222DF21E200A4FE75 /* ShineWhite.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = ShineWhite.fsh; sourceTree = ""; }; 81 | ACBC4D2422DF21E200A4FE75 /* Scale.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Scale.vsh; sourceTree = ""; }; 82 | ACBC4D2522DF21E200A4FE75 /* Scale.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Scale.fsh; sourceTree = ""; }; 83 | ACBC4D2722DF21E200A4FE75 /* Shake.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Shake.fsh; sourceTree = ""; }; 84 | ACBC4D2822DF21E200A4FE75 /* Shake.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = Shake.vsh; sourceTree = ""; }; 85 | ACBC4D2A22DF21E200A4FE75 /* SoulOut.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = SoulOut.vsh; sourceTree = ""; }; 86 | ACBC4D2B22DF21E200A4FE75 /* SoulOut.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = SoulOut.fsh; sourceTree = ""; }; 87 | /* End PBXFileReference section */ 88 | 89 | /* Begin PBXFrameworksBuildPhase section */ 90 | AC578F0E22D2EBA2005AE0FB /* Frameworks */ = { 91 | isa = PBXFrameworksBuildPhase; 92 | buildActionMask = 2147483647; 93 | files = ( 94 | ); 95 | runOnlyForDeploymentPostprocessing = 0; 96 | }; 97 | /* End PBXFrameworksBuildPhase section */ 98 | 99 | /* Begin PBXGroup section */ 100 | AC578F0822D2EBA2005AE0FB = { 101 | isa = PBXGroup; 102 | children = ( 103 | AC578F1322D2EBA2005AE0FB /* 综合滤镜处理 */, 104 | AC578F1222D2EBA2005AE0FB /* Products */, 105 | ); 106 | sourceTree = ""; 107 | }; 108 | AC578F1222D2EBA2005AE0FB /* Products */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | AC578F1122D2EBA2005AE0FB /* 综合滤镜处理.app */, 112 | ); 113 | name = Products; 114 | sourceTree = ""; 115 | }; 116 | AC578F1322D2EBA2005AE0FB /* 综合滤镜处理 */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | AC578F1422D2EBA2005AE0FB /* AppDelegate.h */, 120 | AC578F1522D2EBA2005AE0FB /* AppDelegate.m */, 121 | AC578F1722D2EBA2005AE0FB /* ViewController.h */, 122 | AC578F1822D2EBA2005AE0FB /* ViewController.m */, 123 | AC578F3422D2EE74005AE0FB /* kaixin.jpg */, 124 | AC578F3222D2EE60005AE0FB /* meimei.jpg */, 125 | AC578F3122D2EBFA005AE0FB /* Filter */, 126 | AC578F2A22D2EBD0005AE0FB /* Tool */, 127 | AC578F1A22D2EBA2005AE0FB /* Main.storyboard */, 128 | AC578F1D22D2EBA3005AE0FB /* Assets.xcassets */, 129 | AC578F1F22D2EBA3005AE0FB /* LaunchScreen.storyboard */, 130 | AC578F2222D2EBA3005AE0FB /* Info.plist */, 131 | AC578F2322D2EBA3005AE0FB /* main.m */, 132 | ); 133 | path = "综合滤镜处理"; 134 | sourceTree = ""; 135 | }; 136 | AC578F2A22D2EBD0005AE0FB /* Tool */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | AC578F2D22D2EBD0005AE0FB /* FilterBarCell.h */, 140 | AC578F2B22D2EBD0005AE0FB /* FilterBarCell.m */, 141 | AC578F2E22D2EBD0005AE0FB /* FilterBar.h */, 142 | AC578F2C22D2EBD0005AE0FB /* FilterBar.m */, 143 | ); 144 | path = Tool; 145 | sourceTree = ""; 146 | }; 147 | AC578F3122D2EBFA005AE0FB /* Filter */ = { 148 | isa = PBXGroup; 149 | children = ( 150 | ACBC4D1D22DF21E200A4FE75 /* Glitch */, 151 | ACBC4D2322DF21E200A4FE75 /* Scale */, 152 | ACBC4D2622DF21E200A4FE75 /* Shake */, 153 | ACBC4D2022DF21E200A4FE75 /* ShineWhite */, 154 | ACBC4D2922DF21E200A4FE75 /* SoulOut */, 155 | ACBC4D1822DF217300A4FE75 /* HexagonMosaic */, 156 | ACBC4D1322DF216D00A4FE75 /* Mosaic */, 157 | ACBC4D0E22DF216100A4FE75 /* Cirlce */, 158 | ACBC4D0922DF20D200A4FE75 /* Reversal */, 159 | ACA0452A22D43A7D00B2FA88 /* Gray */, 160 | ACA0452522D4370C00B2FA88 /* TriangularMosaic */, 161 | ACA0452022D426D500B2FA88 /* Normal */, 162 | ); 163 | path = Filter; 164 | sourceTree = ""; 165 | }; 166 | ACA0452022D426D500B2FA88 /* Normal */ = { 167 | isa = PBXGroup; 168 | children = ( 169 | ACA0452122D4270D00B2FA88 /* Normal.fsh */, 170 | ACA0452322D4273000B2FA88 /* Normal.vsh */, 171 | ); 172 | path = Normal; 173 | sourceTree = ""; 174 | }; 175 | ACA0452522D4370C00B2FA88 /* TriangularMosaic */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | ACA0452622D4371E00B2FA88 /* TriangularMosaic.fsh */, 179 | ACA0452822D4372F00B2FA88 /* TriangularMosaic.vsh */, 180 | ); 181 | path = TriangularMosaic; 182 | sourceTree = ""; 183 | }; 184 | ACA0452A22D43A7D00B2FA88 /* Gray */ = { 185 | isa = PBXGroup; 186 | children = ( 187 | ACA0452B22D43A9500B2FA88 /* Gray.fsh */, 188 | ACA0452D22D43AA400B2FA88 /* Gray.vsh */, 189 | ); 190 | path = Gray; 191 | sourceTree = ""; 192 | }; 193 | ACBC4D0922DF20D200A4FE75 /* Reversal */ = { 194 | isa = PBXGroup; 195 | children = ( 196 | ACBC4D0A22DF20D200A4FE75 /* Reversal.fsh */, 197 | ACBC4D0B22DF20D200A4FE75 /* Reversal.vsh */, 198 | ); 199 | path = Reversal; 200 | sourceTree = ""; 201 | }; 202 | ACBC4D0E22DF216100A4FE75 /* Cirlce */ = { 203 | isa = PBXGroup; 204 | children = ( 205 | ACBC4D0F22DF216100A4FE75 /* Cirlce.vsh */, 206 | ACBC4D1022DF216100A4FE75 /* Cirlce.fsh */, 207 | ); 208 | path = Cirlce; 209 | sourceTree = ""; 210 | }; 211 | ACBC4D1322DF216D00A4FE75 /* Mosaic */ = { 212 | isa = PBXGroup; 213 | children = ( 214 | ACBC4D1422DF216D00A4FE75 /* Mosaic.vsh */, 215 | ACBC4D1522DF216D00A4FE75 /* Mosaic.fsh */, 216 | ); 217 | path = Mosaic; 218 | sourceTree = ""; 219 | }; 220 | ACBC4D1822DF217300A4FE75 /* HexagonMosaic */ = { 221 | isa = PBXGroup; 222 | children = ( 223 | ACBC4D1922DF217300A4FE75 /* HexagonMosaic.fsh */, 224 | ACBC4D1A22DF217300A4FE75 /* HexagonMosaic.vsh */, 225 | ); 226 | path = HexagonMosaic; 227 | sourceTree = ""; 228 | }; 229 | ACBC4D1D22DF21E200A4FE75 /* Glitch */ = { 230 | isa = PBXGroup; 231 | children = ( 232 | ACBC4D1E22DF21E200A4FE75 /* Glitch.vsh */, 233 | ACBC4D1F22DF21E200A4FE75 /* Glitch.fsh */, 234 | ); 235 | path = Glitch; 236 | sourceTree = ""; 237 | }; 238 | ACBC4D2022DF21E200A4FE75 /* ShineWhite */ = { 239 | isa = PBXGroup; 240 | children = ( 241 | ACBC4D2122DF21E200A4FE75 /* ShineWhite.vsh */, 242 | ACBC4D2222DF21E200A4FE75 /* ShineWhite.fsh */, 243 | ); 244 | path = ShineWhite; 245 | sourceTree = ""; 246 | }; 247 | ACBC4D2322DF21E200A4FE75 /* Scale */ = { 248 | isa = PBXGroup; 249 | children = ( 250 | ACBC4D2422DF21E200A4FE75 /* Scale.vsh */, 251 | ACBC4D2522DF21E200A4FE75 /* Scale.fsh */, 252 | ); 253 | path = Scale; 254 | sourceTree = ""; 255 | }; 256 | ACBC4D2622DF21E200A4FE75 /* Shake */ = { 257 | isa = PBXGroup; 258 | children = ( 259 | ACBC4D2722DF21E200A4FE75 /* Shake.fsh */, 260 | ACBC4D2822DF21E200A4FE75 /* Shake.vsh */, 261 | ); 262 | path = Shake; 263 | sourceTree = ""; 264 | }; 265 | ACBC4D2922DF21E200A4FE75 /* SoulOut */ = { 266 | isa = PBXGroup; 267 | children = ( 268 | ACBC4D2A22DF21E200A4FE75 /* SoulOut.vsh */, 269 | ACBC4D2B22DF21E200A4FE75 /* SoulOut.fsh */, 270 | ); 271 | path = SoulOut; 272 | sourceTree = ""; 273 | }; 274 | /* End PBXGroup section */ 275 | 276 | /* Begin PBXNativeTarget section */ 277 | AC578F1022D2EBA2005AE0FB /* 综合滤镜处理 */ = { 278 | isa = PBXNativeTarget; 279 | buildConfigurationList = AC578F2722D2EBA3005AE0FB /* Build configuration list for PBXNativeTarget "综合滤镜处理" */; 280 | buildPhases = ( 281 | AC578F0D22D2EBA2005AE0FB /* Sources */, 282 | AC578F0E22D2EBA2005AE0FB /* Frameworks */, 283 | AC578F0F22D2EBA2005AE0FB /* Resources */, 284 | ); 285 | buildRules = ( 286 | ); 287 | dependencies = ( 288 | ); 289 | name = "综合滤镜处理"; 290 | productName = "综合滤镜处理"; 291 | productReference = AC578F1122D2EBA2005AE0FB /* 综合滤镜处理.app */; 292 | productType = "com.apple.product-type.application"; 293 | }; 294 | /* End PBXNativeTarget section */ 295 | 296 | /* Begin PBXProject section */ 297 | AC578F0922D2EBA2005AE0FB /* Project object */ = { 298 | isa = PBXProject; 299 | attributes = { 300 | LastUpgradeCheck = 1020; 301 | ORGANIZATIONNAME = Tainfn; 302 | TargetAttributes = { 303 | AC578F1022D2EBA2005AE0FB = { 304 | CreatedOnToolsVersion = 10.2.1; 305 | }; 306 | }; 307 | }; 308 | buildConfigurationList = AC578F0C22D2EBA2005AE0FB /* Build configuration list for PBXProject "综合滤镜处理" */; 309 | compatibilityVersion = "Xcode 9.3"; 310 | developmentRegion = en; 311 | hasScannedForEncodings = 0; 312 | knownRegions = ( 313 | en, 314 | Base, 315 | ); 316 | mainGroup = AC578F0822D2EBA2005AE0FB; 317 | productRefGroup = AC578F1222D2EBA2005AE0FB /* Products */; 318 | projectDirPath = ""; 319 | projectRoot = ""; 320 | targets = ( 321 | AC578F1022D2EBA2005AE0FB /* 综合滤镜处理 */, 322 | ); 323 | }; 324 | /* End PBXProject section */ 325 | 326 | /* Begin PBXResourcesBuildPhase section */ 327 | AC578F0F22D2EBA2005AE0FB /* Resources */ = { 328 | isa = PBXResourcesBuildPhase; 329 | buildActionMask = 2147483647; 330 | files = ( 331 | ACBC4D3322DF21E200A4FE75 /* Scale.vsh in Resources */, 332 | ACBC4D3722DF21E200A4FE75 /* SoulOut.vsh in Resources */, 333 | ACA0452722D4371E00B2FA88 /* TriangularMosaic.fsh in Resources */, 334 | ACBC4D1122DF216200A4FE75 /* Cirlce.vsh in Resources */, 335 | ACBC4D3422DF21E200A4FE75 /* Scale.fsh in Resources */, 336 | ACA0452922D4372F00B2FA88 /* TriangularMosaic.vsh in Resources */, 337 | ACA0452422D4273000B2FA88 /* Normal.vsh in Resources */, 338 | ACBC4D1C22DF217400A4FE75 /* HexagonMosaic.vsh in Resources */, 339 | ACBC4D3022DF21E200A4FE75 /* Glitch.fsh in Resources */, 340 | ACBC4D3622DF21E200A4FE75 /* Shake.vsh in Resources */, 341 | ACA0452222D4270D00B2FA88 /* Normal.fsh in Resources */, 342 | ACBC4D1622DF216D00A4FE75 /* Mosaic.vsh in Resources */, 343 | ACBC4D1722DF216D00A4FE75 /* Mosaic.fsh in Resources */, 344 | ACBC4D3222DF21E200A4FE75 /* ShineWhite.fsh in Resources */, 345 | ACA0452C22D43A9500B2FA88 /* Gray.fsh in Resources */, 346 | ACBC4D1222DF216200A4FE75 /* Cirlce.fsh in Resources */, 347 | ACBC4D3522DF21E200A4FE75 /* Shake.fsh in Resources */, 348 | AC578F2122D2EBA3005AE0FB /* LaunchScreen.storyboard in Resources */, 349 | AC578F3522D2EE74005AE0FB /* kaixin.jpg in Resources */, 350 | AC578F1E22D2EBA3005AE0FB /* Assets.xcassets in Resources */, 351 | ACBC4D1B22DF217400A4FE75 /* HexagonMosaic.fsh in Resources */, 352 | ACBC4D3822DF21E200A4FE75 /* SoulOut.fsh in Resources */, 353 | AC578F3322D2EE60005AE0FB /* meimei.jpg in Resources */, 354 | AC578F1C22D2EBA2005AE0FB /* Main.storyboard in Resources */, 355 | ACBC4D2F22DF21E200A4FE75 /* Glitch.vsh in Resources */, 356 | ACBC4D0D22DF20D200A4FE75 /* Reversal.vsh in Resources */, 357 | ACA0452E22D43AA400B2FA88 /* Gray.vsh in Resources */, 358 | ACBC4D0C22DF20D200A4FE75 /* Reversal.fsh in Resources */, 359 | ACBC4D3122DF21E200A4FE75 /* ShineWhite.vsh in Resources */, 360 | ); 361 | runOnlyForDeploymentPostprocessing = 0; 362 | }; 363 | /* End PBXResourcesBuildPhase section */ 364 | 365 | /* Begin PBXSourcesBuildPhase section */ 366 | AC578F0D22D2EBA2005AE0FB /* Sources */ = { 367 | isa = PBXSourcesBuildPhase; 368 | buildActionMask = 2147483647; 369 | files = ( 370 | AC578F1922D2EBA2005AE0FB /* ViewController.m in Sources */, 371 | AC578F2F22D2EBD0005AE0FB /* FilterBarCell.m in Sources */, 372 | AC578F2422D2EBA3005AE0FB /* main.m in Sources */, 373 | AC578F3022D2EBD0005AE0FB /* FilterBar.m in Sources */, 374 | AC578F1622D2EBA2005AE0FB /* AppDelegate.m in Sources */, 375 | ); 376 | runOnlyForDeploymentPostprocessing = 0; 377 | }; 378 | /* End PBXSourcesBuildPhase section */ 379 | 380 | /* Begin PBXVariantGroup section */ 381 | AC578F1A22D2EBA2005AE0FB /* Main.storyboard */ = { 382 | isa = PBXVariantGroup; 383 | children = ( 384 | AC578F1B22D2EBA2005AE0FB /* Base */, 385 | ); 386 | name = Main.storyboard; 387 | sourceTree = ""; 388 | }; 389 | AC578F1F22D2EBA3005AE0FB /* LaunchScreen.storyboard */ = { 390 | isa = PBXVariantGroup; 391 | children = ( 392 | AC578F2022D2EBA3005AE0FB /* Base */, 393 | ); 394 | name = LaunchScreen.storyboard; 395 | sourceTree = ""; 396 | }; 397 | /* End PBXVariantGroup section */ 398 | 399 | /* Begin XCBuildConfiguration section */ 400 | AC578F2522D2EBA3005AE0FB /* Debug */ = { 401 | isa = XCBuildConfiguration; 402 | buildSettings = { 403 | ALWAYS_SEARCH_USER_PATHS = NO; 404 | CLANG_ANALYZER_NONNULL = YES; 405 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 406 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 407 | CLANG_CXX_LIBRARY = "libc++"; 408 | CLANG_ENABLE_MODULES = YES; 409 | CLANG_ENABLE_OBJC_ARC = YES; 410 | CLANG_ENABLE_OBJC_WEAK = YES; 411 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 412 | CLANG_WARN_BOOL_CONVERSION = YES; 413 | CLANG_WARN_COMMA = YES; 414 | CLANG_WARN_CONSTANT_CONVERSION = YES; 415 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 416 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 417 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 418 | CLANG_WARN_EMPTY_BODY = YES; 419 | CLANG_WARN_ENUM_CONVERSION = YES; 420 | CLANG_WARN_INFINITE_RECURSION = YES; 421 | CLANG_WARN_INT_CONVERSION = YES; 422 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 423 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 424 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 425 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 426 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 427 | CLANG_WARN_STRICT_PROTOTYPES = YES; 428 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 429 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 430 | CLANG_WARN_UNREACHABLE_CODE = YES; 431 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 432 | CODE_SIGN_IDENTITY = "iPhone Developer"; 433 | COPY_PHASE_STRIP = NO; 434 | DEBUG_INFORMATION_FORMAT = dwarf; 435 | ENABLE_STRICT_OBJC_MSGSEND = YES; 436 | ENABLE_TESTABILITY = YES; 437 | GCC_C_LANGUAGE_STANDARD = gnu11; 438 | GCC_DYNAMIC_NO_PIC = NO; 439 | GCC_NO_COMMON_BLOCKS = YES; 440 | GCC_OPTIMIZATION_LEVEL = 0; 441 | GCC_PREPROCESSOR_DEFINITIONS = ( 442 | "DEBUG=1", 443 | "$(inherited)", 444 | ); 445 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 446 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 447 | GCC_WARN_UNDECLARED_SELECTOR = YES; 448 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 449 | GCC_WARN_UNUSED_FUNCTION = YES; 450 | GCC_WARN_UNUSED_VARIABLE = YES; 451 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 452 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 453 | MTL_FAST_MATH = YES; 454 | ONLY_ACTIVE_ARCH = YES; 455 | SDKROOT = iphoneos; 456 | }; 457 | name = Debug; 458 | }; 459 | AC578F2622D2EBA3005AE0FB /* Release */ = { 460 | isa = XCBuildConfiguration; 461 | buildSettings = { 462 | ALWAYS_SEARCH_USER_PATHS = NO; 463 | CLANG_ANALYZER_NONNULL = YES; 464 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 465 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 466 | CLANG_CXX_LIBRARY = "libc++"; 467 | CLANG_ENABLE_MODULES = YES; 468 | CLANG_ENABLE_OBJC_ARC = YES; 469 | CLANG_ENABLE_OBJC_WEAK = YES; 470 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 471 | CLANG_WARN_BOOL_CONVERSION = YES; 472 | CLANG_WARN_COMMA = YES; 473 | CLANG_WARN_CONSTANT_CONVERSION = YES; 474 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 475 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 476 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 477 | CLANG_WARN_EMPTY_BODY = YES; 478 | CLANG_WARN_ENUM_CONVERSION = YES; 479 | CLANG_WARN_INFINITE_RECURSION = YES; 480 | CLANG_WARN_INT_CONVERSION = YES; 481 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 482 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 483 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 484 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 485 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 486 | CLANG_WARN_STRICT_PROTOTYPES = YES; 487 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 488 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 489 | CLANG_WARN_UNREACHABLE_CODE = YES; 490 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 491 | CODE_SIGN_IDENTITY = "iPhone Developer"; 492 | COPY_PHASE_STRIP = NO; 493 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 494 | ENABLE_NS_ASSERTIONS = NO; 495 | ENABLE_STRICT_OBJC_MSGSEND = YES; 496 | GCC_C_LANGUAGE_STANDARD = gnu11; 497 | GCC_NO_COMMON_BLOCKS = YES; 498 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 499 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 500 | GCC_WARN_UNDECLARED_SELECTOR = YES; 501 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 502 | GCC_WARN_UNUSED_FUNCTION = YES; 503 | GCC_WARN_UNUSED_VARIABLE = YES; 504 | IPHONEOS_DEPLOYMENT_TARGET = 12.2; 505 | MTL_ENABLE_DEBUG_INFO = NO; 506 | MTL_FAST_MATH = YES; 507 | SDKROOT = iphoneos; 508 | VALIDATE_PRODUCT = YES; 509 | }; 510 | name = Release; 511 | }; 512 | AC578F2822D2EBA3005AE0FB /* Debug */ = { 513 | isa = XCBuildConfiguration; 514 | buildSettings = { 515 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 516 | CODE_SIGN_STYLE = Automatic; 517 | INFOPLIST_FILE = "综合滤镜处理/Info.plist"; 518 | LD_RUNPATH_SEARCH_PATHS = ( 519 | "$(inherited)", 520 | "@executable_path/Frameworks", 521 | ); 522 | PRODUCT_BUNDLE_IDENTIFIER = "com.Tianfn.------"; 523 | PRODUCT_NAME = "$(TARGET_NAME)"; 524 | TARGETED_DEVICE_FAMILY = "1,2"; 525 | }; 526 | name = Debug; 527 | }; 528 | AC578F2922D2EBA3005AE0FB /* Release */ = { 529 | isa = XCBuildConfiguration; 530 | buildSettings = { 531 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 532 | CODE_SIGN_STYLE = Automatic; 533 | INFOPLIST_FILE = "综合滤镜处理/Info.plist"; 534 | LD_RUNPATH_SEARCH_PATHS = ( 535 | "$(inherited)", 536 | "@executable_path/Frameworks", 537 | ); 538 | PRODUCT_BUNDLE_IDENTIFIER = "com.Tianfn.------"; 539 | PRODUCT_NAME = "$(TARGET_NAME)"; 540 | TARGETED_DEVICE_FAMILY = "1,2"; 541 | }; 542 | name = Release; 543 | }; 544 | /* End XCBuildConfiguration section */ 545 | 546 | /* Begin XCConfigurationList section */ 547 | AC578F0C22D2EBA2005AE0FB /* Build configuration list for PBXProject "综合滤镜处理" */ = { 548 | isa = XCConfigurationList; 549 | buildConfigurations = ( 550 | AC578F2522D2EBA3005AE0FB /* Debug */, 551 | AC578F2622D2EBA3005AE0FB /* Release */, 552 | ); 553 | defaultConfigurationIsVisible = 0; 554 | defaultConfigurationName = Release; 555 | }; 556 | AC578F2722D2EBA3005AE0FB /* Build configuration list for PBXNativeTarget "综合滤镜处理" */ = { 557 | isa = XCConfigurationList; 558 | buildConfigurations = ( 559 | AC578F2822D2EBA3005AE0FB /* Debug */, 560 | AC578F2922D2EBA3005AE0FB /* Release */, 561 | ); 562 | defaultConfigurationIsVisible = 0; 563 | defaultConfigurationName = Release; 564 | }; 565 | /* End XCConfigurationList section */ 566 | }; 567 | rootObject = AC578F0922D2EBA2005AE0FB /* Project object */; 568 | } 569 | -------------------------------------------------------------------------------- /综合滤镜处理.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /综合滤镜处理.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /综合滤镜处理.xcodeproj/project.xcworkspace/xcuserdata/liangxinchang.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinKoko/zonghelvjing/da398864241dc421500058045cb768b3a6670638/综合滤镜处理.xcodeproj/project.xcworkspace/xcuserdata/liangxinchang.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /综合滤镜处理.xcodeproj/xcuserdata/liangxinchang.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /综合滤镜处理.xcodeproj/xcuserdata/liangxinchang.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | 综合滤镜处理.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /综合滤镜处理/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // 综合滤镜处理 4 | // 5 | // Created by 梁新昌 on 2019/7/8. 6 | // Copyright © 2019 Tainfn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /综合滤镜处理/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // 综合滤镜处理 4 | // 5 | // Created by 梁新昌 on 2019/7/8. 6 | // Copyright © 2019 Tainfn. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /综合滤镜处理/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /综合滤镜处理/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /综合滤镜处理/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /综合滤镜处理/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Cirlce/Cirlce.fsh: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | const float PI = 3.14159265; 4 | uniform sampler2D Texture; 5 | 6 | const float uD = 80.0; 7 | const float uR = 0.5; 8 | 9 | varying vec2 TextureCoordsVarying; 10 | 11 | void main() 12 | { 13 | ivec2 ires = ivec2(512, 512); 14 | float Res = float(ires.s); 15 | 16 | vec2 st = TextureCoordsVarying; 17 | float Radius = Res * uR; 18 | 19 | vec2 xy = Res * st; 20 | 21 | vec2 dxy = xy - vec2(Res/2., Res/2.); 22 | float r = length(dxy); 23 | 24 | //(1.0 - r/Radius); 25 | float beta = atan(dxy.y, dxy.x) + radians(uD) * 2.0 * (-(r/Radius)*(r/Radius) + 1.0); 26 | 27 | vec2 xy1 = xy; 28 | if(r<=Radius) 29 | { 30 | xy1 = Res/2. + r*vec2(cos(beta), sin(beta)); 31 | } 32 | 33 | st = xy1/Res; 34 | 35 | vec3 irgb = texture2D(Texture, st).rgb; 36 | 37 | gl_FragColor = vec4( irgb, 1.0 ); 38 | } 39 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Cirlce/Cirlce.vsh: -------------------------------------------------------------------------------- 1 | 2 | attribute vec4 Position; 3 | attribute vec2 TextureCoords; 4 | varying vec2 TextureCoordsVarying; 5 | 6 | void main (void) { 7 | gl_Position = Position; 8 | TextureCoordsVarying = TextureCoords; 9 | } 10 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Glitch/Glitch.fsh: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | uniform sampler2D Texture; 4 | varying vec2 TextureCoordsVarying; 5 | 6 | uniform float Time; 7 | 8 | const float PI = 3.1415926; 9 | 10 | float rand(float n) { 11 | return fract(sin(n) * 43758.5453123); 12 | } 13 | 14 | void main (void) { 15 | float maxJitter = 0.06; 16 | float duration = 0.3; 17 | float colorROffset = 0.01; 18 | float colorBOffset = -0.025; 19 | 20 | float time = mod(Time, duration * 2.0); 21 | float amplitude = max(sin(time * (PI / duration)), 0.0); 22 | 23 | float jitter = rand(TextureCoordsVarying.y) * 2.0 - 1.0; // -1~1 24 | bool needOffset = abs(jitter) < maxJitter * amplitude; 25 | 26 | float textureX = TextureCoordsVarying.x + (needOffset ? jitter : (jitter * amplitude * 0.006)); 27 | vec2 textureCoords = vec2(textureX, TextureCoordsVarying.y); 28 | 29 | vec4 mask = texture2D(Texture, textureCoords); 30 | vec4 maskR = texture2D(Texture, textureCoords + vec2(colorROffset * amplitude, 0.0)); 31 | vec4 maskB = texture2D(Texture, textureCoords + vec2(colorBOffset * amplitude, 0.0)); 32 | 33 | gl_FragColor = vec4(maskR.r, mask.g, maskB.b, mask.a); 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Glitch/Glitch.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 Position; 2 | attribute vec2 TextureCoords; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | void main (void) { 6 | gl_Position = Position; 7 | TextureCoordsVarying = TextureCoords; 8 | } 9 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Gray/Gray.fsh: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | uniform sampler2D Texture; 3 | varying vec2 TextureCoordsVarying; 4 | const highp vec3 W = vec3(0.2125, 0.7154, 0.0721); 5 | 6 | void main (void) { 7 | 8 | vec4 mask = texture2D(Texture, TextureCoordsVarying); 9 | float luminance = dot(mask.rgb, W); 10 | gl_FragColor = vec4(vec3(luminance), 1.0); 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Gray/Gray.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 Position; 2 | attribute vec2 TextureCoords; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | void main (void) { 6 | gl_Position = Position; 7 | TextureCoordsVarying = TextureCoords; 8 | } 9 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/HexagonMosaic/HexagonMosaic.fsh: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | uniform sampler2D Texture; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | const float mosaicSize = 0.03; 6 | 7 | void main (void) 8 | { 9 | float length = mosaicSize; 10 | float TR = 0.866025; 11 | 12 | float x = TextureCoordsVarying.x; 13 | float y = TextureCoordsVarying.y; 14 | 15 | int wx = int(x / 1.5 / length); 16 | int wy = int(y / TR / length); 17 | vec2 v1, v2, vn; 18 | 19 | if (wx/2 * 2 == wx) { 20 | if (wy/2 * 2 == wy) { 21 | //(0,0),(1,1) 22 | v1 = vec2(length * 1.5 * float(wx), length * TR * float(wy)); 23 | v2 = vec2(length * 1.5 * float(wx + 1), length * TR * float(wy + 1)); 24 | } else { 25 | //(0,1),(1,0) 26 | v1 = vec2(length * 1.5 * float(wx), length * TR * float(wy + 1)); 27 | v2 = vec2(length * 1.5 * float(wx + 1), length * TR * float(wy)); 28 | } 29 | }else { 30 | if (wy/2 * 2 == wy) { 31 | //(0,1),(1,0) 32 | v1 = vec2(length * 1.5 * float(wx), length * TR * float(wy + 1)); 33 | v2 = vec2(length * 1.5 * float(wx + 1), length * TR * float(wy)); 34 | } else { 35 | //(0,0),(1,1) 36 | v1 = vec2(length * 1.5 * float(wx), length * TR * float(wy)); 37 | v2 = vec2(length * 1.5 * float(wx + 1), length * TR * float(wy + 1)); 38 | } 39 | } 40 | 41 | float s1 = sqrt(pow(v1.x - x, 2.0) + pow(v1.y - y, 2.0)); 42 | float s2 = sqrt(pow(v2.x - x, 2.0) + pow(v2.y - y, 2.0)); 43 | if (s1 < s2) { 44 | vn = v1; 45 | } else { 46 | vn = v2; 47 | } 48 | vec4 color = texture2D(Texture, vn); 49 | 50 | gl_FragColor = color; 51 | 52 | } 53 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/HexagonMosaic/HexagonMosaic.vsh: -------------------------------------------------------------------------------- 1 | 2 | attribute vec4 Position; 3 | attribute vec2 TextureCoords; 4 | varying vec2 TextureCoordsVarying; 5 | 6 | void main (void) { 7 | gl_Position = Position; 8 | TextureCoordsVarying = TextureCoords; 9 | } 10 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Mosaic/Mosaic.fsh: -------------------------------------------------------------------------------- 1 | precision mediump float; 2 | 3 | varying vec2 TextureCoordsVarying; 4 | uniform sampler2D Texture; 5 | const vec2 TexSize = vec2(100.0, 100.0); 6 | const vec2 mosaicSize = vec2(1.0, 1.0); 7 | 8 | void main() 9 | { 10 | vec2 intXY = vec2(TextureCoordsVarying.x*TexSize.x, TextureCoordsVarying.y*TexSize.y); 11 | vec2 XYMosaic = vec2(floor(intXY.x/mosaicSize.x)*mosaicSize.x, floor(intXY.y/mosaicSize.y)*mosaicSize.y); 12 | vec2 UVMosaic = vec2(XYMosaic.x/TexSize.x, XYMosaic.y/TexSize.y); 13 | vec4 color = texture2D(Texture, UVMosaic); 14 | gl_FragColor = color; 15 | } 16 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Mosaic/Mosaic.vsh: -------------------------------------------------------------------------------- 1 | 2 | attribute vec4 Position; 3 | attribute vec2 TextureCoords; 4 | varying vec2 TextureCoordsVarying; 5 | 6 | void main (void) { 7 | gl_Position = Position; 8 | TextureCoordsVarying = TextureCoords; 9 | } 10 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Normal/Normal.fsh: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | uniform sampler2D Texture; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | void main (void) { 6 | vec4 mask = texture2D(Texture, TextureCoordsVarying); 7 | gl_FragColor = vec4(mask.rgb, 1.0); 8 | } 9 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Normal/Normal.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 Position; 2 | attribute vec2 TextureCoords; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | void main (void) { 6 | gl_Position = Position; 7 | TextureCoordsVarying = TextureCoords; 8 | } 9 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Reversal/Reversal.fsh: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | uniform sampler2D Texture; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | void main (void) { 6 | 7 | vec4 color = texture2D(Texture, vec2(1.0 - TextureCoordsVarying.x, 1.0 - TextureCoordsVarying.y)); 8 | 9 | gl_FragColor = color; 10 | } 11 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Reversal/Reversal.vsh: -------------------------------------------------------------------------------- 1 | 2 | attribute vec4 Position; 3 | attribute vec2 TextureCoords; 4 | varying vec2 TextureCoordsVarying; 5 | 6 | void main (void) { 7 | gl_Position = Position; 8 | TextureCoordsVarying = TextureCoords; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Scale/Scale.fsh: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | uniform sampler2D Texture; 4 | varying vec2 TextureCoordsVarying; 5 | 6 | void main (void) { 7 | vec4 mask = texture2D(Texture, TextureCoordsVarying); 8 | gl_FragColor = vec4(mask.rgb, 1.0); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Scale/Scale.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 Position; 2 | attribute vec2 TextureCoords; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | uniform float Time; 6 | 7 | const float PI = 3.1415926; 8 | 9 | void main (void) { 10 | float duration = 0.6; 11 | float maxAmplitude = 0.3; 12 | 13 | float time = mod(Time, duration); 14 | float amplitude = 1.0 + maxAmplitude * abs(sin(time * (PI / duration))); 15 | 16 | gl_Position = vec4(Position.x * amplitude, Position.y * amplitude, Position.zw); 17 | TextureCoordsVarying = TextureCoords; 18 | } 19 | 20 | 21 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Shake/Shake.fsh: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | uniform sampler2D Texture; 4 | varying vec2 TextureCoordsVarying; 5 | 6 | uniform float Time; 7 | 8 | void main (void) { 9 | float duration = 0.7; 10 | float maxScale = 1.1; 11 | float offset = 0.02; 12 | 13 | float progress = mod(Time, duration) / duration; // 0~1 14 | vec2 offsetCoords = vec2(offset, offset) * progress; 15 | float scale = 1.0 + (maxScale - 1.0) * progress; 16 | 17 | vec2 ScaleTextureCoords = vec2(0.5, 0.5) + (TextureCoordsVarying - vec2(0.5, 0.5)) / scale; 18 | 19 | vec4 maskR = texture2D(Texture, ScaleTextureCoords + offsetCoords); 20 | vec4 maskB = texture2D(Texture, ScaleTextureCoords - offsetCoords); 21 | vec4 mask = texture2D(Texture, ScaleTextureCoords); 22 | 23 | gl_FragColor = vec4(maskR.r, mask.g, maskB.b, mask.a); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/Shake/Shake.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 Position; 2 | attribute vec2 TextureCoords; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | void main (void) { 6 | gl_Position = Position; 7 | TextureCoordsVarying = TextureCoords; 8 | } 9 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/ShineWhite/ShineWhite.fsh: -------------------------------------------------------------------------------- 1 | 2 | precision highp float; 3 | uniform sampler2D Texture; 4 | varying vec2 TextureCoordsVarying; 5 | uniform float Time; 6 | const float PI = 3.1415926; 7 | 8 | void main (void) { 9 | 10 | 11 | float duration = 0.6; 12 | float time = mod(Time, duration); 13 | vec4 whiteMask = vec4(1.0, 1.0, 1.0, 1.0); 14 | float amplitude = abs(sin(time * (PI / duration))); 15 | vec4 mask = texture2D(Texture, TextureCoordsVarying); 16 | gl_FragColor = mask * (1.0 - amplitude) + whiteMask * amplitude; 17 | } 18 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/ShineWhite/ShineWhite.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 Position; 2 | attribute vec2 TextureCoords; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | void main (void) { 6 | gl_Position = Position; 7 | TextureCoordsVarying = TextureCoords; 8 | } 9 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/SoulOut/SoulOut.fsh: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | 3 | uniform sampler2D Texture; 4 | varying vec2 TextureCoordsVarying; 5 | 6 | uniform float Time; 7 | 8 | void main (void) { 9 | float duration = 0.7; 10 | float maxAlpha = 0.4; 11 | float maxScale = 1.8; 12 | 13 | float progress = mod(Time, duration) / duration; // 0~1 14 | float alpha = maxAlpha * (1.0 - progress); 15 | float scale = 1.0 + (maxScale - 1.0) * progress; 16 | 17 | float weakX = 0.5 + (TextureCoordsVarying.x - 0.5) / scale; 18 | float weakY = 0.5 + (TextureCoordsVarying.y - 0.5) / scale; 19 | vec2 weakTextureCoords = vec2(weakX, weakY); 20 | 21 | vec4 weakMask = texture2D(Texture, weakTextureCoords); 22 | 23 | vec4 mask = texture2D(Texture, TextureCoordsVarying); 24 | 25 | gl_FragColor = mask * (1.0 - alpha) + weakMask * alpha; 26 | } 27 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/SoulOut/SoulOut.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 Position; 2 | attribute vec2 TextureCoords; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | void main (void) { 6 | gl_Position = Position; 7 | TextureCoordsVarying = TextureCoords; 8 | } 9 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/TriangularMosaic/TriangularMosaic.fsh: -------------------------------------------------------------------------------- 1 | precision highp float; 2 | uniform sampler2D Texture; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | float mosaicSize = 0.03; 6 | 7 | void main (void){ 8 | 9 | const float TR = 0.866025; 10 | const float PI6 = 0.523599; 11 | 12 | float x = TextureCoordsVarying.x; 13 | float y = TextureCoordsVarying.y; 14 | 15 | int wx = int(x/(1.5 * mosaicSize)); 16 | int wy = int(y/(TR * mosaicSize)); 17 | 18 | vec2 v1, v2, vn; 19 | 20 | if (wx / 2 * 2 == wx) { 21 | if (wy/2 * 2 == wy) { 22 | v1 = vec2(mosaicSize * 1.5 * float(wx), mosaicSize * TR * float(wy)); 23 | v2 = vec2(mosaicSize * 1.5 * float(wx + 1), mosaicSize * TR * float(wy + 1)); 24 | } else { 25 | v1 = vec2(mosaicSize * 1.5 * float(wx), mosaicSize * TR * float(wy + 1)); 26 | v2 = vec2(mosaicSize * 1.5 * float(wx + 1), mosaicSize * TR * float(wy)); 27 | } 28 | } else { 29 | if (wy/2 * 2 == wy) { 30 | v1 = vec2(mosaicSize * 1.5 * float(wx), mosaicSize * TR * float(wy + 1)); 31 | v2 = vec2(mosaicSize * 1.5 * float(wx+1), mosaicSize * TR * float(wy)); 32 | } else { 33 | v1 = vec2(mosaicSize * 1.5 * float(wx), mosaicSize * TR * float(wy)); 34 | v2 = vec2(mosaicSize * 1.5 * float(wx + 1), mosaicSize * TR * float(wy+1)); 35 | } 36 | } 37 | 38 | float s1 = sqrt(pow(v1.x - x, 2.0) + pow(v1.y - y, 2.0)); 39 | float s2 = sqrt(pow(v2.x - x, 2.0) + pow(v2.y - y, 2.0)); 40 | 41 | if (s1 < s2) { 42 | vn = v1; 43 | } else { 44 | vn = v2; 45 | } 46 | 47 | vec4 mid = texture2D(Texture, vn); 48 | float a = atan((x - vn.x)/(y - vn.y)); 49 | 50 | vec2 area1 = vec2(vn.x, vn.y - mosaicSize * TR / 2.0); 51 | vec2 area2 = vec2(vn.x + mosaicSize / 2.0, vn.y - mosaicSize * TR / 2.0); 52 | vec2 area3 = vec2(vn.x + mosaicSize / 2.0, vn.y + mosaicSize * TR / 2.0); 53 | vec2 area4 = vec2(vn.x, vn.y + mosaicSize * TR / 2.0); 54 | vec2 area5 = vec2(vn.x - mosaicSize / 2.0, vn.y + mosaicSize * TR / 2.0); 55 | vec2 area6 = vec2(vn.x - mosaicSize / 2.0, vn.y - mosaicSize * TR / 2.0); 56 | 57 | if (a >= PI6 && a < PI6 * 3.0) { 58 | vn = area1; 59 | } else if (a >= PI6 * 3.0 && a < PI6 * 5.0) { 60 | vn = area2; 61 | } else if ((a >= PI6 * 5.0 && a <= PI6 * 6.0) || (a < -PI6 * 5.0 && a > -PI6 * 6.0)) { 62 | vn = area3; 63 | } else if (a < -PI6 * 3.0 && a >= -PI6 * 5.0) { 64 | vn = area4; 65 | } else if(a <= -PI6 && a> -PI6 * 3.0) { 66 | vn = area5; 67 | } else if (a > -PI6 && a < PI6) { 68 | vn = area6; 69 | } 70 | 71 | vec4 color = texture2D(Texture, vn); 72 | gl_FragColor = color; 73 | 74 | } 75 | 76 | -------------------------------------------------------------------------------- /综合滤镜处理/Filter/TriangularMosaic/TriangularMosaic.vsh: -------------------------------------------------------------------------------- 1 | attribute vec4 Position; 2 | attribute vec2 TextureCoords; 3 | varying vec2 TextureCoordsVarying; 4 | 5 | void main (void) { 6 | gl_Position = Position; 7 | TextureCoordsVarying = TextureCoords; 8 | } 9 | -------------------------------------------------------------------------------- /综合滤镜处理/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /综合滤镜处理/Tool/FilterBar.h: -------------------------------------------------------------------------------- 1 | // 2 | // FilterBar.h 3 | // 001--滤镜处理 4 | // 5 | // Created by CC老师 on 2019/4/23. 6 | // Copyright © 2019年 CC老师. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class FilterBar; 12 | 13 | @protocol FilterBarDelegate 14 | 15 | - (void)filterBar:(FilterBar *)filterBar didScrollToIndex:(NSUInteger)index; 16 | 17 | @end 18 | 19 | @interface FilterBar : UIView 20 | 21 | @property (nonatomic, strong) NSArray *itemList; 22 | 23 | @property (nonatomic, weak) id delegate; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /综合滤镜处理/Tool/FilterBar.m: -------------------------------------------------------------------------------- 1 | // 2 | // FilterBar.m 3 | // 001--滤镜处理 4 | // 5 | // Created by CC老师 on 2019/4/23. 6 | // Copyright © 2019年 CC老师. All rights reserved. 7 | // 8 | 9 | #import "FilterBarCell.h" 10 | 11 | #import "FilterBar.h" 12 | 13 | static NSString * const kFilterBarCellIdentifier = @"FilterBarCell"; 14 | 15 | @interface FilterBar () 16 | 17 | @property (nonatomic, strong) UICollectionView *collectionView; 18 | @property (nonatomic, strong) UICollectionViewFlowLayout *collectionViewLayout; 19 | 20 | @property (nonatomic, assign) NSInteger currentIndex; 21 | 22 | @end 23 | 24 | @implementation FilterBar 25 | 26 | - (instancetype)initWithFrame:(CGRect)frame { 27 | 28 | self = [super initWithFrame:frame]; 29 | if (self) { 30 | [self commonInit]; 31 | } 32 | return self; 33 | } 34 | 35 | #pragma mark - Private 36 | 37 | - (void)commonInit { 38 | 39 | [self createCollectionViewLayout]; 40 | 41 | _collectionView = [[UICollectionView alloc] initWithFrame:[self bounds] collectionViewLayout:_collectionViewLayout]; 42 | [self addSubview:_collectionView]; 43 | 44 | _collectionView.backgroundColor = [UIColor whiteColor]; 45 | _collectionView.delegate = self; 46 | _collectionView.dataSource = self; 47 | _collectionView.showsVerticalScrollIndicator = NO; 48 | _collectionView.showsHorizontalScrollIndicator = NO; 49 | [_collectionView registerClass:[FilterBarCell class] forCellWithReuseIdentifier:kFilterBarCellIdentifier]; 50 | } 51 | 52 | - (void)createCollectionViewLayout { 53 | 54 | UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; 55 | 56 | flowLayout.minimumLineSpacing = 0; 57 | flowLayout.minimumInteritemSpacing = 0; 58 | 59 | CGFloat itemW = 100; 60 | CGFloat itemH = CGRectGetHeight(self.frame); 61 | flowLayout.itemSize = CGSizeMake(itemW, itemH); 62 | 63 | flowLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0); 64 | flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal; 65 | 66 | _collectionViewLayout = flowLayout; 67 | } 68 | 69 | - (void)selectIndex:(NSIndexPath *)indexPath { 70 | 71 | _currentIndex = indexPath.row; 72 | [_collectionView reloadData]; 73 | 74 | [_collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES]; 75 | 76 | if (self.delegate && [self.delegate respondsToSelector:@selector(filterBar:didScrollToIndex:)]) { 77 | [self.delegate filterBar:self didScrollToIndex:indexPath.row]; 78 | } 79 | } 80 | 81 | #pragma mark - setter 82 | 83 | - (void)setItemList:(NSArray *)itemList { 84 | 85 | _itemList = itemList; 86 | [_collectionView reloadData]; 87 | } 88 | 89 | #pragma mark - UICollectionViewDelegate & UICollectionViewDataSource 90 | 91 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { 92 | 93 | return 1; 94 | } 95 | 96 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 97 | 98 | return [_itemList count]; 99 | } 100 | 101 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 102 | 103 | FilterBarCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kFilterBarCellIdentifier forIndexPath:indexPath]; 104 | cell.title = self.itemList[indexPath.row]; 105 | cell.isSelect = indexPath.row == _currentIndex; 106 | return cell; 107 | } 108 | 109 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { 110 | 111 | [self selectIndex:indexPath]; 112 | } 113 | 114 | @end 115 | -------------------------------------------------------------------------------- /综合滤镜处理/Tool/FilterBarCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // FilterBarCell.h 3 | // 001--滤镜处理 4 | // 5 | // Created by CC老师 on 2019/4/23. 6 | // Copyright © 2019年 CC老师. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface FilterBarCell : UICollectionViewCell 12 | 13 | @property (nonatomic, strong) NSString *title; 14 | @property (nonatomic, assign) BOOL isSelect; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /综合滤镜处理/Tool/FilterBarCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // FilterBarCell.m 3 | // 001--滤镜处理 4 | // 5 | // Created by CC老师 on 2019/4/23. 6 | // Copyright © 2019年 CC老师. All rights reserved. 7 | // 8 | 9 | 10 | #import "FilterBarCell.h" 11 | 12 | @interface FilterBarCell () 13 | 14 | @property (nonatomic, strong) UILabel *label; 15 | 16 | @end 17 | 18 | @implementation FilterBarCell 19 | 20 | - (instancetype)initWithFrame:(CGRect)frame { 21 | self = [super initWithFrame:frame]; 22 | if (self) { 23 | [self commonInit]; 24 | } 25 | return self; 26 | } 27 | 28 | - (void)layoutSubviews { 29 | [super layoutSubviews]; 30 | self.label.frame = CGRectInset(self.label.frame, 10, 10); 31 | } 32 | 33 | - (void)commonInit { 34 | self.label = [[UILabel alloc] initWithFrame:self.bounds]; 35 | self.label.textAlignment = NSTextAlignmentCenter; 36 | self.label.font = [UIFont boldSystemFontOfSize:15]; 37 | self.label.layer.masksToBounds = YES; 38 | self.label.layer.cornerRadius = 15; 39 | [self addSubview:self.label]; 40 | } 41 | 42 | - (void)setTitle:(NSString *)title { 43 | _title = title; 44 | self.label.text = title; 45 | } 46 | 47 | - (void)setIsSelect:(BOOL)isSelect { 48 | _isSelect = isSelect; 49 | self.label.backgroundColor = isSelect ? [UIColor blackColor] : [UIColor clearColor]; 50 | self.label.textColor = isSelect ? [UIColor whiteColor] : [UIColor blackColor]; 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /综合滤镜处理/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // 综合滤镜处理 4 | // 5 | // Created by 梁新昌 on 2019/7/8. 6 | // Copyright © 2019 Tainfn. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /综合滤镜处理/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // 综合滤镜处理 4 | // 5 | // Created by 梁新昌 on 2019/7/8. 6 | // Copyright © 2019 Tainfn. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import 11 | #import "FilterBar.h" 12 | 13 | typedef struct { 14 | 15 | GLKVector3 positionCoord; // (x, y, z) 16 | GLKVector2 textureCoord; // (U, V) 17 | 18 | } SenceVertex; 19 | 20 | @interface ViewController () 21 | 22 | @property (nonatomic, assign) SenceVertex *vertices; 23 | 24 | @property (nonatomic, strong) EAGLContext *context; 25 | // 用于刷新屏幕 26 | @property (nonatomic, strong) CADisplayLink *displayLink; 27 | // 开始的时间戳 28 | @property (nonatomic, assign) NSTimeInterval startTimeInterval; 29 | // 着色器程序 30 | @property (nonatomic, assign) GLuint program; 31 | // 顶点缓存 32 | @property (nonatomic, assign) GLuint vertexBuffer; 33 | // 纹理 ID 34 | @property (nonatomic, assign) GLuint textureID; 35 | 36 | @end 37 | 38 | @implementation ViewController 39 | 40 | - (void)dealloc { 41 | // 1.上下文释放 42 | if ([EAGLContext currentContext] == self.context) { 43 | [EAGLContext setCurrentContext:nil]; 44 | } 45 | // 顶点缓存区释放 46 | if (_vertexBuffer) { 47 | glDeleteBuffers(1, &_vertexBuffer); 48 | _vertexBuffer = 0; 49 | } 50 | // 顶点数组释放 51 | if (_vertices) { 52 | free(_vertices); 53 | _vertices = nil; 54 | } 55 | } 56 | 57 | - (void)viewWillDisappear:(BOOL)animated { 58 | [super viewWillDisappear:animated]; 59 | // 移除 displayLink 60 | if (self.displayLink) { 61 | [self.displayLink invalidate]; 62 | self.displayLink = nil; 63 | } 64 | } 65 | 66 | - (void)viewDidLoad { 67 | [super viewDidLoad]; 68 | // 设置背景颜色program链接失败 69 | self.view.backgroundColor = [UIColor blackColor]; 70 | // 创建滤镜工具栏 71 | [self setupFilterBar]; 72 | // 滤镜处理初始化 73 | [self filterInit]; 74 | // 开始一个滤镜动画 75 | [self startFilerAnimation]; 76 | } 77 | 78 | // 创建滤镜栏 79 | - (void)setupFilterBar { 80 | CGFloat filterBarWidth = [UIScreen mainScreen].bounds.size.width; 81 | CGFloat filterBarHeight = 100; 82 | CGFloat filterBarY = [UIScreen mainScreen].bounds.size.height - filterBarHeight; 83 | FilterBar *filerBar = [[FilterBar alloc] initWithFrame:CGRectMake(0, filterBarY, filterBarWidth, filterBarHeight)]; 84 | filerBar.delegate = self; 85 | [self.view addSubview:filerBar]; 86 | 87 | NSArray *dataSource = @[@"无",@"灰度",@"颠倒",@"旋涡",@"马赛克",@"马赛克2",@"马赛克3", @"缩放",@"灵魂出窍",@"抖动",@"闪白",@"毛刺"]; 88 | filerBar.itemList = dataSource; 89 | } 90 | 91 | - (void)filterInit { 92 | 93 | //1. 初始化上下文并设置为当前上下文 94 | self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; 95 | [EAGLContext setCurrentContext:self.context]; 96 | 97 | //2.开辟顶点数组内存空间 98 | self.vertices = malloc(sizeof(SenceVertex) * 4); 99 | 100 | //3.初始化顶点(0,1,2,3)的顶点坐标以及纹理坐标 101 | self.vertices[0] = (SenceVertex){{-1, 1, 0}, {0, 1}}; 102 | self.vertices[1] = (SenceVertex){{-1, -1, 0}, {0, 0}}; 103 | self.vertices[2] = (SenceVertex){{1, 1, 0}, {1, 1}}; 104 | self.vertices[3] = (SenceVertex){{1, -1, 0}, {1, 0}}; 105 | 106 | //4.创建图层(CAEAGLLayer) 107 | CAEAGLLayer *layer = [[CAEAGLLayer alloc] init]; 108 | //设置图层frame 109 | layer.frame = CGRectMake(0, 150, self.view.frame.size.width, self.view.frame.size.width); 110 | //设置图层的scale 111 | layer.contentsScale = [[UIScreen mainScreen] scale]; 112 | //给View添加layer 113 | [self.view.layer addSublayer:layer]; 114 | 115 | //5.绑定渲染缓存区 和帧缓存区 116 | [self bindRenderLayer:layer]; 117 | 118 | //6.获取处理的图片路径 119 | NSString *imagePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"meimei.jpg"]; 120 | //读取图片 121 | UIImage *image = [UIImage imageWithContentsOfFile:imagePath]; 122 | //将JPG图片转换成纹理图片 123 | GLuint textureID = [self createTextureWithImage:image]; 124 | //设置纹理ID 125 | self.textureID = textureID; // 将纹理 ID 保存,方便后面切换滤镜的时候重用 126 | 127 | //7.设置视口 128 | glViewport(0, 0, self.drawableWidth, self.drawableHeight); 129 | 130 | //8.设置顶点缓存区 131 | GLuint vertexBuffer; 132 | glGenBuffers(1, &vertexBuffer); 133 | glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); 134 | GLsizeiptr bufferSizeBytes = sizeof(SenceVertex) * 4; 135 | glBufferData(GL_ARRAY_BUFFER, bufferSizeBytes, self.vertices, GL_STATIC_DRAW); 136 | 137 | 138 | //9.设置默认着色器 139 | [self setupShaderProgramWithName:@"Normal"]; // 一开始选用默认的着色器 140 | 141 | //10.将顶点缓存保存,退出时才释放 142 | self.vertexBuffer = vertexBuffer; 143 | 144 | } 145 | 146 | - (void)bindRenderLayer:(CALayer *)layer { 147 | // 1.渲染缓存区, 帧缓存区对象 148 | GLuint renderBuffer; 149 | GLuint frameBuffer; 150 | // 2.获取渲染缓存区名称, 绑定渲染缓存区以及将渲染缓存区与 layer建立联系 151 | glGenRenderbuffers(1, &renderBuffer); 152 | glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer); 153 | [self.context renderbufferStorage:GL_RENDERBUFFER fromDrawable:layer]; 154 | // 3.获取帧缓存区名称, 绑定帧缓存区以及渲染缓存区附着到帧缓存区上 155 | glGenFramebuffers(1, &frameBuffer); 156 | glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer); 157 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderBuffer); 158 | } 159 | 160 | //从图片中加载纹理 161 | 162 | - (GLuint)createTextureWithImage:(UIImage *)image { 163 | //1、将 UIImage 转换为 CGImageRef 164 | CGImageRef cgImageRef = [image CGImage]; 165 | //判断图片是否获取成功 166 | if (!cgImageRef) { 167 | NSLog(@"Failed to load image"); 168 | exit(1); 169 | } 170 | //2、读取图片的大小,宽和高 171 | GLuint width = (GLuint)CGImageGetWidth(cgImageRef); 172 | GLuint height = (GLuint)CGImageGetHeight(cgImageRef); 173 | //获取图片的rect 174 | CGRect rect = CGRectMake(0, 0, width, height); 175 | 176 | //获取图片的颜色空间 177 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 178 | //3.获取图片字节数 宽*高*4(RGBA) 179 | void *imageData = malloc(width * height * 4); 180 | //4.创建上下文 181 | /* 182 | 参数1:data,指向要渲染的绘制图像的内存地址 183 | 参数2:width,bitmap的宽度,单位为像素 184 | 参数3:height,bitmap的高度,单位为像素 185 | 参数4:bitPerComponent,内存中像素的每个组件的位数,比如32位RGBA,就设置为8 186 | 参数5:bytesPerRow,bitmap的没一行的内存所占的比特数 187 | 参数6:colorSpace,bitmap上使用的颜色空间 kCGImageAlphaPremultipliedLast:RGBA 188 | */ 189 | 190 | CGContextRef context = CGBitmapContextCreate(imageData, width, height, 8, width * 4, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); 191 | 192 | //将图片翻转过来(图片默认是倒置的) 193 | CGContextTranslateCTM(context, 0, height); 194 | CGContextScaleCTM(context, 1.0f, -1.0f); 195 | CGColorSpaceRelease(colorSpace); 196 | CGContextClearRect(context, rect); 197 | 198 | //对图片进行重新绘制,得到一张新的解压缩后的位图 199 | CGContextDrawImage(context, rect, cgImageRef); 200 | 201 | //设置图片纹理属性 202 | //5. 获取纹理ID 203 | GLuint textureID; 204 | glGenTextures(1, &textureID); 205 | glBindTexture(GL_TEXTURE_2D, textureID); 206 | 207 | //6.载入纹理2D数据 208 | /* 209 | 参数1:纹理模式,GL_TEXTURE_1D、GL_TEXTURE_2D、GL_TEXTURE_3D 210 | 参数2:加载的层次,一般设置为0 211 | 参数3:纹理的颜色值GL_RGBA 212 | 参数4:宽 213 | 参数5:高 214 | 参数6:border,边界宽度 215 | 参数7:format 216 | 参数8:type 217 | 参数9:纹理数据 218 | */ 219 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); 220 | 221 | //7.设置纹理属性 222 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 223 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 224 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 225 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 226 | 227 | //8.绑定纹理 228 | /* 229 | 参数1:纹理维度 230 | 参数2:纹理ID,因为只有一个纹理,给0就可以了。 231 | */ 232 | glBindTexture(GL_TEXTURE_2D, 0); 233 | 234 | //9.释放context,imageData 235 | CGContextRelease(context); 236 | free(imageData); 237 | 238 | //10.返回纹理ID 239 | return textureID; 240 | } 241 | 242 | 243 | 244 | // 开始一个滤镜动画 245 | - (void)startFilerAnimation { 246 | // 1.判断 displayLink 是否为空 247 | // CADisplayLink 定时器 248 | if (self.displayLink) { 249 | [self.displayLink invalidate]; 250 | self.displayLink = nil; 251 | } 252 | //2. 设置displayLink 的方法 253 | self.startTimeInterval = 0; 254 | self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(timeAction)]; 255 | 256 | //3.将displayLink 添加到runloop 运行循环 257 | [self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; 258 | 259 | } 260 | // 动画 261 | - (void)timeAction { 262 | 263 | //DisplayLink 的当前时间撮 264 | if (self.startTimeInterval == 0) { 265 | self.startTimeInterval = self.displayLink.timestamp; 266 | } 267 | //使用program 268 | glUseProgram(self.program); 269 | //绑定buffer 270 | glBindBuffer(GL_ARRAY_BUFFER, self.vertexBuffer); 271 | 272 | // 传入时间 273 | CGFloat currentTime = self.displayLink.timestamp - self.startTimeInterval; 274 | GLuint time = glGetUniformLocation(self.program, "Time"); 275 | glUniform1f(time, currentTime); 276 | 277 | // 清除画布 278 | glClear(GL_COLOR_BUFFER_BIT); 279 | glClearColor(1, 1, 1, 1); 280 | 281 | // 重绘 282 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 283 | //渲染到屏幕上 284 | [self.context presentRenderbuffer:GL_RENDERBUFFER]; 285 | 286 | } 287 | 288 | #pragma mark - FilterBarDelegate 289 | 290 | - (void)filterBar:(FilterBar *)filterBar didScrollToIndex:(NSUInteger)index { 291 | 292 | //普通图片显示着色器程序/灰度滤镜着色器程序/颠倒滤镜着色器程序/旋涡滤镜着色器程序/马赛克滤镜着色器程序/六边形马赛克滤镜着色器程序/三角形马赛克滤镜着色器程序/缩放滤镜着色器程序/灵魂出窍滤镜着色器程序/抖动滤镜着色器程序/闪白滤镜着色器程序/毛刺滤镜着色器程序 293 | 294 | NSArray *arr = @[@"Normal", @"Gray", @"Reversal", @"Cirlce", @"Mosaic", @"HexagonMosaic", @"TriangularMosaic", @"Scale", @"SoulOut", @"Shake", @"ShineWhite", @"Glitch"]; 295 | [self setupShaderProgramWithName:arr[index]]; 296 | // 重新开始滤镜动画 297 | [self startFilerAnimation]; 298 | 299 | 300 | } 301 | 302 | // 初始化着色器程序 303 | - (void)setupShaderProgramWithName:(NSString *)name { 304 | // 1.获取着色器 program 305 | GLuint program = [self programWithShaderName:name]; 306 | // 2.use Program 307 | glUseProgram(program); 308 | // 3.获取 position, texture, TextureCoords 的索引位置 309 | GLuint positionSlot = glGetAttribLocation(program, "Position"); 310 | 311 | GLuint textureSlot = glGetUniformLocation(program, "Texture"); 312 | 313 | GLuint textureCoordsSlot = glGetAttribLocation(program, "TextureCoords"); 314 | 315 | // 4.激活纹理, 绑定纹理 ID 316 | glActiveTexture(GL_TEXTURE0); 317 | glBindTexture(GL_TEXTURE_2D, self.textureID); 318 | 319 | // 5.纹理 sample 320 | glUniform1f(textureSlot, 0); 321 | // 6.打开 positionSlot 属性 并且传递数据到positionSlot中去(顶点坐标) 322 | glEnableVertexAttribArray(positionSlot); 323 | glVertexAttribPointer(positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(SenceVertex), NULL+ offsetof(SenceVertex, positionCoord)); 324 | // 7.打开textureCoordsSlot 属性并传递数据到textureCoordsSlot(纹理坐标) 325 | glEnableVertexAttribArray(textureCoordsSlot); 326 | glVertexAttribPointer(textureCoordsSlot, 2, GL_FLOAT, GL_FALSE, sizeof(SenceVertex), NULL + offsetof(SenceVertex, textureCoord)); 327 | // 8.保存 program , 界面销毁则释放 328 | self.program = program; 329 | 330 | 331 | } 332 | 333 | 334 | #pragma mark - shader compile and link 335 | //link program 336 | - (GLuint)programWithShaderName:(NSString *)shaderName { 337 | 338 | //1. 编译顶点着色器/片元着色器 339 | GLuint vertexShader = [self compileShaderWithName:shaderName type:GL_VERTEX_SHADER]; 340 | GLuint fragmentShader = [self compileShaderWithName:shaderName type:GL_FRAGMENT_SHADER]; 341 | 342 | //2. 将顶点/片元附着到program 343 | GLuint program = glCreateProgram(); 344 | glAttachShader(program, vertexShader); 345 | glAttachShader(program, fragmentShader); 346 | 347 | //3.linkProgram 348 | glLinkProgram(program); 349 | 350 | //4.检查是否link成功 351 | GLint linkSuccess; 352 | glGetProgramiv(program, GL_LINK_STATUS, &linkSuccess); 353 | if (linkSuccess == GL_FALSE) { 354 | GLchar messages[256]; 355 | glGetProgramInfoLog(program, sizeof(messages), 0, &messages[0]); 356 | NSString *messageString = [NSString stringWithUTF8String:messages]; 357 | NSAssert(NO, @"program链接失败:%@", messageString); 358 | exit(1); 359 | } 360 | //5.返回program 361 | return program; 362 | } 363 | // 编译 shader 代码 364 | - (GLuint)compileShaderWithName:(NSString *)name type:(GLenum)shaderType { 365 | 366 | //1.获取shader 路径 367 | NSString *shaderPath = [[NSBundle mainBundle] pathForResource:name ofType:shaderType == GL_VERTEX_SHADER ? @"vsh" : @"fsh"]; 368 | NSError *error; 369 | NSString *shaderString = [NSString stringWithContentsOfFile:shaderPath encoding:NSUTF8StringEncoding error:&error]; 370 | if (!shaderString) { 371 | NSAssert(NO, @"读取shader失败"); 372 | exit(1); 373 | } 374 | 375 | //2. 创建shader->根据shaderType 376 | GLuint shader = glCreateShader(shaderType); 377 | 378 | //3.获取shader source 379 | const char *shaderStringUTF8 = [shaderString UTF8String]; 380 | int shaderStringLength = (int)[shaderString length]; 381 | glShaderSource(shader, 1, &shaderStringUTF8, &shaderStringLength); 382 | 383 | //4.编译shader 384 | glCompileShader(shader); 385 | 386 | //5.查看编译是否成功 387 | GLint compileSuccess; 388 | glGetShaderiv(shader, GL_COMPILE_STATUS, &compileSuccess); 389 | if (compileSuccess == GL_FALSE) { 390 | GLchar messages[256]; 391 | glGetShaderInfoLog(shader, sizeof(messages), 0, &messages[0]); 392 | NSString *messageString = [NSString stringWithUTF8String:messages]; 393 | NSAssert(NO, @"shader编译失败:%@", messageString); 394 | exit(1); 395 | } 396 | //6.返回shader 397 | return shader; 398 | } 399 | 400 | //获取渲染缓存区的宽 401 | - (GLint)drawableWidth { 402 | GLint backingWidth; 403 | glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth); 404 | return backingWidth; 405 | } 406 | //获取渲染缓存区的高 407 | - (GLint)drawableHeight { 408 | GLint backingHeight; 409 | glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight); 410 | return backingHeight; 411 | } 412 | 413 | @end 414 | -------------------------------------------------------------------------------- /综合滤镜处理/kaixin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinKoko/zonghelvjing/da398864241dc421500058045cb768b3a6670638/综合滤镜处理/kaixin.jpg -------------------------------------------------------------------------------- /综合滤镜处理/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // 综合滤镜处理 4 | // 5 | // Created by 梁新昌 on 2019/7/8. 6 | // Copyright © 2019 Tainfn. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /综合滤镜处理/meimei.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustinKoko/zonghelvjing/da398864241dc421500058045cb768b3a6670638/综合滤镜处理/meimei.jpg --------------------------------------------------------------------------------