├── .flowconfig ├── .gitignore ├── README.MD ├── RNGLDesktop.xcodeproj └── project.pbxproj ├── RNGLDesktop ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist └── main.m ├── index.osx.js ├── package.json └── shaders.js /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [options] 8 | module.system=haste 9 | 10 | munge_underscores=true 11 | 12 | module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' 13 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub' 14 | 15 | suppress_type=$FlowIssue 16 | suppress_type=$FlowFixMe 17 | suppress_type=$FixMe 18 | 19 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-6]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 20 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-6]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 21 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-6]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+ 22 | 23 | [version] 24 | 0.17.0 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | !**/*.xcodeproj 3 | !**/*.pbxproj 4 | !**/*.xcworkspacedata 5 | !**/*.xcsettings 6 | !**/*.xcscheme 7 | *.pbxuser 8 | !default.pbxuser 9 | *.mode1v3 10 | !default.mode1v3 11 | *.mode2v3 12 | !default.mode2v3 13 | *.perspectivev3 14 | !default.perspectivev3 15 | xcuserdata 16 | *.xccheckout 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | *.xcuserstate 22 | project.xcworkspace 23 | 24 | # Xcode 25 | build/ 26 | 27 | # Node 28 | node_modules 29 | *.log 30 | .nvm 31 | 32 | # OS X 33 | .DS_Store 34 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | 2 | 1. `npm install` 3 | 2. `npm run start` 4 | 3. `open RNGLDesktop` and run from XCode 5 | 6 | ![screenshot 2015-12-01 09 45 05](https://cloud.githubusercontent.com/assets/1004115/11491930/6e1e74ea-9808-11e5-977e-c20ecf81b2af.png) 7 | 8 | Download [RNGLDesktop.app.zip](https://github.com/ptmt/rnd-gl-example/releases/download/1.0.0/RNGLDesktop.app.zip) (470kb) 9 | -------------------------------------------------------------------------------- /RNGLDesktop.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0325C6A21C0C6F2500A6B483 /* libRNGL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0325C6A11C0C6F1800A6B483 /* libRNGL.a */; }; 11 | 038F30071BE377D1009A0F4C /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 038F30011BE3779A009A0F4C /* libRCTImage.a */; }; 12 | 039780D31BD79C7000452D23 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 039780D21BD79C7000452D23 /* AppDelegate.m */; }; 13 | 039780D61BD79C7000452D23 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 039780D51BD79C7000452D23 /* main.m */; }; 14 | 039780D81BD79C7000452D23 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 039780D71BD79C7000452D23 /* Assets.xcassets */; }; 15 | 039781011BD79ECA00452D23 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 039781001BD79EBA00452D23 /* libRCTNetwork.a */; }; 16 | 039781021BD79ECA00452D23 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 039780F41BD79E8700452D23 /* libRCTText.a */; }; 17 | 039781031BD79ECA00452D23 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 039780FA1BD79E9E00452D23 /* libRCTWebSocket.a */; }; 18 | 039781041BD79ECA00452D23 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 039780EE1BD79E6200452D23 /* libReact.a */; }; 19 | 0397810B1BD7C1BA00452D23 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0397810A1BD7BF3100452D23 /* libRCTLinking.a */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 0325C6A01C0C6F1800A6B483 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 0325C6961C0C6F1800A6B483 /* RNGL.xcodeproj */; 26 | proxyType = 2; 27 | remoteGlobalIDString = 4107012F1ACB723B00C6AA39; 28 | remoteInfo = RNGL; 29 | }; 30 | 038F30001BE3779A009A0F4C /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 038F2FFC1BE3779A009A0F4C /* RCTImage.xcodeproj */; 33 | proxyType = 2; 34 | remoteGlobalIDString = 58B5115D1A9E6B3D00147676; 35 | remoteInfo = RCTImage; 36 | }; 37 | 039780ED1BD79E6200452D23 /* PBXContainerItemProxy */ = { 38 | isa = PBXContainerItemProxy; 39 | containerPortal = 039780E91BD79E6200452D23 /* React.xcodeproj */; 40 | proxyType = 2; 41 | remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; 42 | remoteInfo = React; 43 | }; 44 | 039780F31BD79E8700452D23 /* PBXContainerItemProxy */ = { 45 | isa = PBXContainerItemProxy; 46 | containerPortal = 039780EF1BD79E8700452D23 /* RCTText.xcodeproj */; 47 | proxyType = 2; 48 | remoteGlobalIDString = 58B5119B1A9E6C1200147676; 49 | remoteInfo = RCTText; 50 | }; 51 | 039780F91BD79E9E00452D23 /* PBXContainerItemProxy */ = { 52 | isa = PBXContainerItemProxy; 53 | containerPortal = 039780F51BD79E9E00452D23 /* RCTWebSocket.xcodeproj */; 54 | proxyType = 2; 55 | remoteGlobalIDString = 3C86DF461ADF2C930047B81A; 56 | remoteInfo = RCTWebSocket; 57 | }; 58 | 039780FF1BD79EBA00452D23 /* PBXContainerItemProxy */ = { 59 | isa = PBXContainerItemProxy; 60 | containerPortal = 039780FB1BD79EBA00452D23 /* RCTNetwork.xcodeproj */; 61 | proxyType = 2; 62 | remoteGlobalIDString = 58B511DB1A9E6C8500147676; 63 | remoteInfo = RCTNetwork; 64 | }; 65 | 039781091BD7BF3100452D23 /* PBXContainerItemProxy */ = { 66 | isa = PBXContainerItemProxy; 67 | containerPortal = 039781051BD7BF3100452D23 /* RCTLinking.xcodeproj */; 68 | proxyType = 2; 69 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 70 | remoteInfo = RCTLinking; 71 | }; 72 | /* End PBXContainerItemProxy section */ 73 | 74 | /* Begin PBXFileReference section */ 75 | 0325C6961C0C6F1800A6B483 /* RNGL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RNGL.xcodeproj; path = "node_modules/gl-react-native/osx/RNGL.xcodeproj"; sourceTree = ""; }; 76 | 038F2FFC1BE3779A009A0F4C /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "node_modules/react-native-desktop/Libraries/Image/RCTImage.xcodeproj"; sourceTree = ""; }; 77 | 039780CE1BD79C7000452D23 /* RNGLDesktop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RNGLDesktop.app; sourceTree = BUILT_PRODUCTS_DIR; }; 78 | 039780D11BD79C7000452D23 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 79 | 039780D21BD79C7000452D23 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 80 | 039780D51BD79C7000452D23 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 81 | 039780D71BD79C7000452D23 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 82 | 039780DC1BD79C7000452D23 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 83 | 039780E91BD79E6200452D23 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "node_modules/react-native-desktop/React/React.xcodeproj"; sourceTree = ""; }; 84 | 039780EF1BD79E8700452D23 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "node_modules/react-native-desktop//Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; 85 | 039780F51BD79E9E00452D23 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "node_modules/react-native-desktop/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = ""; }; 86 | 039780FB1BD79EBA00452D23 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "node_modules/react-native-desktop/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = ""; }; 87 | 039781051BD7BF3100452D23 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "node_modules/react-native-desktop/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 88 | /* End PBXFileReference section */ 89 | 90 | /* Begin PBXFrameworksBuildPhase section */ 91 | 039780CB1BD79C7000452D23 /* Frameworks */ = { 92 | isa = PBXFrameworksBuildPhase; 93 | buildActionMask = 2147483647; 94 | files = ( 95 | 0325C6A21C0C6F2500A6B483 /* libRNGL.a in Frameworks */, 96 | 038F30071BE377D1009A0F4C /* libRCTImage.a in Frameworks */, 97 | 0397810B1BD7C1BA00452D23 /* libRCTLinking.a in Frameworks */, 98 | 039781011BD79ECA00452D23 /* libRCTNetwork.a in Frameworks */, 99 | 039781021BD79ECA00452D23 /* libRCTText.a in Frameworks */, 100 | 039781031BD79ECA00452D23 /* libRCTWebSocket.a in Frameworks */, 101 | 039781041BD79ECA00452D23 /* libReact.a in Frameworks */, 102 | ); 103 | runOnlyForDeploymentPostprocessing = 0; 104 | }; 105 | /* End PBXFrameworksBuildPhase section */ 106 | 107 | /* Begin PBXGroup section */ 108 | 0325C6971C0C6F1800A6B483 /* Products */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 0325C6A11C0C6F1800A6B483 /* libRNGL.a */, 112 | ); 113 | name = Products; 114 | sourceTree = ""; 115 | }; 116 | 038F2FFD1BE3779A009A0F4C /* Products */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 038F30011BE3779A009A0F4C /* libRCTImage.a */, 120 | ); 121 | name = Products; 122 | sourceTree = ""; 123 | }; 124 | 039780C51BD79C7000452D23 = { 125 | isa = PBXGroup; 126 | children = ( 127 | 039780D01BD79C7000452D23 /* RNGLDesktop */, 128 | 039780CF1BD79C7000452D23 /* Products */, 129 | 039780E21BD79C8400452D23 /* Libraries */, 130 | ); 131 | sourceTree = ""; 132 | }; 133 | 039780CF1BD79C7000452D23 /* Products */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 039780CE1BD79C7000452D23 /* RNGLDesktop.app */, 137 | ); 138 | name = Products; 139 | sourceTree = ""; 140 | }; 141 | 039780D01BD79C7000452D23 /* RNGLDesktop */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 039780D11BD79C7000452D23 /* AppDelegate.h */, 145 | 039780D21BD79C7000452D23 /* AppDelegate.m */, 146 | 039780D71BD79C7000452D23 /* Assets.xcassets */, 147 | 039780DC1BD79C7000452D23 /* Info.plist */, 148 | 039780D41BD79C7000452D23 /* Supporting Files */, 149 | ); 150 | path = RNGLDesktop; 151 | sourceTree = ""; 152 | }; 153 | 039780D41BD79C7000452D23 /* Supporting Files */ = { 154 | isa = PBXGroup; 155 | children = ( 156 | 039780D51BD79C7000452D23 /* main.m */, 157 | ); 158 | name = "Supporting Files"; 159 | sourceTree = ""; 160 | }; 161 | 039780E21BD79C8400452D23 /* Libraries */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | 0325C6961C0C6F1800A6B483 /* RNGL.xcodeproj */, 165 | 038F2FFC1BE3779A009A0F4C /* RCTImage.xcodeproj */, 166 | 039781051BD7BF3100452D23 /* RCTLinking.xcodeproj */, 167 | 039780FB1BD79EBA00452D23 /* RCTNetwork.xcodeproj */, 168 | 039780F51BD79E9E00452D23 /* RCTWebSocket.xcodeproj */, 169 | 039780EF1BD79E8700452D23 /* RCTText.xcodeproj */, 170 | 039780E91BD79E6200452D23 /* React.xcodeproj */, 171 | ); 172 | name = Libraries; 173 | sourceTree = ""; 174 | }; 175 | 039780EA1BD79E6200452D23 /* Products */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | 039780EE1BD79E6200452D23 /* libReact.a */, 179 | ); 180 | name = Products; 181 | sourceTree = ""; 182 | }; 183 | 039780F01BD79E8700452D23 /* Products */ = { 184 | isa = PBXGroup; 185 | children = ( 186 | 039780F41BD79E8700452D23 /* libRCTText.a */, 187 | ); 188 | name = Products; 189 | sourceTree = ""; 190 | }; 191 | 039780F61BD79E9E00452D23 /* Products */ = { 192 | isa = PBXGroup; 193 | children = ( 194 | 039780FA1BD79E9E00452D23 /* libRCTWebSocket.a */, 195 | ); 196 | name = Products; 197 | sourceTree = ""; 198 | }; 199 | 039780FC1BD79EBA00452D23 /* Products */ = { 200 | isa = PBXGroup; 201 | children = ( 202 | 039781001BD79EBA00452D23 /* libRCTNetwork.a */, 203 | ); 204 | name = Products; 205 | sourceTree = ""; 206 | }; 207 | 039781061BD7BF3100452D23 /* Products */ = { 208 | isa = PBXGroup; 209 | children = ( 210 | 0397810A1BD7BF3100452D23 /* libRCTLinking.a */, 211 | ); 212 | name = Products; 213 | sourceTree = ""; 214 | }; 215 | /* End PBXGroup section */ 216 | 217 | /* Begin PBXNativeTarget section */ 218 | 039780CD1BD79C7000452D23 /* RNGLDesktop */ = { 219 | isa = PBXNativeTarget; 220 | buildConfigurationList = 039780DF1BD79C7000452D23 /* Build configuration list for PBXNativeTarget "RNGLDesktop" */; 221 | buildPhases = ( 222 | 039780CA1BD79C7000452D23 /* Sources */, 223 | 039780CB1BD79C7000452D23 /* Frameworks */, 224 | 039780CC1BD79C7000452D23 /* Resources */, 225 | ); 226 | buildRules = ( 227 | ); 228 | dependencies = ( 229 | ); 230 | name = RNGLDesktop; 231 | productName = RNGLDesktop; 232 | productReference = 039780CE1BD79C7000452D23 /* RNGLDesktop.app */; 233 | productType = "com.apple.product-type.application"; 234 | }; 235 | /* End PBXNativeTarget section */ 236 | 237 | /* Begin PBXProject section */ 238 | 039780C61BD79C7000452D23 /* Project object */ = { 239 | isa = PBXProject; 240 | attributes = { 241 | LastUpgradeCheck = 0710; 242 | ORGANIZATIONNAME = Elephant; 243 | TargetAttributes = { 244 | 039780CD1BD79C7000452D23 = { 245 | CreatedOnToolsVersion = 7.1; 246 | }; 247 | }; 248 | }; 249 | buildConfigurationList = 039780C91BD79C7000452D23 /* Build configuration list for PBXProject "RNGLDesktop" */; 250 | compatibilityVersion = "Xcode 3.2"; 251 | developmentRegion = English; 252 | hasScannedForEncodings = 0; 253 | knownRegions = ( 254 | en, 255 | Base, 256 | ); 257 | mainGroup = 039780C51BD79C7000452D23; 258 | productRefGroup = 039780CF1BD79C7000452D23 /* Products */; 259 | projectDirPath = ""; 260 | projectReferences = ( 261 | { 262 | ProductGroup = 038F2FFD1BE3779A009A0F4C /* Products */; 263 | ProjectRef = 038F2FFC1BE3779A009A0F4C /* RCTImage.xcodeproj */; 264 | }, 265 | { 266 | ProductGroup = 039781061BD7BF3100452D23 /* Products */; 267 | ProjectRef = 039781051BD7BF3100452D23 /* RCTLinking.xcodeproj */; 268 | }, 269 | { 270 | ProductGroup = 039780FC1BD79EBA00452D23 /* Products */; 271 | ProjectRef = 039780FB1BD79EBA00452D23 /* RCTNetwork.xcodeproj */; 272 | }, 273 | { 274 | ProductGroup = 039780F01BD79E8700452D23 /* Products */; 275 | ProjectRef = 039780EF1BD79E8700452D23 /* RCTText.xcodeproj */; 276 | }, 277 | { 278 | ProductGroup = 039780F61BD79E9E00452D23 /* Products */; 279 | ProjectRef = 039780F51BD79E9E00452D23 /* RCTWebSocket.xcodeproj */; 280 | }, 281 | { 282 | ProductGroup = 039780EA1BD79E6200452D23 /* Products */; 283 | ProjectRef = 039780E91BD79E6200452D23 /* React.xcodeproj */; 284 | }, 285 | { 286 | ProductGroup = 0325C6971C0C6F1800A6B483 /* Products */; 287 | ProjectRef = 0325C6961C0C6F1800A6B483 /* RNGL.xcodeproj */; 288 | }, 289 | ); 290 | projectRoot = ""; 291 | targets = ( 292 | 039780CD1BD79C7000452D23 /* RNGLDesktop */, 293 | ); 294 | }; 295 | /* End PBXProject section */ 296 | 297 | /* Begin PBXReferenceProxy section */ 298 | 0325C6A11C0C6F1800A6B483 /* libRNGL.a */ = { 299 | isa = PBXReferenceProxy; 300 | fileType = archive.ar; 301 | path = libRNGL.a; 302 | remoteRef = 0325C6A01C0C6F1800A6B483 /* PBXContainerItemProxy */; 303 | sourceTree = BUILT_PRODUCTS_DIR; 304 | }; 305 | 038F30011BE3779A009A0F4C /* libRCTImage.a */ = { 306 | isa = PBXReferenceProxy; 307 | fileType = archive.ar; 308 | path = libRCTImage.a; 309 | remoteRef = 038F30001BE3779A009A0F4C /* PBXContainerItemProxy */; 310 | sourceTree = BUILT_PRODUCTS_DIR; 311 | }; 312 | 039780EE1BD79E6200452D23 /* libReact.a */ = { 313 | isa = PBXReferenceProxy; 314 | fileType = archive.ar; 315 | path = libReact.a; 316 | remoteRef = 039780ED1BD79E6200452D23 /* PBXContainerItemProxy */; 317 | sourceTree = BUILT_PRODUCTS_DIR; 318 | }; 319 | 039780F41BD79E8700452D23 /* libRCTText.a */ = { 320 | isa = PBXReferenceProxy; 321 | fileType = archive.ar; 322 | path = libRCTText.a; 323 | remoteRef = 039780F31BD79E8700452D23 /* PBXContainerItemProxy */; 324 | sourceTree = BUILT_PRODUCTS_DIR; 325 | }; 326 | 039780FA1BD79E9E00452D23 /* libRCTWebSocket.a */ = { 327 | isa = PBXReferenceProxy; 328 | fileType = archive.ar; 329 | path = libRCTWebSocket.a; 330 | remoteRef = 039780F91BD79E9E00452D23 /* PBXContainerItemProxy */; 331 | sourceTree = BUILT_PRODUCTS_DIR; 332 | }; 333 | 039781001BD79EBA00452D23 /* libRCTNetwork.a */ = { 334 | isa = PBXReferenceProxy; 335 | fileType = archive.ar; 336 | path = libRCTNetwork.a; 337 | remoteRef = 039780FF1BD79EBA00452D23 /* PBXContainerItemProxy */; 338 | sourceTree = BUILT_PRODUCTS_DIR; 339 | }; 340 | 0397810A1BD7BF3100452D23 /* libRCTLinking.a */ = { 341 | isa = PBXReferenceProxy; 342 | fileType = archive.ar; 343 | path = libRCTLinking.a; 344 | remoteRef = 039781091BD7BF3100452D23 /* PBXContainerItemProxy */; 345 | sourceTree = BUILT_PRODUCTS_DIR; 346 | }; 347 | /* End PBXReferenceProxy section */ 348 | 349 | /* Begin PBXResourcesBuildPhase section */ 350 | 039780CC1BD79C7000452D23 /* Resources */ = { 351 | isa = PBXResourcesBuildPhase; 352 | buildActionMask = 2147483647; 353 | files = ( 354 | 039780D81BD79C7000452D23 /* Assets.xcassets in Resources */, 355 | ); 356 | runOnlyForDeploymentPostprocessing = 0; 357 | }; 358 | /* End PBXResourcesBuildPhase section */ 359 | 360 | /* Begin PBXSourcesBuildPhase section */ 361 | 039780CA1BD79C7000452D23 /* Sources */ = { 362 | isa = PBXSourcesBuildPhase; 363 | buildActionMask = 2147483647; 364 | files = ( 365 | 039780D61BD79C7000452D23 /* main.m in Sources */, 366 | 039780D31BD79C7000452D23 /* AppDelegate.m in Sources */, 367 | ); 368 | runOnlyForDeploymentPostprocessing = 0; 369 | }; 370 | /* End PBXSourcesBuildPhase section */ 371 | 372 | /* Begin XCBuildConfiguration section */ 373 | 039780DD1BD79C7000452D23 /* Debug */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | ALWAYS_SEARCH_USER_PATHS = YES; 377 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 378 | CLANG_CXX_LIBRARY = "libc++"; 379 | CLANG_ENABLE_MODULES = YES; 380 | CLANG_ENABLE_OBJC_ARC = YES; 381 | CLANG_WARN_BOOL_CONVERSION = YES; 382 | CLANG_WARN_CONSTANT_CONVERSION = YES; 383 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 384 | CLANG_WARN_EMPTY_BODY = YES; 385 | CLANG_WARN_ENUM_CONVERSION = YES; 386 | CLANG_WARN_INT_CONVERSION = YES; 387 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 388 | CLANG_WARN_UNREACHABLE_CODE = YES; 389 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 390 | CODE_SIGN_IDENTITY = "-"; 391 | COPY_PHASE_STRIP = NO; 392 | DEBUG_INFORMATION_FORMAT = dwarf; 393 | ENABLE_STRICT_OBJC_MSGSEND = YES; 394 | ENABLE_TESTABILITY = YES; 395 | GCC_C_LANGUAGE_STANDARD = gnu99; 396 | GCC_DYNAMIC_NO_PIC = NO; 397 | GCC_NO_COMMON_BLOCKS = YES; 398 | GCC_OPTIMIZATION_LEVEL = 0; 399 | GCC_PREPROCESSOR_DEFINITIONS = ( 400 | "DEBUG=1", 401 | "$(inherited)", 402 | ); 403 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 404 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 405 | GCC_WARN_UNDECLARED_SELECTOR = YES; 406 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 407 | GCC_WARN_UNUSED_FUNCTION = YES; 408 | GCC_WARN_UNUSED_VARIABLE = YES; 409 | MACOSX_DEPLOYMENT_TARGET = 10.11; 410 | MTL_ENABLE_DEBUG_INFO = YES; 411 | ONLY_ACTIVE_ARCH = YES; 412 | SDKROOT = macosx; 413 | }; 414 | name = Debug; 415 | }; 416 | 039780DE1BD79C7000452D23 /* Release */ = { 417 | isa = XCBuildConfiguration; 418 | buildSettings = { 419 | ALWAYS_SEARCH_USER_PATHS = YES; 420 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 421 | CLANG_CXX_LIBRARY = "libc++"; 422 | CLANG_ENABLE_MODULES = YES; 423 | CLANG_ENABLE_OBJC_ARC = YES; 424 | CLANG_WARN_BOOL_CONVERSION = YES; 425 | CLANG_WARN_CONSTANT_CONVERSION = YES; 426 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 427 | CLANG_WARN_EMPTY_BODY = YES; 428 | CLANG_WARN_ENUM_CONVERSION = YES; 429 | CLANG_WARN_INT_CONVERSION = YES; 430 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 431 | CLANG_WARN_UNREACHABLE_CODE = YES; 432 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 433 | CODE_SIGN_IDENTITY = "-"; 434 | COPY_PHASE_STRIP = NO; 435 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 436 | ENABLE_NS_ASSERTIONS = NO; 437 | ENABLE_STRICT_OBJC_MSGSEND = YES; 438 | GCC_C_LANGUAGE_STANDARD = gnu99; 439 | GCC_NO_COMMON_BLOCKS = YES; 440 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 441 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 442 | GCC_WARN_UNDECLARED_SELECTOR = YES; 443 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 444 | GCC_WARN_UNUSED_FUNCTION = YES; 445 | GCC_WARN_UNUSED_VARIABLE = YES; 446 | MACOSX_DEPLOYMENT_TARGET = 10.11; 447 | MTL_ENABLE_DEBUG_INFO = NO; 448 | SDKROOT = macosx; 449 | }; 450 | name = Release; 451 | }; 452 | 039780E01BD79C7000452D23 /* Debug */ = { 453 | isa = XCBuildConfiguration; 454 | buildSettings = { 455 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 456 | COMBINE_HIDPI_IMAGES = YES; 457 | HEADER_SEARCH_PATHS = ( 458 | "$(SRCROOT)/node_modules/react-native-desktop/React/**", 459 | "$(inherited)", 460 | ); 461 | INFOPLIST_FILE = RNGLDesktop/Info.plist; 462 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 463 | MACOSX_DEPLOYMENT_TARGET = 10.11; 464 | OTHER_LDFLAGS = "-ObjC"; 465 | PRODUCT_BUNDLE_IDENTIFIER = com.elephant.RNGLDesktop; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | }; 468 | name = Debug; 469 | }; 470 | 039780E11BD79C7000452D23 /* Release */ = { 471 | isa = XCBuildConfiguration; 472 | buildSettings = { 473 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 474 | COMBINE_HIDPI_IMAGES = YES; 475 | HEADER_SEARCH_PATHS = ( 476 | "$(SRCROOT)/node_modules/react-native-desktop/React/**", 477 | "$(inherited)", 478 | ); 479 | INFOPLIST_FILE = RNGLDesktop/Info.plist; 480 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 481 | MACOSX_DEPLOYMENT_TARGET = 10.11; 482 | OTHER_LDFLAGS = "-ObjC"; 483 | PRODUCT_BUNDLE_IDENTIFIER = com.elephant.RNGLDesktop; 484 | PRODUCT_NAME = "$(TARGET_NAME)"; 485 | }; 486 | name = Release; 487 | }; 488 | /* End XCBuildConfiguration section */ 489 | 490 | /* Begin XCConfigurationList section */ 491 | 039780C91BD79C7000452D23 /* Build configuration list for PBXProject "RNGLDesktop" */ = { 492 | isa = XCConfigurationList; 493 | buildConfigurations = ( 494 | 039780DD1BD79C7000452D23 /* Debug */, 495 | 039780DE1BD79C7000452D23 /* Release */, 496 | ); 497 | defaultConfigurationIsVisible = 0; 498 | defaultConfigurationName = Release; 499 | }; 500 | 039780DF1BD79C7000452D23 /* Build configuration list for PBXNativeTarget "RNGLDesktop" */ = { 501 | isa = XCConfigurationList; 502 | buildConfigurations = ( 503 | 039780E01BD79C7000452D23 /* Debug */, 504 | 039780E11BD79C7000452D23 /* Release */, 505 | ); 506 | defaultConfigurationIsVisible = 0; 507 | defaultConfigurationName = Release; 508 | }; 509 | /* End XCConfigurationList section */ 510 | }; 511 | rootObject = 039780C61BD79C7000452D23 /* Project object */; 512 | } 513 | -------------------------------------------------------------------------------- /RNGLDesktop/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SimpleGmailClient 4 | // 5 | // Created by Dmitriy Loktev on 10/21/15. 6 | // Copyright © 2015 Elephant. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : NSObject 12 | 13 | @property (strong, nonatomic) NSWindow *window; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /RNGLDesktop/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SimpleGmailClient 4 | // 5 | // Created by Dmitriy Loktev on 10/21/15. 6 | // Copyright © 2015 Elephant. All rights reserved. 7 | // 8 | 9 | /** 10 | * The examples provided by Facebook are for non-commercial testing and 11 | * evaluation purposes only. 12 | * 13 | * Facebook reserves all rights not expressly granted. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL 18 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #import "AppDelegate.h" 24 | 25 | #import "RCTBridge.h" 26 | #import "RCTJavaScriptLoader.h" 27 | #import "RCTRootView.h" 28 | #import 29 | 30 | @interface AppDelegate() 31 | 32 | @end 33 | 34 | @implementation AppDelegate 35 | 36 | -(id)init 37 | { 38 | if(self = [super init]) { 39 | NSRect contentSize = NSMakeRect(200, 500, 1000, 500); // TODO: should not be hardcoded 40 | 41 | self.window = [[NSWindow alloc] initWithContentRect:contentSize 42 | styleMask:NSTitledWindowMask | NSResizableWindowMask | NSFullSizeContentViewWindowMask | NSMiniaturizableWindowMask | NSClosableWindowMask 43 | backing:NSBackingStoreBuffered 44 | defer:NO]; 45 | NSWindowController *windowController = [[NSWindowController alloc] initWithWindow:self.window]; 46 | 47 | [[self window] setTitleVisibility:NSWindowTitleHidden]; 48 | [[self window] setTitlebarAppearsTransparent:YES]; 49 | [[self window] setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameAqua]]; 50 | 51 | [windowController setShouldCascadeWindows:NO]; 52 | [windowController setWindowFrameAutosaveName:@"RNGLDesktop"]; 53 | 54 | [windowController showWindow:self.window]; 55 | 56 | // TODO: remove broilerplate 57 | [self setUpApplicationMenu]; 58 | } 59 | return self; 60 | } 61 | 62 | - (void)applicationDidFinishLaunching:(__unused NSNotification *)aNotification 63 | { 64 | 65 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self 66 | launchOptions:nil]; 67 | 68 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 69 | moduleName:@"RNGLDesktop" 70 | initialProperties:nil]; 71 | 72 | 73 | 74 | [self.window setContentView:rootView]; 75 | } 76 | 77 | 78 | - (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge 79 | { 80 | NSURL *sourceURL; 81 | 82 | /** 83 | * Loading JavaScript code - uncomment the one you want. 84 | * 85 | * OPTION 1 86 | * Load from development server. Start the server from the repository root: 87 | * 88 | * $ npm start 89 | * 90 | * To run on device, change `localhost` to the IP address of your computer 91 | * (you can get this by typing `ifconfig` into the terminal and selecting the 92 | * `inet` value under `en0:`) and make sure your computer and iOS device are 93 | * on the same Wi-Fi network. 94 | */ 95 | 96 | sourceURL = [NSURL URLWithString:@"http://localhost:8081/index.osx.bundle?platform=osx&dev=true"]; 97 | 98 | /** 99 | * OPTION 2 100 | * Load from pre-bundled file on disk. To re-generate the static bundle, `cd` 101 | * to your Xcode project folder and run 102 | * 103 | * $ curl 'http://localhost:8081/index.osx.bundle?platform=osx&dev=false&minify=true' -o RNGLDesktop/main.jsbundle 104 | * 105 | * then add the `main.jsbundle` file to your project and uncomment this line: 106 | */ 107 | 108 | //sourceURL = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 109 | 110 | #if RUNNING_ON_CI 111 | sourceURL = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 112 | #endif 113 | 114 | return sourceURL; 115 | } 116 | 117 | - (void)loadSourceForBridge:(RCTBridge *)bridge 118 | withBlock:(RCTSourceLoadBlock)loadCallback 119 | { 120 | [RCTJavaScriptLoader loadBundleAtURL:[self sourceURLForBridge:bridge] 121 | onComplete:loadCallback]; 122 | } 123 | 124 | 125 | - (void)setUpApplicationMenu 126 | { 127 | NSMenu *mainMenu = [[NSMenu alloc] initWithTitle:@"" ]; 128 | NSMenuItem *containerItem = [[NSMenuItem alloc] init]; 129 | NSMenu *rootMenu = [[NSMenu alloc] initWithTitle:@"" ]; 130 | [containerItem setSubmenu:rootMenu]; 131 | //[mainMenu addItem:containerItem]; 132 | [rootMenu addItemWithTitle:@"Quit RNGLDesktop" action:@selector(terminate) keyEquivalent:@"Q"]; 133 | [[NSApp mainMenu] addItem:containerItem]; 134 | } 135 | 136 | - (id)firstResponder 137 | { 138 | return [self.window firstResponder]; 139 | } 140 | 141 | @end 142 | 143 | -------------------------------------------------------------------------------- /RNGLDesktop/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /RNGLDesktop/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2015 Elephant. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | NSAppTransportSecurity 34 | 35 | NSAllowsArbitraryLoads 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /RNGLDesktop/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SimpleGmailClient 4 | // 5 | // Created by Dmitriy Loktev on 10/21/15. 6 | // Copyright © 2015 Elephant. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | NSApplication * application = [NSApplication sharedApplication]; 15 | NSMenu *mainMenu = [[NSMenu alloc] initWithTitle:@"Application"]; 16 | [NSApp setMainMenu:mainMenu]; 17 | AppDelegate * appDelegate = [[AppDelegate alloc] init]; 18 | [application setDelegate:appDelegate]; 19 | [application run]; 20 | return EXIT_SUCCESS; 21 | } 22 | } -------------------------------------------------------------------------------- /index.osx.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 'use strict'; 3 | 4 | import React, {View, Text, Dimensions} from 'react-native-desktop'; 5 | 6 | import GL from 'gl-react'; 7 | import { Surface } from "gl-react-native"; 8 | 9 | import shaders, {lightShaderText} from './shaders'; 10 | 11 | const HelloWorld = GL.createComponent(({time, resolution}) => 12 | , 13 | { displayName: "HelloGL" } 14 | ); 15 | 16 | class RNGLDesktop extends React.Component { 17 | constructor() { 18 | super(); 19 | this.state = { 20 | time: 0 21 | } 22 | } 23 | componentDidMount() { 24 | this.play(); 25 | } 26 | play() { 27 | const loop = t => { 28 | this.setState({ time: this.state.time + 0.01}); 29 | requestAnimationFrame(loop); 30 | }; 31 | loop(); 32 | } 33 | render() { 34 | const { width, height } = Dimensions.get('window'); 35 | return ( 36 | 37 | 42 | 45 | 46 | { /* */} 53 | 54 | {lightShaderText} 55 | 56 | 57 | ); 58 | // 68 | } 69 | } 70 | 71 | const styles = { 72 | textWrapper: { 73 | 74 | } 75 | } 76 | React.AppRegistry.registerComponent('RNGLDesktop', () => RNGLDesktop); 77 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rnd-gl-example", 3 | "version": "1.0.0", 4 | "description": "gl-react-native for Desktop", 5 | "main": "index.osx.js", 6 | "scripts": { 7 | "start": "node_modules/react-native-desktop/packager/packager.sh", 8 | "build": "curl 'http://localhost:8081/index.osx.bundle?platform=osx&dev=false&minify=true' -o RNGLDesktop/main.jsbundle" 9 | }, 10 | "author": "Dmitry Loktev", 11 | "license": "ISC", 12 | "dependencies": { 13 | "gl-react-native": "ptmt/gl-react-native", 14 | "gl-react": "*", 15 | "react-native-desktop": "0.3.7" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /shaders.js: -------------------------------------------------------------------------------- 1 | const GL = require("gl-react"); 2 | 3 | const lightShaderText = ` 4 | #ifdef GL_ES 5 | precision mediump float; 6 | #endif 7 | 8 | uniform vec2 resolution; 9 | uniform float time; 10 | 11 | void main() { 12 | vec2 p = (gl_FragCoord.xy * 2.0 - resolution) / min(resolution.x,resolution.y); 13 | 14 | float radius = 1.0; 15 | float radiusMovSpeed = 1.3; 16 | float speed = 0.3; 17 | float timeSpeedDiff = 0.11; 18 | float circleSize = 0.03; 19 | float distanceDiff = 0.1; 20 | 21 | vec3 colorDest = vec3(1.0,1.0,0.0); 22 | for(float i = 0.0;i < 19.0; i++) 23 | { 24 | float j = i + 1.0; 25 | vec2 q = p + vec2((radius*cos(time*radiusMovSpeed))*cos(time*(speed+timeSpeedDiff*j) + j*distanceDiff),(radius*sin(time*radiusMovSpeed))*sin(time*(speed+timeSpeedDiff*j) + j*distanceDiff)); 26 | float l = circleSize/length(q); 27 | colorDest += vec3(l-0.15,l-0.15,l-0.03); 28 | } 29 | gl_FragColor = vec4(vec3(colorDest),1.0); 30 | } 31 | `; 32 | 33 | 34 | const shaders = GL.Shaders.create({ 35 | helloGL: { 36 | frag: ` 37 | varying vec2 uv; 38 | uniform vec2 resolution; 39 | void main () { 40 | gl_FragColor = vec4(uv.x, uv.y, 0.5, 1.0); 41 | }` 42 | }, 43 | light: { 44 | frag: lightShaderText 45 | }, 46 | smoke: { 47 | frag: ` 48 | #ifdef GL_ES 49 | precision lowp float; 50 | #endif 51 | #define LINEAR_DENSITY 0 // 0: constant 52 | #define H .05 // skin layer thickness (for linear density) 53 | #define ANIM true // true/false 54 | #define PI 3.14159 55 | uniform vec2 resolution; 56 | uniform float time; 57 | varying vec2 uv; 58 | // --- noise functions from https://www.shadertoy.com/view/XslGRr 59 | // Created by inigo quilez - iq/2013 60 | // License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. 61 | mat3 m = mat3( 0.00, 0.80, 0.60, 62 | -0.80, 0.36, -0.48, 63 | -0.60, -0.48, 0.64 ); 64 | 65 | float hash( float n ) 66 | { 67 | return fract(sin(n)*43758.5453); 68 | } 69 | float radius() { 70 | return time / 24.0; 71 | } 72 | float density () { 73 | return time / 24.0 + 0.7; 74 | } 75 | float noise( in vec3 x ) 76 | { 77 | vec3 p = floor(x); 78 | vec3 f = fract(x); 79 | f = f*f*(3.0-2.0*f); 80 | float n = p.x + p.y*57.0 + 113.0*p.z; 81 | float res = mix(mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x), 82 | mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y), 83 | mix(mix( hash(n+113.0), hash(n+114.0),f.x), 84 | mix( hash(n+170.0), hash(n+171.0),f.x),f.y),f.z); 85 | return res; 86 | } 87 | float fbm( vec3 p ) 88 | { 89 | float f; 90 | f = 0.5000*noise( p ); p = m*p*2.02; 91 | f += 0.2500*noise( p ); p = m*p*2.03; 92 | f += 0.1250*noise( p ); p = m*p*2.01; 93 | f += 0.0625*noise( p ); 94 | return f; 95 | } 96 | // --- End of: Created by inigo quilez -------------------- 97 | vec3 noise3( vec3 p ) 98 | { 99 | if (ANIM) p += time; 100 | float fx = noise(p); 101 | float fy = noise(p+vec3(1345.67,0,45.67)); 102 | float fz = noise(p+vec3(0,4567.8,-123.4)); 103 | return vec3(fx,fy,fz); 104 | } 105 | vec3 fbm3( vec3 p ) 106 | { 107 | if (ANIM) p += time; 108 | float fx = fbm(p); 109 | float fy = fbm(p+vec3(1345.67,0,45.67)); 110 | float fz = fbm(p+vec3(0,4567.8,-123.4)); 111 | return vec3(fx,fy,fz); 112 | } 113 | vec3 perturb3(vec3 p, float scaleX, float scaleI) 114 | { 115 | scaleX *= 2.; 116 | return scaleI*scaleX*fbm3(p/scaleX); // usually, to be added to p 117 | } 118 | float constantDensityTransmittance(float NDotL,float NDotO) 119 | { 120 | return NDotL/(density()*(NDotL+NDotO)); 121 | } 122 | float linearDensityTransmittance(float NDotL,float NDotO) 123 | { 124 | return sqrt(PI/2.) / sqrt(density()/H) ; // test1 125 | } 126 | //float Rz=0.; // 1/2 ray length inside object 127 | float intersectSphere(vec3 rpos, vec3 rdir, float r) 128 | { 129 | vec3 op = vec3(0.0, 0.0, 0.0) - rpos; 130 | //float rad = 0.3; 131 | float Rz = 0.; 132 | float eps = 1e-9; 133 | float b = dot(op, rdir); 134 | float det = b*b - dot(op, op) + r*r; 135 | if (det > 0.0) 136 | { 137 | det = sqrt(det); 138 | float t = b - det; 139 | if (t > eps) 140 | { 141 | vec4 P = vec4(normalize(rpos+rdir*t), t); 142 | Rz = r*P.z; // 1/2 ray length inside object 143 | #if LINEAR_DENSITY 144 | // skin layer counts less 145 | float dH = 1.+H*(H-2.*r/Rz*Rz); 146 | if (dH>0.) // core region 147 | Rz *= .5*(1.+sqrt(dH)); 148 | else 149 | Rz *= .5*r*(1.-sqrt(1.-Rz*Rz/r*r))/H; 150 | #endif 151 | //return P; 152 | } 153 | } 154 | return Rz; 155 | } 156 | float computeNormal(in vec3 cameraPos, in vec3 cameraDir, out vec3 normal, float r) 157 | { 158 | cameraPos = cameraPos+perturb3(cameraDir,.06,1.5); 159 | return intersectSphere(cameraPos, cameraDir, r); 160 | } 161 | float computeTransmittance( in vec3 cameraPos, in vec3 cameraDir, float r) 162 | { 163 | vec3 normal; 164 | return computeNormal(cameraPos, cameraDir, normal, r); 165 | } 166 | 167 | void main(void) 168 | { 169 | vec4 fragCoord = gl_FragCoord; 170 | vec3 cameraPos = vec3(0.0,0.0,1.0); 171 | vec3 cameraTarget = vec3(0.0, 0.0, 0.0); 172 | vec3 ww = normalize( cameraPos - cameraTarget ); 173 | vec3 uu = normalize(cross( vec3(0.0,1.0,0.0), ww )); 174 | vec3 vv = normalize(cross(ww,uu)); 175 | vec2 q = fragCoord.xy / resolution.xy; 176 | vec2 p = -1.0 + 2.0 * q; 177 | p.x *= resolution.x/ resolution.y; 178 | vec3 cameraDir = normalize( p.x*uu + p.y*vv - 1.5*ww ); 179 | float RzRed = 0.; 180 | RzRed = computeTransmittance(cameraPos, cameraDir, radius()); 181 | RzRed = 1. - exp(-8. * density() * RzRed); 182 | float alphaRed = RzRed; //228,44,229 183 | vec4 colorRed = vec4(1. - alphaRed, 0.1 - alphaRed, 0.9 - alphaRed, alphaRed); 184 | gl_FragColor = colorRed; 185 | 186 | } 187 | ` 188 | } 189 | }); 190 | 191 | shaders.lightShaderText = lightShaderText; 192 | module.exports = shaders; 193 | --------------------------------------------------------------------------------