├── Nebula.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── simongladman.xcuserdatad │ └── xcschemes │ ├── Nebula.xcscheme │ └── xcschememanagement.plist ├── Nebula ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── IMG_0195.jpg ├── Info.plist ├── NebulaShader.cikernel └── ViewController.swift └── README.md /Nebula.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 3E4A19491C8F1948006032BC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E4A19481C8F1948006032BC /* AppDelegate.swift */; }; 11 | 3E4A194B1C8F1948006032BC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E4A194A1C8F1948006032BC /* ViewController.swift */; }; 12 | 3E4A194E1C8F1948006032BC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3E4A194C1C8F1948006032BC /* Main.storyboard */; }; 13 | 3E4A19501C8F1948006032BC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3E4A194F1C8F1948006032BC /* Assets.xcassets */; }; 14 | 3E4A19531C8F1948006032BC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3E4A19511C8F1948006032BC /* LaunchScreen.storyboard */; }; 15 | 3E4A195B1C8F1972006032BC /* NebulaShader.cikernel in Resources */ = {isa = PBXBuildFile; fileRef = 3E4A195A1C8F1972006032BC /* NebulaShader.cikernel */; }; 16 | 3E4A195D1C8F1B9E006032BC /* IMG_0195.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 3E4A195C1C8F1B9E006032BC /* IMG_0195.jpg */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 3E4A19451C8F1948006032BC /* Nebula.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Nebula.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 3E4A19481C8F1948006032BC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | 3E4A194A1C8F1948006032BC /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 23 | 3E4A194D1C8F1948006032BC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 24 | 3E4A194F1C8F1948006032BC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 25 | 3E4A19521C8F1948006032BC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 26 | 3E4A19541C8F1948006032BC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 27 | 3E4A195A1C8F1972006032BC /* NebulaShader.cikernel */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NebulaShader.cikernel; sourceTree = ""; }; 28 | 3E4A195C1C8F1B9E006032BC /* IMG_0195.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = IMG_0195.jpg; sourceTree = ""; }; 29 | /* End PBXFileReference section */ 30 | 31 | /* Begin PBXFrameworksBuildPhase section */ 32 | 3E4A19421C8F1948006032BC /* Frameworks */ = { 33 | isa = PBXFrameworksBuildPhase; 34 | buildActionMask = 2147483647; 35 | files = ( 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | 3E4A193C1C8F1948006032BC = { 43 | isa = PBXGroup; 44 | children = ( 45 | 3E4A19471C8F1948006032BC /* Nebula */, 46 | 3E4A19461C8F1948006032BC /* Products */, 47 | ); 48 | sourceTree = ""; 49 | }; 50 | 3E4A19461C8F1948006032BC /* Products */ = { 51 | isa = PBXGroup; 52 | children = ( 53 | 3E4A19451C8F1948006032BC /* Nebula.app */, 54 | ); 55 | name = Products; 56 | sourceTree = ""; 57 | }; 58 | 3E4A19471C8F1948006032BC /* Nebula */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 3E4A19481C8F1948006032BC /* AppDelegate.swift */, 62 | 3E4A194A1C8F1948006032BC /* ViewController.swift */, 63 | 3E4A195C1C8F1B9E006032BC /* IMG_0195.jpg */, 64 | 3E4A194C1C8F1948006032BC /* Main.storyboard */, 65 | 3E4A194F1C8F1948006032BC /* Assets.xcassets */, 66 | 3E4A19511C8F1948006032BC /* LaunchScreen.storyboard */, 67 | 3E4A19541C8F1948006032BC /* Info.plist */, 68 | 3E4A195A1C8F1972006032BC /* NebulaShader.cikernel */, 69 | ); 70 | path = Nebula; 71 | sourceTree = ""; 72 | }; 73 | /* End PBXGroup section */ 74 | 75 | /* Begin PBXNativeTarget section */ 76 | 3E4A19441C8F1948006032BC /* Nebula */ = { 77 | isa = PBXNativeTarget; 78 | buildConfigurationList = 3E4A19571C8F1948006032BC /* Build configuration list for PBXNativeTarget "Nebula" */; 79 | buildPhases = ( 80 | 3E4A19411C8F1948006032BC /* Sources */, 81 | 3E4A19421C8F1948006032BC /* Frameworks */, 82 | 3E4A19431C8F1948006032BC /* Resources */, 83 | ); 84 | buildRules = ( 85 | ); 86 | dependencies = ( 87 | ); 88 | name = Nebula; 89 | productName = Nebula; 90 | productReference = 3E4A19451C8F1948006032BC /* Nebula.app */; 91 | productType = "com.apple.product-type.application"; 92 | }; 93 | /* End PBXNativeTarget section */ 94 | 95 | /* Begin PBXProject section */ 96 | 3E4A193D1C8F1948006032BC /* Project object */ = { 97 | isa = PBXProject; 98 | attributes = { 99 | LastSwiftUpdateCheck = 0720; 100 | LastUpgradeCheck = 0720; 101 | ORGANIZATIONNAME = "Simon Gladman"; 102 | TargetAttributes = { 103 | 3E4A19441C8F1948006032BC = { 104 | CreatedOnToolsVersion = 7.2.1; 105 | }; 106 | }; 107 | }; 108 | buildConfigurationList = 3E4A19401C8F1948006032BC /* Build configuration list for PBXProject "Nebula" */; 109 | compatibilityVersion = "Xcode 3.2"; 110 | developmentRegion = English; 111 | hasScannedForEncodings = 0; 112 | knownRegions = ( 113 | en, 114 | Base, 115 | ); 116 | mainGroup = 3E4A193C1C8F1948006032BC; 117 | productRefGroup = 3E4A19461C8F1948006032BC /* Products */; 118 | projectDirPath = ""; 119 | projectRoot = ""; 120 | targets = ( 121 | 3E4A19441C8F1948006032BC /* Nebula */, 122 | ); 123 | }; 124 | /* End PBXProject section */ 125 | 126 | /* Begin PBXResourcesBuildPhase section */ 127 | 3E4A19431C8F1948006032BC /* Resources */ = { 128 | isa = PBXResourcesBuildPhase; 129 | buildActionMask = 2147483647; 130 | files = ( 131 | 3E4A19531C8F1948006032BC /* LaunchScreen.storyboard in Resources */, 132 | 3E4A195D1C8F1B9E006032BC /* IMG_0195.jpg in Resources */, 133 | 3E4A19501C8F1948006032BC /* Assets.xcassets in Resources */, 134 | 3E4A195B1C8F1972006032BC /* NebulaShader.cikernel in Resources */, 135 | 3E4A194E1C8F1948006032BC /* Main.storyboard in Resources */, 136 | ); 137 | runOnlyForDeploymentPostprocessing = 0; 138 | }; 139 | /* End PBXResourcesBuildPhase section */ 140 | 141 | /* Begin PBXSourcesBuildPhase section */ 142 | 3E4A19411C8F1948006032BC /* Sources */ = { 143 | isa = PBXSourcesBuildPhase; 144 | buildActionMask = 2147483647; 145 | files = ( 146 | 3E4A194B1C8F1948006032BC /* ViewController.swift in Sources */, 147 | 3E4A19491C8F1948006032BC /* AppDelegate.swift in Sources */, 148 | ); 149 | runOnlyForDeploymentPostprocessing = 0; 150 | }; 151 | /* End PBXSourcesBuildPhase section */ 152 | 153 | /* Begin PBXVariantGroup section */ 154 | 3E4A194C1C8F1948006032BC /* Main.storyboard */ = { 155 | isa = PBXVariantGroup; 156 | children = ( 157 | 3E4A194D1C8F1948006032BC /* Base */, 158 | ); 159 | name = Main.storyboard; 160 | sourceTree = ""; 161 | }; 162 | 3E4A19511C8F1948006032BC /* LaunchScreen.storyboard */ = { 163 | isa = PBXVariantGroup; 164 | children = ( 165 | 3E4A19521C8F1948006032BC /* Base */, 166 | ); 167 | name = LaunchScreen.storyboard; 168 | sourceTree = ""; 169 | }; 170 | /* End PBXVariantGroup section */ 171 | 172 | /* Begin XCBuildConfiguration section */ 173 | 3E4A19551C8F1948006032BC /* Debug */ = { 174 | isa = XCBuildConfiguration; 175 | buildSettings = { 176 | ALWAYS_SEARCH_USER_PATHS = NO; 177 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 178 | CLANG_CXX_LIBRARY = "libc++"; 179 | CLANG_ENABLE_MODULES = YES; 180 | CLANG_ENABLE_OBJC_ARC = YES; 181 | CLANG_WARN_BOOL_CONVERSION = YES; 182 | CLANG_WARN_CONSTANT_CONVERSION = YES; 183 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 184 | CLANG_WARN_EMPTY_BODY = YES; 185 | CLANG_WARN_ENUM_CONVERSION = YES; 186 | CLANG_WARN_INT_CONVERSION = YES; 187 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 188 | CLANG_WARN_UNREACHABLE_CODE = YES; 189 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 190 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 191 | COPY_PHASE_STRIP = NO; 192 | DEBUG_INFORMATION_FORMAT = dwarf; 193 | ENABLE_STRICT_OBJC_MSGSEND = YES; 194 | ENABLE_TESTABILITY = YES; 195 | GCC_C_LANGUAGE_STANDARD = gnu99; 196 | GCC_DYNAMIC_NO_PIC = NO; 197 | GCC_NO_COMMON_BLOCKS = YES; 198 | GCC_OPTIMIZATION_LEVEL = 0; 199 | GCC_PREPROCESSOR_DEFINITIONS = ( 200 | "DEBUG=1", 201 | "$(inherited)", 202 | ); 203 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 204 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 205 | GCC_WARN_UNDECLARED_SELECTOR = YES; 206 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 207 | GCC_WARN_UNUSED_FUNCTION = YES; 208 | GCC_WARN_UNUSED_VARIABLE = YES; 209 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 210 | MTL_ENABLE_DEBUG_INFO = YES; 211 | ONLY_ACTIVE_ARCH = YES; 212 | SDKROOT = iphoneos; 213 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 214 | TARGETED_DEVICE_FAMILY = 2; 215 | }; 216 | name = Debug; 217 | }; 218 | 3E4A19561C8F1948006032BC /* Release */ = { 219 | isa = XCBuildConfiguration; 220 | buildSettings = { 221 | ALWAYS_SEARCH_USER_PATHS = NO; 222 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 223 | CLANG_CXX_LIBRARY = "libc++"; 224 | CLANG_ENABLE_MODULES = YES; 225 | CLANG_ENABLE_OBJC_ARC = YES; 226 | CLANG_WARN_BOOL_CONVERSION = YES; 227 | CLANG_WARN_CONSTANT_CONVERSION = YES; 228 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 229 | CLANG_WARN_EMPTY_BODY = YES; 230 | CLANG_WARN_ENUM_CONVERSION = YES; 231 | CLANG_WARN_INT_CONVERSION = YES; 232 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 233 | CLANG_WARN_UNREACHABLE_CODE = YES; 234 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 235 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 236 | COPY_PHASE_STRIP = NO; 237 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 238 | ENABLE_NS_ASSERTIONS = NO; 239 | ENABLE_STRICT_OBJC_MSGSEND = YES; 240 | GCC_C_LANGUAGE_STANDARD = gnu99; 241 | GCC_NO_COMMON_BLOCKS = YES; 242 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 243 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 244 | GCC_WARN_UNDECLARED_SELECTOR = YES; 245 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 246 | GCC_WARN_UNUSED_FUNCTION = YES; 247 | GCC_WARN_UNUSED_VARIABLE = YES; 248 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 249 | MTL_ENABLE_DEBUG_INFO = NO; 250 | SDKROOT = iphoneos; 251 | TARGETED_DEVICE_FAMILY = 2; 252 | VALIDATE_PRODUCT = YES; 253 | }; 254 | name = Release; 255 | }; 256 | 3E4A19581C8F1948006032BC /* Debug */ = { 257 | isa = XCBuildConfiguration; 258 | buildSettings = { 259 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 260 | INFOPLIST_FILE = Nebula/Info.plist; 261 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 262 | PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.Nebula; 263 | PRODUCT_NAME = "$(TARGET_NAME)"; 264 | TARGETED_DEVICE_FAMILY = "1,2"; 265 | }; 266 | name = Debug; 267 | }; 268 | 3E4A19591C8F1948006032BC /* Release */ = { 269 | isa = XCBuildConfiguration; 270 | buildSettings = { 271 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 272 | INFOPLIST_FILE = Nebula/Info.plist; 273 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 274 | PRODUCT_BUNDLE_IDENTIFIER = uk.co.flexmonkey.Nebula; 275 | PRODUCT_NAME = "$(TARGET_NAME)"; 276 | TARGETED_DEVICE_FAMILY = "1,2"; 277 | }; 278 | name = Release; 279 | }; 280 | /* End XCBuildConfiguration section */ 281 | 282 | /* Begin XCConfigurationList section */ 283 | 3E4A19401C8F1948006032BC /* Build configuration list for PBXProject "Nebula" */ = { 284 | isa = XCConfigurationList; 285 | buildConfigurations = ( 286 | 3E4A19551C8F1948006032BC /* Debug */, 287 | 3E4A19561C8F1948006032BC /* Release */, 288 | ); 289 | defaultConfigurationIsVisible = 0; 290 | defaultConfigurationName = Release; 291 | }; 292 | 3E4A19571C8F1948006032BC /* Build configuration list for PBXNativeTarget "Nebula" */ = { 293 | isa = XCConfigurationList; 294 | buildConfigurations = ( 295 | 3E4A19581C8F1948006032BC /* Debug */, 296 | 3E4A19591C8F1948006032BC /* Release */, 297 | ); 298 | defaultConfigurationIsVisible = 0; 299 | defaultConfigurationName = Release; 300 | }; 301 | /* End XCConfigurationList section */ 302 | }; 303 | rootObject = 3E4A193D1C8F1948006032BC /* Project object */; 304 | } 305 | -------------------------------------------------------------------------------- /Nebula.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Nebula.xcodeproj/xcuserdata/simongladman.xcuserdatad/xcschemes/Nebula.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Nebula.xcodeproj/xcuserdata/simongladman.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Nebula.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 3E4A19441C8F1948006032BC 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Nebula/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Nebula 4 | // 5 | // Created by Simon Gladman on 08/03/2016. 6 | // Copyright © 2016 Simon Gladman. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // 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. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Nebula/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "ipad", 5 | "size" : "29x29", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "ipad", 10 | "size" : "29x29", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "ipad", 15 | "size" : "40x40", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "40x40", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "76x76", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "76x76", 31 | "scale" : "2x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Nebula/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 | 27 | 28 | -------------------------------------------------------------------------------- /Nebula/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 | 26 | -------------------------------------------------------------------------------- /Nebula/IMG_0195.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlexMonkey/Nebula/4faa2f1e6a6285e0a7c1da0340f4d2ec8930bdbf/Nebula/IMG_0195.jpg -------------------------------------------------------------------------------- /Nebula/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations~ipad 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationPortraitUpsideDown 37 | UIInterfaceOrientationLandscapeLeft 38 | UIInterfaceOrientationLandscapeRight 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Nebula/NebulaShader.cikernel: -------------------------------------------------------------------------------- 1 | // Based on http://glslsandbox.com/e#31308.0 2 | 3 | #define iterations 4 4 | #define formuparam2 0.89 5 | 6 | #define volsteps 5 7 | #define stepsize 0.190 8 | 9 | #define zoom 3.900 10 | #define tile 0.450 11 | #define speed2 0.010 12 | 13 | #define brightness 0.2 14 | #define darkmatter 0.400 15 | #define distfading 0.560 16 | #define saturation 0.400 17 | 18 | 19 | #define transverseSpeed 1.1 20 | #define cloud 0.2 21 | 22 | float field(in vec3 p, float time) 23 | { 24 | float strength = 7. + .03 * log(1.e-6 + fract(sin(time) * 4373.11)); 25 | float accum = 0.; 26 | float prev = 0.; 27 | float tw = 0.; 28 | 29 | 30 | for (int i = 0; i < 6; ++i) 31 | { 32 | float mag = dot(p, p); 33 | p = abs(p) / mag + vec3(-.5, -.8 + 0.1*sin(time*0.2 + 2.0), -1.1+0.3*cos(time*0.15)); 34 | float w = exp(-float(i) / 7.); 35 | accum += w * exp(-strength * pow(abs(mag - prev), 2.3)); 36 | tw += w; 37 | prev = mag; 38 | } 39 | return max(0., 5. * accum / tw - .7); 40 | } 41 | 42 | 43 | 44 | kernel vec4 nebulaKernel(float time, vec2 mouse, vec2 resolution) 45 | { 46 | vec2 uv2 = 2. * destCoord().xy / resolution.xy - 1.; 47 | vec2 uvs = uv2 * resolution.xy / max(resolution.x, resolution.y); 48 | 49 | 50 | 51 | float time2 = time; 52 | 53 | float speed = speed2; 54 | speed = 0.005 * cos(time2*0.02 + 3.1415926/4.0); 55 | 56 | //speed = 0.0; 57 | 58 | 59 | float formuparam = formuparam2; 60 | 61 | //get coords and direction 62 | 63 | vec2 uv = uvs; 64 | 65 | 66 | 67 | //mouse rotation 68 | float a_xz = 0.9; 69 | float a_yz = -.6; 70 | float a_xy = 0.9 + time*0.04; 71 | 72 | 73 | mat2 rot_xz = mat2(cos(a_xz),sin(a_xz),-sin(a_xz),cos(a_xz)); 74 | 75 | mat2 rot_yz = mat2(cos(a_yz),sin(a_yz),-sin(a_yz),cos(a_yz)); 76 | 77 | mat2 rot_xy = mat2(cos(a_xy),sin(a_xy),-sin(a_xy),cos(a_xy)); 78 | 79 | 80 | float v2 =1.0; 81 | 82 | vec3 dir=vec3(uv*zoom,1.); 83 | 84 | vec3 from=vec3(0.0, 0.0,0.0); 85 | 86 | 87 | from.x -= .5*(mouse.x-0.5); 88 | from.y -= .5*(mouse.y-0.5); 89 | 90 | 91 | vec3 forward = vec3(0.,0.,1.); 92 | 93 | 94 | from.x += transverseSpeed*(1.0)*cos(0.01*time) + 0.001*time; 95 | from.y += transverseSpeed*(1.0)*sin(0.01*time) +0.001*time; 96 | 97 | from.z += 0.003*time; 98 | 99 | 100 | dir.xy*=rot_xy; 101 | forward.xy *= rot_xy; 102 | 103 | dir.xz*=rot_xz; 104 | forward.xz *= rot_xz; 105 | 106 | 107 | dir.yz*= rot_yz; 108 | forward.yz *= rot_yz; 109 | 110 | 111 | 112 | from.xy*=-rot_xy; 113 | from.xz*=rot_xz; 114 | from.yz*= rot_yz; 115 | 116 | 117 | //zoom 118 | float zooom = (time2-3311.)*speed; 119 | from += forward* zooom; 120 | float sampleShift = mod( zooom, stepsize ); 121 | 122 | float zoffset = -sampleShift; 123 | sampleShift /= stepsize; // make from 0 to 1 124 | 125 | 126 | 127 | //volumetric rendering 128 | float s=0.24; 129 | float s3 = s + stepsize/2.0; 130 | vec3 v=vec3(0.); 131 | float t3 = 0.0; 132 | 133 | 134 | vec3 backCol2 = vec3(0.); 135 | for (int r=0; r 2) 153 | { 154 | a += i > 7 ? min( 12., D) : D; 155 | } 156 | pa=length(p2); 157 | } 158 | 159 | 160 | //float dm=max(0.,darkmatter-a*a*.001); //dark matter 161 | a*=a*a; // add contrast 162 | //if (r>3) fade*=1.-dm; // dark matter, don't render near 163 | // brightens stuff up a bit 164 | float s1 = s+zoffset; 165 | // need closed form expression for this, now that we shift samples 166 | float fade = pow(distfading,max(0.,float(r)-sampleShift)); 167 | 168 | 169 | //t3 += fade; 170 | 171 | v+=fade; 172 | //backCol2 -= fade; 173 | 174 | // fade out samples as they approach the camera 175 | if( r == 0 ) 176 | fade *= (1. - (sampleShift)); 177 | // fade in samples as they approach from the distance 178 | if( r == volsteps-1 ) 179 | fade *= sampleShift; 180 | v+=vec3(s1,s1*s1,s1*s1*s1*s1)*a*brightness*fade; // coloring based on distance 181 | 182 | backCol2 += mix(.4, 1., v2) * vec3(0.20 * t3 * t3 * t3, 0.4 * t3 * t3, t3 * 0.7) * fade; 183 | 184 | 185 | s+=stepsize; 186 | s3 += stepsize; 187 | 188 | 189 | 190 | } 191 | 192 | v=mix(vec3(length(v)),v,saturation); //color adjust 193 | 194 | 195 | 196 | 197 | vec4 forCol2 = vec4(v*.01,1.); 198 | 199 | #ifdef cloud 200 | backCol2 *= cloud; 201 | #endif 202 | 203 | //backCol2.b *= 1.8; 204 | 205 | //backCol2.r *= 0.05; 206 | 207 | 208 | 209 | //backCol2.b = 0.5*mix(backCol2.b, backCol2.g, 0.2); 210 | //backCol2.g = 0.0; 211 | 212 | // backCol2.bg = mix(backCol2.gb, backCol2.bg, 0.5*(cos(time*0.01) + 1.0)); 213 | 214 | return forCol2 + vec4(backCol2, 1.0); 215 | } -------------------------------------------------------------------------------- /Nebula/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Nebula 4 | // 5 | // Created by Simon Gladman on 08/03/2016. 6 | // Copyright © 2016 Simon Gladman. All rights reserved. 7 | // 8 | 9 | // 10 | // Based on http://glslsandbox.com/e#31308.0 11 | 12 | import UIKit 13 | import GLKit 14 | 15 | class ViewController: UIViewController 16 | { 17 | var time: CGFloat = 1 18 | var touchPosition = CIVector(x: 0, y: 0) 19 | 20 | let imageView = OpenGLImageView() 21 | 22 | lazy var nebulaKernel: CIColorKernel = 23 | { 24 | let nebulaShaderPath = NSBundle.mainBundle().pathForResource("NebulaShader", ofType: "cikernel") 25 | 26 | guard let path = nebulaShaderPath, 27 | code = try? String(contentsOfFile: path), 28 | kernel = CIColorKernel(string: code) else 29 | { 30 | fatalError("Unable to build nebula shader") 31 | } 32 | 33 | return kernel 34 | }() 35 | 36 | override func viewDidLoad() 37 | { 38 | super.viewDidLoad() 39 | 40 | view.addSubview(imageView) 41 | 42 | let displayLink = CADisplayLink(target: self, selector: Selector("step")) 43 | displayLink.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSDefaultRunLoopMode) 44 | } 45 | 46 | // MARK: Touch Handling 47 | 48 | override func touchesBegan(touches: Set, withEvent event: UIEvent?) 49 | { 50 | guard let locationInView = touches.first?.locationInView(view) else 51 | { 52 | return 53 | } 54 | 55 | touchPosition = CIVector(x: view.frame.height / 2 - locationInView.y, 56 | y: view.frame.width / 2 - locationInView.x) 57 | } 58 | 59 | // MARK: Step 60 | 61 | func step() 62 | { 63 | time += 0.01 64 | 65 | let resolution = CIVector(x: view.frame.width, y: view.frame.height) 66 | 67 | let arguments = [time, touchPosition, resolution] 68 | 69 | let image = nebulaKernel.applyWithExtent(view.bounds, arguments: arguments) 70 | 71 | imageView.image = image 72 | } 73 | 74 | override func viewDidLayoutSubviews() 75 | { 76 | imageView.frame = view.bounds 77 | } 78 | 79 | override func prefersStatusBarHidden() -> Bool 80 | { 81 | return true 82 | } 83 | } 84 | 85 | // ----- 86 | 87 | class OpenGLImageView: GLKView 88 | { 89 | let eaglContext = EAGLContext(API: .OpenGLES2) 90 | 91 | lazy var ciContext: CIContext = 92 | { 93 | [unowned self] in 94 | 95 | return CIContext(EAGLContext: self.eaglContext, 96 | options: [kCIContextWorkingColorSpace: NSNull()]) 97 | }() 98 | 99 | override init(frame: CGRect) 100 | { 101 | super.init(frame: frame, context: eaglContext) 102 | 103 | context = self.eaglContext 104 | delegate = self 105 | } 106 | 107 | override init(frame: CGRect, context: EAGLContext) 108 | { 109 | fatalError("init(frame:, context:) has not been implemented") 110 | } 111 | 112 | required init?(coder aDecoder: NSCoder) 113 | { 114 | fatalError("init(coder:) has not been implemented") 115 | } 116 | 117 | /// The image to display 118 | var image: CIImage? 119 | { 120 | didSet 121 | { 122 | setNeedsDisplay() 123 | } 124 | } 125 | } 126 | 127 | extension OpenGLImageView: GLKViewDelegate 128 | { 129 | func glkView(view: GLKView, drawInRect rect: CGRect) 130 | { 131 | guard let image = image else 132 | { 133 | return 134 | } 135 | 136 | let targetRect = image.extent.aspectFitInRect( 137 | target: CGRect(origin: CGPointZero, 138 | size: CGSize(width: drawableWidth, 139 | height: drawableHeight))) 140 | 141 | let ciBackgroundColor = CIColor( 142 | color: backgroundColor ?? UIColor.whiteColor()) 143 | 144 | ciContext.drawImage(CIImage(color: ciBackgroundColor), 145 | inRect: CGRect(x: 0, 146 | y: 0, 147 | width: drawableWidth, 148 | height: drawableHeight), 149 | fromRect: CGRect(x: 0, 150 | y: 0, 151 | width: drawableWidth, 152 | height: drawableHeight)) 153 | 154 | ciContext.drawImage(image, 155 | inRect: targetRect, 156 | fromRect: image.extent) 157 | } 158 | } 159 | 160 | extension CGRect 161 | { 162 | func aspectFitInRect(target target: CGRect) -> CGRect 163 | { 164 | let scale: CGFloat = 165 | { 166 | let scale = target.width / self.width 167 | 168 | return self.height * scale <= target.height ? 169 | scale : 170 | target.height / self.height 171 | }() 172 | 173 | let width = self.width * scale 174 | let height = self.height * scale 175 | let x = target.midX - width / 2 176 | let y = target.midY - height / 2 177 | 178 | return CGRect(x: x, 179 | y: y, 180 | width: width, 181 | height: height) 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nebula 2 | Core Image Volumetric Rendering 3 | 4 | ![IMG_0195.jpg](Nebula/IMG_0195.jpg) 5 | 6 | I'd love to be able to take credit for this shader, but the hard work isn't mine! This volumetric nebula shader code originates from [glslsandbox.com](http://glslsandbox.com/e#31308.0) . All I've done is changed `main()` to a kernel function, swapped out `gl_FragCoord` for `destCoord` and wrapped the code in a `CIColorKernel`. 7 | 8 | On my iPad Pro, I get around 30fps rendering at 2732 x 2048 - not too bad! 9 | --------------------------------------------------------------------------------