├── .gitignore ├── .gitmodules ├── Cocos2DShaderCookbook.xcodeproj └── project.pbxproj ├── Cookbook ├── Classes │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── ExampleBase.h │ └── ExampleBase.m ├── Docs │ ├── E01_SimplestShader.md │ ├── E01_SimplestShader.png │ ├── E02_SpriteColor.md │ ├── E02_SpriteColor.png │ ├── E03_SpriteDistort.md │ ├── E03_SpriteDistort.png │ ├── E04_Grayscale.md │ ├── E04_Grayscale.png │ ├── E05_Chromatic.md │ ├── E05_Chromatic.png │ ├── E06_Shadow.md │ ├── E06_Shadow.png │ ├── E07_ColorFlash.md │ ├── E07_ColorFlash.png │ ├── E08_Outline.md │ ├── E08_Outline.png │ ├── E09_Static.md │ ├── E09_Static.png │ ├── E09_Water.md │ ├── E10_Water.png │ ├── E11_Diffusion.md │ ├── E11_Diffusion.png │ ├── E12_ColorMatrix.md │ ├── E12_ColorMatrix.png │ ├── E13_MotionBlur.png │ └── E15_SignedDistanceField.png ├── Examples │ ├── E01_SimplestShader.fsh │ ├── E01_SimplestShader.m │ ├── E01_SimplestShader.webarchive │ ├── E02_SpriteColor.fsh │ ├── E02_SpriteColor.m │ ├── E02_SpriteColor.webarchive │ ├── E03_SpriteDistort.fsh │ ├── E03_SpriteDistort.m │ ├── E03_SpriteDistort.webarchive │ ├── E04_Grayscale.fsh │ ├── E04_Grayscale.m │ ├── E04_Grayscale.webarchive │ ├── E05_Chromatic.fsh │ ├── E05_Chromatic.m │ ├── E05_Chromatic.webarchive │ ├── E06_Shadow.fsh │ ├── E06_Shadow.m │ ├── E06_Shadow.webarchive │ ├── E07_Color Flash.webarchive │ ├── E07_ColorFlash.fsh │ ├── E07_ColorFlash.m │ ├── E08_Outline.fsh │ ├── E08_Outline.m │ ├── E08_Outline.vsh │ ├── E08_Outline.webarchive │ ├── E09_Static.fsh │ ├── E09_Static.m │ ├── E09_Static.vsh │ ├── E09_Static.webarchive │ ├── E10_Water.fsh │ ├── E10_Water.m │ ├── E10_Water.vsh │ ├── E10_Water.webarchive │ ├── E11_Diffusion.fsh │ ├── E11_Diffusion.m │ ├── E11_Diffusion.vsh │ ├── E11_Diffusion.webarchive │ ├── E12_ColorMatrix.fsh │ ├── E12_ColorMatrix.m │ ├── E12_ColorMatrix.webarchive │ ├── E13_MotionBlur.fsh │ ├── E13_MotionBlur.m │ ├── E14_Flag.fsh │ ├── E14_Flag.m │ ├── E15_SignedDistanceField.fsh │ ├── E15_SignedDistanceField.m │ ├── E16_MetaParticles.fsh │ ├── E16_MetaParticles.m │ ├── EXX_Template.fsh │ ├── EXX_Template.m │ └── EXX_Template.vsh ├── Resources │ ├── BisectionNoise.png │ ├── Caustic.png │ ├── Default-568h@2x.png │ ├── Default-Landscape~ipad.png │ ├── Default.png │ ├── Default@2x.png │ ├── DistanceField.png │ ├── DistanceField.psd.gz │ ├── Flag-hd.png │ ├── Flag-ipadhd.png │ ├── Flag-ipadhd.psd │ ├── Fog.plist │ ├── Icons │ │ ├── Icon-120.png │ │ ├── Icon-72.png │ │ ├── Icon-72@2x.png │ │ ├── Icon-76.png │ │ ├── Icon-76@2x.png │ │ ├── Icon-Small-50.png │ │ ├── Icon-Small.png │ │ ├── Icon-Small@2x.png │ │ ├── Icon-Spotlight-iOS7.png │ │ ├── Icon-Spotlight-iOS7@2x.png │ │ ├── Icon-iPad-Spotlight-iOS7@2x.png │ │ ├── Icon.png │ │ └── Icon@2x.png │ ├── Info.plist │ ├── Interface-hd.plist │ ├── Interface-hd.png │ ├── Interface-ipadhd.plist │ ├── Interface-ipadhd.png │ ├── Logo-hd.png │ ├── Logo-ipadhd.png │ ├── Rocks-hd.png │ ├── Rocks-ipadhd.png │ ├── gaussianNoise.png │ ├── slider-background-hd.png │ ├── slider-background-ipadhd.png │ ├── slider-handle-hd.png │ └── slider-handle-ipadhd.png └── Supporting Files │ ├── Prefix.pch │ └── main.m ├── LICENSE ├── README.md └── TODO.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | DerivedData 3 | *.xcworkspace 4 | xcuserdata 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Cocos2D"] 2 | path = Cocos2D 3 | url = https://github.com/cocos2d/cocos2d-iphone.git 4 | -------------------------------------------------------------------------------- /Cocos2DShaderCookbook.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 753B79F9191A89800034A6D5 /* TODO.txt in Resources */ = {isa = PBXBuildFile; fileRef = 753B79F8191A89800034A6D5 /* TODO.txt */; }; 11 | 753B79FC191A8D970034A6D5 /* E11_Diffusion.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 753B79FA191A8D970034A6D5 /* E11_Diffusion.fsh */; }; 12 | 753B79FD191A8D970034A6D5 /* E11_Diffusion.m in Sources */ = {isa = PBXBuildFile; fileRef = 753B79FB191A8D970034A6D5 /* E11_Diffusion.m */; }; 13 | 753B7A03191A92840034A6D5 /* E11_Diffusion.vsh in Resources */ = {isa = PBXBuildFile; fileRef = 753B7A02191A92840034A6D5 /* E11_Diffusion.vsh */; }; 14 | 753B7A06191AC2DD0034A6D5 /* E12_ColorMatrix.m in Sources */ = {isa = PBXBuildFile; fileRef = 753B7A04191AC2DD0034A6D5 /* E12_ColorMatrix.m */; }; 15 | 753B7A07191AC2DD0034A6D5 /* E12_ColorMatrix.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 753B7A05191AC2DD0034A6D5 /* E12_ColorMatrix.fsh */; }; 16 | 753B7A0A191AD9710034A6D5 /* E13_MotionBlur.fsh in Resources */ = {isa = PBXBuildFile; fileRef = 753B7A08191AD9710034A6D5 /* E13_MotionBlur.fsh */; }; 17 | 753B7A0B191AD9710034A6D5 /* E13_MotionBlur.m in Sources */ = {isa = PBXBuildFile; fileRef = 753B7A09191AD9710034A6D5 /* E13_MotionBlur.m */; }; 18 | D32754F4191A94EC00865098 /* E08_Outline.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D32754F2191A94EC00865098 /* E08_Outline.fsh */; }; 19 | D32754F5191A94EC00865098 /* E08_Outline.m in Sources */ = {isa = PBXBuildFile; fileRef = D32754F3191A94EC00865098 /* E08_Outline.m */; }; 20 | D32754F8191A973D00865098 /* E08_Outline.vsh in Resources */ = {isa = PBXBuildFile; fileRef = D32754F7191A973D00865098 /* E08_Outline.vsh */; }; 21 | D3275507191AE26A00865098 /* E09_Static.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D3275505191AE26A00865098 /* E09_Static.fsh */; }; 22 | D3275508191AE26A00865098 /* E09_Static.m in Sources */ = {isa = PBXBuildFile; fileRef = D3275506191AE26A00865098 /* E09_Static.m */; }; 23 | D327550B191AE5E600865098 /* E09_Static.vsh in Resources */ = {isa = PBXBuildFile; fileRef = D327550A191AE5E600865098 /* E09_Static.vsh */; }; 24 | D327550D191AEB2400865098 /* gaussianNoise.png in Resources */ = {isa = PBXBuildFile; fileRef = D327550C191AEB2400865098 /* gaussianNoise.png */; }; 25 | D33E2B2A191D866000FEB214 /* E14_Flag.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D33E2B28191D866000FEB214 /* E14_Flag.fsh */; }; 26 | D33E2B2B191D866000FEB214 /* E14_Flag.m in Sources */ = {isa = PBXBuildFile; fileRef = D33E2B29191D866000FEB214 /* E14_Flag.m */; }; 27 | D33E2B2F191D86EC00FEB214 /* Flag-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D33E2B2D191D86EC00FEB214 /* Flag-hd.png */; }; 28 | D33E2B30191D86EC00FEB214 /* Flag-ipadhd.png in Resources */ = {isa = PBXBuildFile; fileRef = D33E2B2E191D86EC00FEB214 /* Flag-ipadhd.png */; }; 29 | D38827A6191D60FA006C1A75 /* BisectionNoise.png in Resources */ = {isa = PBXBuildFile; fileRef = D38827A2191D60FA006C1A75 /* BisectionNoise.png */; }; 30 | D38827A7191D60FA006C1A75 /* Caustic.png in Resources */ = {isa = PBXBuildFile; fileRef = D38827A3191D60FA006C1A75 /* Caustic.png */; }; 31 | D38827A8191D60FA006C1A75 /* Rocks-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D38827A4191D60FA006C1A75 /* Rocks-hd.png */; }; 32 | D38827A9191D60FA006C1A75 /* Rocks-ipadhd.png in Resources */ = {isa = PBXBuildFile; fileRef = D38827A5191D60FA006C1A75 /* Rocks-ipadhd.png */; }; 33 | D38827B1191D617F006C1A75 /* E10_Water.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D38827AE191D617F006C1A75 /* E10_Water.fsh */; }; 34 | D38827B2191D617F006C1A75 /* E10_Water.m in Sources */ = {isa = PBXBuildFile; fileRef = D38827AF191D617F006C1A75 /* E10_Water.m */; }; 35 | D38827B3191D617F006C1A75 /* E10_Water.vsh in Resources */ = {isa = PBXBuildFile; fileRef = D38827B0191D617F006C1A75 /* E10_Water.vsh */; }; 36 | D3A6CD441922A39A000E4134 /* E15_SignedDistanceField.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D3A6CD421922A39A000E4134 /* E15_SignedDistanceField.fsh */; }; 37 | D3A6CD451922A39A000E4134 /* E15_SignedDistanceField.m in Sources */ = {isa = PBXBuildFile; fileRef = D3A6CD431922A39A000E4134 /* E15_SignedDistanceField.m */; }; 38 | D3A6CD4C1922FFCA000E4134 /* DistanceField.png in Resources */ = {isa = PBXBuildFile; fileRef = D3A6CD4B1922FFCA000E4134 /* DistanceField.png */; }; 39 | D3BC84DB1940BAF100E98AD2 /* Fog.plist in Resources */ = {isa = PBXBuildFile; fileRef = D3BC84DA1940BAF100E98AD2 /* Fog.plist */; }; 40 | D3BC84DF1940BAFF00E98AD2 /* E16_MetaParticles.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D3BC84DD1940BAFF00E98AD2 /* E16_MetaParticles.fsh */; }; 41 | D3BC84E01940BAFF00E98AD2 /* E16_MetaParticles.m in Sources */ = {isa = PBXBuildFile; fileRef = D3BC84DE1940BAFF00E98AD2 /* E16_MetaParticles.m */; }; 42 | D3EF46F91919997E003E8B91 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3EF46F81919997E003E8B91 /* QuartzCore.framework */; }; 43 | D3EF46FB1919997E003E8B91 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3EF46FA1919997E003E8B91 /* OpenGLES.framework */; }; 44 | D3EF46FD1919997E003E8B91 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3EF46FC1919997E003E8B91 /* OpenAL.framework */; }; 45 | D3EF46FF1919997E003E8B91 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3EF46FE1919997E003E8B91 /* AudioToolbox.framework */; }; 46 | D3EF47011919997E003E8B91 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3EF47001919997E003E8B91 /* AVFoundation.framework */; }; 47 | D3EF47031919997E003E8B91 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3EF47021919997E003E8B91 /* UIKit.framework */; }; 48 | D3EF47051919997E003E8B91 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3EF47041919997E003E8B91 /* Foundation.framework */; }; 49 | D3EF47071919997E003E8B91 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3EF47061919997E003E8B91 /* CoreGraphics.framework */; }; 50 | D3EF47091919997E003E8B91 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3EF47081919997E003E8B91 /* CoreText.framework */; }; 51 | D3EF470B1919997E003E8B91 /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D3EF470A1919997E003E8B91 /* GLKit.framework */; }; 52 | D3EF47151919997E003E8B91 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF47141919997E003E8B91 /* Default.png */; }; 53 | D3EF47171919997E003E8B91 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF47161919997E003E8B91 /* Default@2x.png */; }; 54 | D3EF47191919997E003E8B91 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF47181919997E003E8B91 /* Default-568h@2x.png */; }; 55 | D3EF471B1919997E003E8B91 /* Default-Landscape~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF471A1919997E003E8B91 /* Default-Landscape~ipad.png */; }; 56 | D3EF471E1919997E003E8B91 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF471D1919997E003E8B91 /* Icon.png */; }; 57 | D3EF47201919997E003E8B91 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF471F1919997E003E8B91 /* Icon@2x.png */; }; 58 | D3EF47221919997E003E8B91 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF47211919997E003E8B91 /* Icon-72.png */; }; 59 | D3EF47241919997E003E8B91 /* Icon-72@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF47231919997E003E8B91 /* Icon-72@2x.png */; }; 60 | D3EF47261919997E003E8B91 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF47251919997E003E8B91 /* Icon-76.png */; }; 61 | D3EF47281919997E003E8B91 /* Icon-76@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF47271919997E003E8B91 /* Icon-76@2x.png */; }; 62 | D3EF472A1919997E003E8B91 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF47291919997E003E8B91 /* Icon-120.png */; }; 63 | D3EF472C1919997E003E8B91 /* Icon-iPad-Spotlight-iOS7@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF472B1919997E003E8B91 /* Icon-iPad-Spotlight-iOS7@2x.png */; }; 64 | D3EF472E1919997E003E8B91 /* Icon-Small-50.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF472D1919997E003E8B91 /* Icon-Small-50.png */; }; 65 | D3EF47301919997E003E8B91 /* Icon-Small.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF472F1919997E003E8B91 /* Icon-Small.png */; }; 66 | D3EF47321919997E003E8B91 /* Icon-Small@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF47311919997E003E8B91 /* Icon-Small@2x.png */; }; 67 | D3EF47341919997E003E8B91 /* Icon-Spotlight-iOS7.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF47331919997E003E8B91 /* Icon-Spotlight-iOS7.png */; }; 68 | D3EF47361919997E003E8B91 /* Icon-Spotlight-iOS7@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF47351919997E003E8B91 /* Icon-Spotlight-iOS7@2x.png */; }; 69 | D3EF494A19199980003E8B91 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EF494919199980003E8B91 /* main.m */; }; 70 | D3EF494E19199980003E8B91 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EF494D19199980003E8B91 /* AppDelegate.m */; }; 71 | D3EF495F19199B09003E8B91 /* E01_SimplestShader.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EF495E19199B09003E8B91 /* E01_SimplestShader.m */; }; 72 | D3EF497019199DBF003E8B91 /* libcocos2d.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3EF496D19199D82003E8B91 /* libcocos2d.a */; }; 73 | D3EF49761919A222003E8B91 /* Logo-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49741919A222003E8B91 /* Logo-hd.png */; }; 74 | D3EF49771919A222003E8B91 /* Logo-ipadhd.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49751919A222003E8B91 /* Logo-ipadhd.png */; }; 75 | D3EF49791919A343003E8B91 /* E01_SimplestShader.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49781919A343003E8B91 /* E01_SimplestShader.fsh */; }; 76 | D3EF497F1919ABCB003E8B91 /* E02_SpriteColor.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D3EF497D1919ABCB003E8B91 /* E02_SpriteColor.fsh */; }; 77 | D3EF49801919ABCB003E8B91 /* E02_SpriteColor.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EF497E1919ABCB003E8B91 /* E02_SpriteColor.m */; }; 78 | D3EF49891919AE7D003E8B91 /* Interface-hd.plist in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49811919AE7D003E8B91 /* Interface-hd.plist */; }; 79 | D3EF498A1919AE7D003E8B91 /* Interface-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49821919AE7D003E8B91 /* Interface-hd.png */; }; 80 | D3EF498B1919AE7D003E8B91 /* Interface-ipadhd.plist in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49831919AE7D003E8B91 /* Interface-ipadhd.plist */; }; 81 | D3EF498C1919AE7D003E8B91 /* Interface-ipadhd.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49841919AE7D003E8B91 /* Interface-ipadhd.png */; }; 82 | D3EF498D1919AE7D003E8B91 /* slider-background-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49851919AE7D003E8B91 /* slider-background-hd.png */; }; 83 | D3EF498E1919AE7D003E8B91 /* slider-background-ipadhd.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49861919AE7D003E8B91 /* slider-background-ipadhd.png */; }; 84 | D3EF498F1919AE7D003E8B91 /* slider-handle-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49871919AE7D003E8B91 /* slider-handle-hd.png */; }; 85 | D3EF49901919AE7D003E8B91 /* slider-handle-ipadhd.png in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49881919AE7D003E8B91 /* slider-handle-ipadhd.png */; }; 86 | D3EF49931919BE55003E8B91 /* E03_SpriteDistort.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D3EF49911919BE55003E8B91 /* E03_SpriteDistort.fsh */; }; 87 | D3EF49941919BE55003E8B91 /* E03_SpriteDistort.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EF49921919BE55003E8B91 /* E03_SpriteDistort.m */; }; 88 | D3EF49971919C543003E8B91 /* ExampleBase.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EF49961919C543003E8B91 /* ExampleBase.m */; }; 89 | D3EFD6F71919DA1700EA8874 /* E04_Grayscale.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D3EFD6F51919DA1700EA8874 /* E04_Grayscale.fsh */; }; 90 | D3EFD6F81919DA1700EA8874 /* E04_Grayscale.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EFD6F61919DA1700EA8874 /* E04_Grayscale.m */; }; 91 | D3EFD7001919DFA100EA8874 /* E05_Chromatic.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EFD6FF1919DFA100EA8874 /* E05_Chromatic.m */; }; 92 | D3EFD7031919DFA600EA8874 /* E05_Chromatic.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D3EFD7021919DFA600EA8874 /* E05_Chromatic.fsh */; }; 93 | D3EFD7061919E51800EA8874 /* E06_Shadow.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D3EFD7041919E51800EA8874 /* E06_Shadow.fsh */; }; 94 | D3EFD7071919E51800EA8874 /* E06_Shadow.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EFD7051919E51800EA8874 /* E06_Shadow.m */; }; 95 | D3EFD70A1919F89C00EA8874 /* E07_ColorFlash.fsh in Resources */ = {isa = PBXBuildFile; fileRef = D3EFD7081919F89C00EA8874 /* E07_ColorFlash.fsh */; }; 96 | D3EFD70B1919F89C00EA8874 /* E07_ColorFlash.m in Sources */ = {isa = PBXBuildFile; fileRef = D3EFD7091919F89C00EA8874 /* E07_ColorFlash.m */; }; 97 | /* End PBXBuildFile section */ 98 | 99 | /* Begin PBXContainerItemProxy section */ 100 | D3EF496C19199D82003E8B91 /* PBXContainerItemProxy */ = { 101 | isa = PBXContainerItemProxy; 102 | containerPortal = D3EF496619199D82003E8B91 /* cocos2d-ios.xcodeproj */; 103 | proxyType = 2; 104 | remoteGlobalIDString = 5018F24D0DFDEAC400C013A5; 105 | remoteInfo = cocos2d; 106 | }; 107 | D3EF496E19199DBA003E8B91 /* PBXContainerItemProxy */ = { 108 | isa = PBXContainerItemProxy; 109 | containerPortal = D3EF496619199D82003E8B91 /* cocos2d-ios.xcodeproj */; 110 | proxyType = 1; 111 | remoteGlobalIDString = 5018F24C0DFDEAC400C013A5; 112 | remoteInfo = cocos2d; 113 | }; 114 | /* End PBXContainerItemProxy section */ 115 | 116 | /* Begin PBXFileReference section */ 117 | 753B79F8191A89800034A6D5 /* TODO.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = TODO.txt; sourceTree = ""; }; 118 | 753B79FA191A8D970034A6D5 /* E11_Diffusion.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E11_Diffusion.fsh; sourceTree = ""; }; 119 | 753B79FB191A8D970034A6D5 /* E11_Diffusion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E11_Diffusion.m; sourceTree = ""; }; 120 | 753B7A02191A92840034A6D5 /* E11_Diffusion.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E11_Diffusion.vsh; sourceTree = ""; }; 121 | 753B7A04191AC2DD0034A6D5 /* E12_ColorMatrix.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E12_ColorMatrix.m; sourceTree = ""; }; 122 | 753B7A05191AC2DD0034A6D5 /* E12_ColorMatrix.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E12_ColorMatrix.fsh; sourceTree = ""; }; 123 | 753B7A08191AD9710034A6D5 /* E13_MotionBlur.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E13_MotionBlur.fsh; sourceTree = ""; }; 124 | 753B7A09191AD9710034A6D5 /* E13_MotionBlur.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E13_MotionBlur.m; sourceTree = ""; }; 125 | D32754F2191A94EC00865098 /* E08_Outline.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E08_Outline.fsh; sourceTree = ""; }; 126 | D32754F3191A94EC00865098 /* E08_Outline.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E08_Outline.m; sourceTree = ""; }; 127 | D32754F7191A973D00865098 /* E08_Outline.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E08_Outline.vsh; sourceTree = ""; }; 128 | D3275505191AE26A00865098 /* E09_Static.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E09_Static.fsh; sourceTree = ""; }; 129 | D3275506191AE26A00865098 /* E09_Static.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E09_Static.m; sourceTree = ""; }; 130 | D327550A191AE5E600865098 /* E09_Static.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E09_Static.vsh; sourceTree = ""; }; 131 | D327550C191AEB2400865098 /* gaussianNoise.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = gaussianNoise.png; path = Resources/gaussianNoise.png; sourceTree = ""; }; 132 | D33E2B28191D866000FEB214 /* E14_Flag.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E14_Flag.fsh; sourceTree = ""; }; 133 | D33E2B29191D866000FEB214 /* E14_Flag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E14_Flag.m; sourceTree = ""; }; 134 | D33E2B2D191D86EC00FEB214 /* Flag-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Flag-hd.png"; path = "Resources/Flag-hd.png"; sourceTree = ""; }; 135 | D33E2B2E191D86EC00FEB214 /* Flag-ipadhd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Flag-ipadhd.png"; path = "Resources/Flag-ipadhd.png"; sourceTree = ""; }; 136 | D38827A2191D60FA006C1A75 /* BisectionNoise.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = BisectionNoise.png; path = Resources/BisectionNoise.png; sourceTree = ""; }; 137 | D38827A3191D60FA006C1A75 /* Caustic.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Caustic.png; path = Resources/Caustic.png; sourceTree = ""; }; 138 | D38827A4191D60FA006C1A75 /* Rocks-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Rocks-hd.png"; path = "Resources/Rocks-hd.png"; sourceTree = ""; }; 139 | D38827A5191D60FA006C1A75 /* Rocks-ipadhd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Rocks-ipadhd.png"; path = "Resources/Rocks-ipadhd.png"; sourceTree = ""; }; 140 | D38827AE191D617F006C1A75 /* E10_Water.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E10_Water.fsh; sourceTree = ""; }; 141 | D38827AF191D617F006C1A75 /* E10_Water.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E10_Water.m; sourceTree = ""; }; 142 | D38827B0191D617F006C1A75 /* E10_Water.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E10_Water.vsh; sourceTree = ""; }; 143 | D3A6CD421922A39A000E4134 /* E15_SignedDistanceField.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E15_SignedDistanceField.fsh; sourceTree = ""; }; 144 | D3A6CD431922A39A000E4134 /* E15_SignedDistanceField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E15_SignedDistanceField.m; sourceTree = ""; }; 145 | D3A6CD4B1922FFCA000E4134 /* DistanceField.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = DistanceField.png; path = Resources/DistanceField.png; sourceTree = ""; }; 146 | D3BC84DA1940BAF100E98AD2 /* Fog.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Fog.plist; path = Resources/Fog.plist; sourceTree = ""; }; 147 | D3BC84DD1940BAFF00E98AD2 /* E16_MetaParticles.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E16_MetaParticles.fsh; sourceTree = ""; }; 148 | D3BC84DE1940BAFF00E98AD2 /* E16_MetaParticles.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E16_MetaParticles.m; sourceTree = ""; }; 149 | D3C04F7F1925E52E00632AAE /* E01_SimplestShader.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = E01_SimplestShader.webarchive; sourceTree = ""; }; 150 | D3C04F811925E72500632AAE /* E02_SpriteColor.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = E02_SpriteColor.webarchive; sourceTree = ""; }; 151 | D3C04F821925E73900632AAE /* E03_SpriteDistort.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = E03_SpriteDistort.webarchive; sourceTree = ""; }; 152 | D3C04F841925E74200632AAE /* E04_Grayscale.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = E04_Grayscale.webarchive; sourceTree = ""; }; 153 | D3C04F861925E74800632AAE /* E05_Chromatic.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = E05_Chromatic.webarchive; sourceTree = ""; }; 154 | D3C04F881925E74C00632AAE /* E06_Shadow.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = E06_Shadow.webarchive; sourceTree = ""; }; 155 | D3C04F8A1925E75100632AAE /* E07_Color Flash.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = "E07_Color Flash.webarchive"; sourceTree = ""; }; 156 | D3C04F8C1925E75600632AAE /* E08_Outline.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = E08_Outline.webarchive; sourceTree = ""; }; 157 | D3C04F8E1925E75A00632AAE /* E09_Static.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = E09_Static.webarchive; sourceTree = ""; }; 158 | D3C04F901925E75E00632AAE /* E10_Water.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = E10_Water.webarchive; sourceTree = ""; }; 159 | D3C04F921925E76500632AAE /* E11_Diffusion.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = E11_Diffusion.webarchive; sourceTree = ""; }; 160 | D3C04F941925E76900632AAE /* E12_ColorMatrix.webarchive */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; path = E12_ColorMatrix.webarchive; sourceTree = ""; }; 161 | D3EF46F51919997E003E8B91 /* Cocos2DShaderCookbook.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Cocos2DShaderCookbook.app; sourceTree = BUILT_PRODUCTS_DIR; }; 162 | D3EF46F81919997E003E8B91 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 163 | D3EF46FA1919997E003E8B91 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 164 | D3EF46FC1919997E003E8B91 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; 165 | D3EF46FE1919997E003E8B91 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 166 | D3EF47001919997E003E8B91 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 167 | D3EF47021919997E003E8B91 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 168 | D3EF47041919997E003E8B91 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 169 | D3EF47061919997E003E8B91 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 170 | D3EF47081919997E003E8B91 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; 171 | D3EF470A1919997E003E8B91 /* GLKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLKit.framework; path = System/Library/Frameworks/GLKit.framework; sourceTree = SDKROOT; }; 172 | D3EF47141919997E003E8B91 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = Resources/Default.png; sourceTree = ""; }; 173 | D3EF47161919997E003E8B91 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "Resources/Default@2x.png"; sourceTree = ""; }; 174 | D3EF47181919997E003E8B91 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "Resources/Default-568h@2x.png"; sourceTree = ""; }; 175 | D3EF471A1919997E003E8B91 /* Default-Landscape~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Landscape~ipad.png"; path = "Resources/Default-Landscape~ipad.png"; sourceTree = ""; }; 176 | D3EF471D1919997E003E8B91 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon.png; path = Resources/Icons/Icon.png; sourceTree = ""; }; 177 | D3EF471F1919997E003E8B91 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon@2x.png"; path = "Resources/Icons/Icon@2x.png"; sourceTree = ""; }; 178 | D3EF47211919997E003E8B91 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "Resources/Icons/Icon-72.png"; sourceTree = ""; }; 179 | D3EF47231919997E003E8B91 /* Icon-72@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72@2x.png"; path = "Resources/Icons/Icon-72@2x.png"; sourceTree = ""; }; 180 | D3EF47251919997E003E8B91 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-76.png"; path = "Resources/Icons/Icon-76.png"; sourceTree = ""; }; 181 | D3EF47271919997E003E8B91 /* Icon-76@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-76@2x.png"; path = "Resources/Icons/Icon-76@2x.png"; sourceTree = ""; }; 182 | D3EF47291919997E003E8B91 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-120.png"; path = "Resources/Icons/Icon-120.png"; sourceTree = ""; }; 183 | D3EF472B1919997E003E8B91 /* Icon-iPad-Spotlight-iOS7@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-iPad-Spotlight-iOS7@2x.png"; path = "Resources/Icons/Icon-iPad-Spotlight-iOS7@2x.png"; sourceTree = ""; }; 184 | D3EF472D1919997E003E8B91 /* Icon-Small-50.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-Small-50.png"; path = "Resources/Icons/Icon-Small-50.png"; sourceTree = ""; }; 185 | D3EF472F1919997E003E8B91 /* Icon-Small.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-Small.png"; path = "Resources/Icons/Icon-Small.png"; sourceTree = ""; }; 186 | D3EF47311919997E003E8B91 /* Icon-Small@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-Small@2x.png"; path = "Resources/Icons/Icon-Small@2x.png"; sourceTree = ""; }; 187 | D3EF47331919997E003E8B91 /* Icon-Spotlight-iOS7.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-Spotlight-iOS7.png"; path = "Resources/Icons/Icon-Spotlight-iOS7.png"; sourceTree = ""; }; 188 | D3EF47351919997E003E8B91 /* Icon-Spotlight-iOS7@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-Spotlight-iOS7@2x.png"; path = "Resources/Icons/Icon-Spotlight-iOS7@2x.png"; sourceTree = ""; }; 189 | D3EF47371919997E003E8B91 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Resources/Info.plist; sourceTree = ""; }; 190 | D3EF494819199980003E8B91 /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Prefix.pch; path = "Supporting Files/Prefix.pch"; sourceTree = ""; }; 191 | D3EF494919199980003E8B91 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = main.m; path = "Supporting Files/main.m"; sourceTree = ""; }; 192 | D3EF494C19199980003E8B91 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = Classes/AppDelegate.h; sourceTree = ""; }; 193 | D3EF494D19199980003E8B91 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = Classes/AppDelegate.m; sourceTree = ""; }; 194 | D3EF495E19199B09003E8B91 /* E01_SimplestShader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E01_SimplestShader.m; sourceTree = ""; }; 195 | D3EF496619199D82003E8B91 /* cocos2d-ios.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "cocos2d-ios.xcodeproj"; path = "Cocos2D/cocos2d-ios.xcodeproj"; sourceTree = ""; }; 196 | D3EF49741919A222003E8B91 /* Logo-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Logo-hd.png"; path = "Resources/Logo-hd.png"; sourceTree = ""; }; 197 | D3EF49751919A222003E8B91 /* Logo-ipadhd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Logo-ipadhd.png"; path = "Resources/Logo-ipadhd.png"; sourceTree = ""; }; 198 | D3EF49781919A343003E8B91 /* E01_SimplestShader.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E01_SimplestShader.fsh; sourceTree = ""; }; 199 | D3EF497D1919ABCB003E8B91 /* E02_SpriteColor.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E02_SpriteColor.fsh; sourceTree = ""; }; 200 | D3EF497E1919ABCB003E8B91 /* E02_SpriteColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E02_SpriteColor.m; sourceTree = ""; }; 201 | D3EF49811919AE7D003E8B91 /* Interface-hd.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Interface-hd.plist"; path = "Resources/Interface-hd.plist"; sourceTree = ""; }; 202 | D3EF49821919AE7D003E8B91 /* Interface-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Interface-hd.png"; path = "Resources/Interface-hd.png"; sourceTree = ""; }; 203 | D3EF49831919AE7D003E8B91 /* Interface-ipadhd.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Interface-ipadhd.plist"; path = "Resources/Interface-ipadhd.plist"; sourceTree = ""; }; 204 | D3EF49841919AE7D003E8B91 /* Interface-ipadhd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Interface-ipadhd.png"; path = "Resources/Interface-ipadhd.png"; sourceTree = ""; }; 205 | D3EF49851919AE7D003E8B91 /* slider-background-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "slider-background-hd.png"; path = "Resources/slider-background-hd.png"; sourceTree = ""; }; 206 | D3EF49861919AE7D003E8B91 /* slider-background-ipadhd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "slider-background-ipadhd.png"; path = "Resources/slider-background-ipadhd.png"; sourceTree = ""; }; 207 | D3EF49871919AE7D003E8B91 /* slider-handle-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "slider-handle-hd.png"; path = "Resources/slider-handle-hd.png"; sourceTree = ""; }; 208 | D3EF49881919AE7D003E8B91 /* slider-handle-ipadhd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "slider-handle-ipadhd.png"; path = "Resources/slider-handle-ipadhd.png"; sourceTree = ""; }; 209 | D3EF49911919BE55003E8B91 /* E03_SpriteDistort.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E03_SpriteDistort.fsh; sourceTree = ""; }; 210 | D3EF49921919BE55003E8B91 /* E03_SpriteDistort.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E03_SpriteDistort.m; sourceTree = ""; }; 211 | D3EF49951919C543003E8B91 /* ExampleBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExampleBase.h; path = Classes/ExampleBase.h; sourceTree = ""; }; 212 | D3EF49961919C543003E8B91 /* ExampleBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ExampleBase.m; path = Classes/ExampleBase.m; sourceTree = ""; }; 213 | D3EFD6F51919DA1700EA8874 /* E04_Grayscale.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E04_Grayscale.fsh; sourceTree = ""; }; 214 | D3EFD6F61919DA1700EA8874 /* E04_Grayscale.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E04_Grayscale.m; sourceTree = ""; }; 215 | D3EFD6FF1919DFA100EA8874 /* E05_Chromatic.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E05_Chromatic.m; sourceTree = ""; }; 216 | D3EFD7021919DFA600EA8874 /* E05_Chromatic.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E05_Chromatic.fsh; sourceTree = ""; }; 217 | D3EFD7041919E51800EA8874 /* E06_Shadow.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E06_Shadow.fsh; sourceTree = ""; }; 218 | D3EFD7051919E51800EA8874 /* E06_Shadow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E06_Shadow.m; sourceTree = ""; }; 219 | D3EFD7081919F89C00EA8874 /* E07_ColorFlash.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; path = E07_ColorFlash.fsh; sourceTree = ""; }; 220 | D3EFD7091919F89C00EA8874 /* E07_ColorFlash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = E07_ColorFlash.m; sourceTree = ""; }; 221 | /* End PBXFileReference section */ 222 | 223 | /* Begin PBXFrameworksBuildPhase section */ 224 | D3EF46F21919997E003E8B91 /* Frameworks */ = { 225 | isa = PBXFrameworksBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | D3EF497019199DBF003E8B91 /* libcocos2d.a in Frameworks */, 229 | D3EF46FD1919997E003E8B91 /* OpenAL.framework in Frameworks */, 230 | D3EF47031919997E003E8B91 /* UIKit.framework in Frameworks */, 231 | D3EF46F91919997E003E8B91 /* QuartzCore.framework in Frameworks */, 232 | D3EF47011919997E003E8B91 /* AVFoundation.framework in Frameworks */, 233 | D3EF47071919997E003E8B91 /* CoreGraphics.framework in Frameworks */, 234 | D3EF47091919997E003E8B91 /* CoreText.framework in Frameworks */, 235 | D3EF46FB1919997E003E8B91 /* OpenGLES.framework in Frameworks */, 236 | D3EF47051919997E003E8B91 /* Foundation.framework in Frameworks */, 237 | D3EF470B1919997E003E8B91 /* GLKit.framework in Frameworks */, 238 | D3EF46FF1919997E003E8B91 /* AudioToolbox.framework in Frameworks */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | /* End PBXFrameworksBuildPhase section */ 243 | 244 | /* Begin PBXGroup section */ 245 | D3BC84E11940BB0800E98AD2 /* E16_MetaParticles */ = { 246 | isa = PBXGroup; 247 | children = ( 248 | D3BC84DE1940BAFF00E98AD2 /* E16_MetaParticles.m */, 249 | D3BC84DD1940BAFF00E98AD2 /* E16_MetaParticles.fsh */, 250 | ); 251 | name = E16_MetaParticles; 252 | sourceTree = ""; 253 | }; 254 | D3C04F6E1925E38C00632AAE /* E01_SimplestShader */ = { 255 | isa = PBXGroup; 256 | children = ( 257 | D3C04F7F1925E52E00632AAE /* E01_SimplestShader.webarchive */, 258 | D3EF495E19199B09003E8B91 /* E01_SimplestShader.m */, 259 | D3EF49781919A343003E8B91 /* E01_SimplestShader.fsh */, 260 | ); 261 | name = E01_SimplestShader; 262 | sourceTree = ""; 263 | }; 264 | D3C04F6F1925E39E00632AAE /* E02_SpriteColor */ = { 265 | isa = PBXGroup; 266 | children = ( 267 | D3C04F811925E72500632AAE /* E02_SpriteColor.webarchive */, 268 | D3EF497E1919ABCB003E8B91 /* E02_SpriteColor.m */, 269 | D3EF497D1919ABCB003E8B91 /* E02_SpriteColor.fsh */, 270 | ); 271 | name = E02_SpriteColor; 272 | sourceTree = ""; 273 | }; 274 | D3C04F701925E3AD00632AAE /* E03_SpriteDistort */ = { 275 | isa = PBXGroup; 276 | children = ( 277 | D3C04F821925E73900632AAE /* E03_SpriteDistort.webarchive */, 278 | D3EF49921919BE55003E8B91 /* E03_SpriteDistort.m */, 279 | D3EF49911919BE55003E8B91 /* E03_SpriteDistort.fsh */, 280 | ); 281 | name = E03_SpriteDistort; 282 | sourceTree = ""; 283 | }; 284 | D3C04F711925E3BB00632AAE /* E04_Grayscale */ = { 285 | isa = PBXGroup; 286 | children = ( 287 | D3C04F841925E74200632AAE /* E04_Grayscale.webarchive */, 288 | D3EFD6F61919DA1700EA8874 /* E04_Grayscale.m */, 289 | D3EFD6F51919DA1700EA8874 /* E04_Grayscale.fsh */, 290 | ); 291 | name = E04_Grayscale; 292 | sourceTree = ""; 293 | }; 294 | D3C04F721925E3C400632AAE /* E05_Chromatic */ = { 295 | isa = PBXGroup; 296 | children = ( 297 | D3C04F861925E74800632AAE /* E05_Chromatic.webarchive */, 298 | D3EFD6FF1919DFA100EA8874 /* E05_Chromatic.m */, 299 | D3EFD7021919DFA600EA8874 /* E05_Chromatic.fsh */, 300 | ); 301 | name = E05_Chromatic; 302 | sourceTree = ""; 303 | }; 304 | D3C04F731925E3D300632AAE /* E06_Shadow */ = { 305 | isa = PBXGroup; 306 | children = ( 307 | D3C04F881925E74C00632AAE /* E06_Shadow.webarchive */, 308 | D3EFD7051919E51800EA8874 /* E06_Shadow.m */, 309 | D3EFD7041919E51800EA8874 /* E06_Shadow.fsh */, 310 | ); 311 | name = E06_Shadow; 312 | sourceTree = ""; 313 | }; 314 | D3C04F741925E3DB00632AAE /* E07_ColorFlash */ = { 315 | isa = PBXGroup; 316 | children = ( 317 | D3C04F8A1925E75100632AAE /* E07_Color Flash.webarchive */, 318 | D3EFD7091919F89C00EA8874 /* E07_ColorFlash.m */, 319 | D3EFD7081919F89C00EA8874 /* E07_ColorFlash.fsh */, 320 | ); 321 | name = E07_ColorFlash; 322 | sourceTree = ""; 323 | }; 324 | D3C04F751925E3E400632AAE /* E08_Outline */ = { 325 | isa = PBXGroup; 326 | children = ( 327 | D3C04F8C1925E75600632AAE /* E08_Outline.webarchive */, 328 | D32754F3191A94EC00865098 /* E08_Outline.m */, 329 | D32754F7191A973D00865098 /* E08_Outline.vsh */, 330 | D32754F2191A94EC00865098 /* E08_Outline.fsh */, 331 | ); 332 | name = E08_Outline; 333 | sourceTree = ""; 334 | }; 335 | D3C04F761925E3F100632AAE /* E09_Static */ = { 336 | isa = PBXGroup; 337 | children = ( 338 | D3C04F8E1925E75A00632AAE /* E09_Static.webarchive */, 339 | D3275506191AE26A00865098 /* E09_Static.m */, 340 | D327550A191AE5E600865098 /* E09_Static.vsh */, 341 | D3275505191AE26A00865098 /* E09_Static.fsh */, 342 | ); 343 | name = E09_Static; 344 | sourceTree = ""; 345 | }; 346 | D3C04F771925E40D00632AAE /* E10_Water */ = { 347 | isa = PBXGroup; 348 | children = ( 349 | D3C04F901925E75E00632AAE /* E10_Water.webarchive */, 350 | D38827AF191D617F006C1A75 /* E10_Water.m */, 351 | D38827B0191D617F006C1A75 /* E10_Water.vsh */, 352 | D38827AE191D617F006C1A75 /* E10_Water.fsh */, 353 | ); 354 | name = E10_Water; 355 | sourceTree = ""; 356 | }; 357 | D3C04F781925E43100632AAE /* E11_Diffusion */ = { 358 | isa = PBXGroup; 359 | children = ( 360 | D3C04F921925E76500632AAE /* E11_Diffusion.webarchive */, 361 | 753B79FB191A8D970034A6D5 /* E11_Diffusion.m */, 362 | 753B7A02191A92840034A6D5 /* E11_Diffusion.vsh */, 363 | 753B79FA191A8D970034A6D5 /* E11_Diffusion.fsh */, 364 | ); 365 | name = E11_Diffusion; 366 | sourceTree = ""; 367 | }; 368 | D3C04F791925E43E00632AAE /* E12_ColorMatrix */ = { 369 | isa = PBXGroup; 370 | children = ( 371 | D3C04F941925E76900632AAE /* E12_ColorMatrix.webarchive */, 372 | 753B7A04191AC2DD0034A6D5 /* E12_ColorMatrix.m */, 373 | 753B7A05191AC2DD0034A6D5 /* E12_ColorMatrix.fsh */, 374 | ); 375 | name = E12_ColorMatrix; 376 | sourceTree = ""; 377 | }; 378 | D3C04F7A1925E44700632AAE /* E13_MotionBlur */ = { 379 | isa = PBXGroup; 380 | children = ( 381 | 753B7A09191AD9710034A6D5 /* E13_MotionBlur.m */, 382 | 753B7A08191AD9710034A6D5 /* E13_MotionBlur.fsh */, 383 | ); 384 | name = E13_MotionBlur; 385 | sourceTree = ""; 386 | }; 387 | D3C04F7B1925E45300632AAE /* E14_Flag */ = { 388 | isa = PBXGroup; 389 | children = ( 390 | D33E2B29191D866000FEB214 /* E14_Flag.m */, 391 | D33E2B28191D866000FEB214 /* E14_Flag.fsh */, 392 | ); 393 | name = E14_Flag; 394 | sourceTree = ""; 395 | }; 396 | D3C04F7C1925E45D00632AAE /* E15_SignedDistanceField */ = { 397 | isa = PBXGroup; 398 | children = ( 399 | D3A6CD431922A39A000E4134 /* E15_SignedDistanceField.m */, 400 | D3A6CD421922A39A000E4134 /* E15_SignedDistanceField.fsh */, 401 | ); 402 | name = E15_SignedDistanceField; 403 | sourceTree = ""; 404 | }; 405 | D3EF46EC1919997E003E8B91 = { 406 | isa = PBXGroup; 407 | children = ( 408 | 753B79F8191A89800034A6D5 /* TODO.txt */, 409 | D3EF47121919997E003E8B91 /* Cookbook */, 410 | D3EF46F71919997E003E8B91 /* Frameworks */, 411 | D3EF46F61919997E003E8B91 /* Products */, 412 | D3EF496619199D82003E8B91 /* cocos2d-ios.xcodeproj */, 413 | ); 414 | sourceTree = ""; 415 | }; 416 | D3EF46F61919997E003E8B91 /* Products */ = { 417 | isa = PBXGroup; 418 | children = ( 419 | D3EF46F51919997E003E8B91 /* Cocos2DShaderCookbook.app */, 420 | ); 421 | name = Products; 422 | sourceTree = ""; 423 | }; 424 | D3EF46F71919997E003E8B91 /* Frameworks */ = { 425 | isa = PBXGroup; 426 | children = ( 427 | D3EF46F81919997E003E8B91 /* QuartzCore.framework */, 428 | D3EF46FA1919997E003E8B91 /* OpenGLES.framework */, 429 | D3EF46FC1919997E003E8B91 /* OpenAL.framework */, 430 | D3EF46FE1919997E003E8B91 /* AudioToolbox.framework */, 431 | D3EF47001919997E003E8B91 /* AVFoundation.framework */, 432 | D3EF47021919997E003E8B91 /* UIKit.framework */, 433 | D3EF47041919997E003E8B91 /* Foundation.framework */, 434 | D3EF47061919997E003E8B91 /* CoreGraphics.framework */, 435 | D3EF47081919997E003E8B91 /* CoreText.framework */, 436 | D3EF470A1919997E003E8B91 /* GLKit.framework */, 437 | ); 438 | name = Frameworks; 439 | sourceTree = ""; 440 | }; 441 | D3EF47121919997E003E8B91 /* Cookbook */ = { 442 | isa = PBXGroup; 443 | children = ( 444 | D3EF494B19199980003E8B91 /* Classes */, 445 | D3EF497319199F8A003E8B91 /* Examples */, 446 | D3EF47131919997E003E8B91 /* Resources */, 447 | D3EF494719199980003E8B91 /* Supporting Files */, 448 | ); 449 | path = Cookbook; 450 | sourceTree = ""; 451 | }; 452 | D3EF47131919997E003E8B91 /* Resources */ = { 453 | isa = PBXGroup; 454 | children = ( 455 | D3BC84DA1940BAF100E98AD2 /* Fog.plist */, 456 | D3A6CD4B1922FFCA000E4134 /* DistanceField.png */, 457 | D38827A2191D60FA006C1A75 /* BisectionNoise.png */, 458 | D38827A3191D60FA006C1A75 /* Caustic.png */, 459 | D38827A4191D60FA006C1A75 /* Rocks-hd.png */, 460 | D38827A5191D60FA006C1A75 /* Rocks-ipadhd.png */, 461 | D327550C191AEB2400865098 /* gaussianNoise.png */, 462 | D3EF49811919AE7D003E8B91 /* Interface-hd.plist */, 463 | D3EF49821919AE7D003E8B91 /* Interface-hd.png */, 464 | D3EF49831919AE7D003E8B91 /* Interface-ipadhd.plist */, 465 | D3EF49841919AE7D003E8B91 /* Interface-ipadhd.png */, 466 | D3EF49851919AE7D003E8B91 /* slider-background-hd.png */, 467 | D3EF49861919AE7D003E8B91 /* slider-background-ipadhd.png */, 468 | D3EF49871919AE7D003E8B91 /* slider-handle-hd.png */, 469 | D3EF49881919AE7D003E8B91 /* slider-handle-ipadhd.png */, 470 | D3EF49741919A222003E8B91 /* Logo-hd.png */, 471 | D3EF49751919A222003E8B91 /* Logo-ipadhd.png */, 472 | D3EF47141919997E003E8B91 /* Default.png */, 473 | D3EF47161919997E003E8B91 /* Default@2x.png */, 474 | D3EF47181919997E003E8B91 /* Default-568h@2x.png */, 475 | D3EF471A1919997E003E8B91 /* Default-Landscape~ipad.png */, 476 | D33E2B2D191D86EC00FEB214 /* Flag-hd.png */, 477 | D33E2B2E191D86EC00FEB214 /* Flag-ipadhd.png */, 478 | D3EF47371919997E003E8B91 /* Info.plist */, 479 | D3EF471C1919997E003E8B91 /* Icons */, 480 | ); 481 | name = Resources; 482 | sourceTree = ""; 483 | }; 484 | D3EF471C1919997E003E8B91 /* Icons */ = { 485 | isa = PBXGroup; 486 | children = ( 487 | D3EF471D1919997E003E8B91 /* Icon.png */, 488 | D3EF471F1919997E003E8B91 /* Icon@2x.png */, 489 | D3EF47211919997E003E8B91 /* Icon-72.png */, 490 | D3EF47231919997E003E8B91 /* Icon-72@2x.png */, 491 | D3EF47251919997E003E8B91 /* Icon-76.png */, 492 | D3EF47271919997E003E8B91 /* Icon-76@2x.png */, 493 | D3EF47291919997E003E8B91 /* Icon-120.png */, 494 | D3EF472B1919997E003E8B91 /* Icon-iPad-Spotlight-iOS7@2x.png */, 495 | D3EF472D1919997E003E8B91 /* Icon-Small-50.png */, 496 | D3EF472F1919997E003E8B91 /* Icon-Small.png */, 497 | D3EF47311919997E003E8B91 /* Icon-Small@2x.png */, 498 | D3EF47331919997E003E8B91 /* Icon-Spotlight-iOS7.png */, 499 | D3EF47351919997E003E8B91 /* Icon-Spotlight-iOS7@2x.png */, 500 | ); 501 | name = Icons; 502 | sourceTree = ""; 503 | }; 504 | D3EF494719199980003E8B91 /* Supporting Files */ = { 505 | isa = PBXGroup; 506 | children = ( 507 | D3EF494819199980003E8B91 /* Prefix.pch */, 508 | D3EF494919199980003E8B91 /* main.m */, 509 | ); 510 | name = "Supporting Files"; 511 | sourceTree = ""; 512 | }; 513 | D3EF494B19199980003E8B91 /* Classes */ = { 514 | isa = PBXGroup; 515 | children = ( 516 | D3EF494C19199980003E8B91 /* AppDelegate.h */, 517 | D3EF494D19199980003E8B91 /* AppDelegate.m */, 518 | D3EF49951919C543003E8B91 /* ExampleBase.h */, 519 | D3EF49961919C543003E8B91 /* ExampleBase.m */, 520 | ); 521 | name = Classes; 522 | sourceTree = ""; 523 | }; 524 | D3EF496719199D82003E8B91 /* Products */ = { 525 | isa = PBXGroup; 526 | children = ( 527 | D3EF496D19199D82003E8B91 /* libcocos2d.a */, 528 | ); 529 | name = Products; 530 | sourceTree = ""; 531 | }; 532 | D3EF497319199F8A003E8B91 /* Examples */ = { 533 | isa = PBXGroup; 534 | children = ( 535 | D3C04F6E1925E38C00632AAE /* E01_SimplestShader */, 536 | D3C04F6F1925E39E00632AAE /* E02_SpriteColor */, 537 | D3C04F701925E3AD00632AAE /* E03_SpriteDistort */, 538 | D3C04F711925E3BB00632AAE /* E04_Grayscale */, 539 | D3C04F721925E3C400632AAE /* E05_Chromatic */, 540 | D3C04F731925E3D300632AAE /* E06_Shadow */, 541 | D3C04F741925E3DB00632AAE /* E07_ColorFlash */, 542 | D3C04F751925E3E400632AAE /* E08_Outline */, 543 | D3C04F761925E3F100632AAE /* E09_Static */, 544 | D3C04F771925E40D00632AAE /* E10_Water */, 545 | D3C04F781925E43100632AAE /* E11_Diffusion */, 546 | D3C04F791925E43E00632AAE /* E12_ColorMatrix */, 547 | D3C04F7A1925E44700632AAE /* E13_MotionBlur */, 548 | D3C04F7B1925E45300632AAE /* E14_Flag */, 549 | D3C04F7C1925E45D00632AAE /* E15_SignedDistanceField */, 550 | D3BC84E11940BB0800E98AD2 /* E16_MetaParticles */, 551 | ); 552 | path = Examples; 553 | sourceTree = ""; 554 | }; 555 | /* End PBXGroup section */ 556 | 557 | /* Begin PBXNativeTarget section */ 558 | D3EF46F41919997E003E8B91 /* Cocos2DShaderCookbook */ = { 559 | isa = PBXNativeTarget; 560 | buildConfigurationList = D3EF495A19199980003E8B91 /* Build configuration list for PBXNativeTarget "Cocos2DShaderCookbook" */; 561 | buildPhases = ( 562 | D3EF46F11919997E003E8B91 /* Sources */, 563 | D3EF46F21919997E003E8B91 /* Frameworks */, 564 | D3EF46F31919997E003E8B91 /* Resources */, 565 | ); 566 | buildRules = ( 567 | ); 568 | dependencies = ( 569 | D3EF496F19199DBA003E8B91 /* PBXTargetDependency */, 570 | ); 571 | name = Cocos2DShaderCookbook; 572 | productName = Shaders4Cocos2D; 573 | productReference = D3EF46F51919997E003E8B91 /* Cocos2DShaderCookbook.app */; 574 | productType = "com.apple.product-type.application"; 575 | }; 576 | /* End PBXNativeTarget section */ 577 | 578 | /* Begin PBXProject section */ 579 | D3EF46ED1919997E003E8B91 /* Project object */ = { 580 | isa = PBXProject; 581 | attributes = { 582 | LastUpgradeCheck = 0510; 583 | ORGANIZATIONNAME = "Cocos2D-iPhone"; 584 | }; 585 | buildConfigurationList = D3EF46F01919997E003E8B91 /* Build configuration list for PBXProject "Cocos2DShaderCookbook" */; 586 | compatibilityVersion = "Xcode 3.2"; 587 | developmentRegion = English; 588 | hasScannedForEncodings = 0; 589 | knownRegions = ( 590 | en, 591 | ); 592 | mainGroup = D3EF46EC1919997E003E8B91; 593 | productRefGroup = D3EF46F61919997E003E8B91 /* Products */; 594 | projectDirPath = ""; 595 | projectReferences = ( 596 | { 597 | ProductGroup = D3EF496719199D82003E8B91 /* Products */; 598 | ProjectRef = D3EF496619199D82003E8B91 /* cocos2d-ios.xcodeproj */; 599 | }, 600 | ); 601 | projectRoot = ""; 602 | targets = ( 603 | D3EF46F41919997E003E8B91 /* Cocos2DShaderCookbook */, 604 | ); 605 | }; 606 | /* End PBXProject section */ 607 | 608 | /* Begin PBXReferenceProxy section */ 609 | D3EF496D19199D82003E8B91 /* libcocos2d.a */ = { 610 | isa = PBXReferenceProxy; 611 | fileType = archive.ar; 612 | path = libcocos2d.a; 613 | remoteRef = D3EF496C19199D82003E8B91 /* PBXContainerItemProxy */; 614 | sourceTree = BUILT_PRODUCTS_DIR; 615 | }; 616 | /* End PBXReferenceProxy section */ 617 | 618 | /* Begin PBXResourcesBuildPhase section */ 619 | D3EF46F31919997E003E8B91 /* Resources */ = { 620 | isa = PBXResourcesBuildPhase; 621 | buildActionMask = 2147483647; 622 | files = ( 623 | D3EF47171919997E003E8B91 /* Default@2x.png in Resources */, 624 | 753B7A07191AC2DD0034A6D5 /* E12_ColorMatrix.fsh in Resources */, 625 | D3EF472A1919997E003E8B91 /* Icon-120.png in Resources */, 626 | D3BC84DF1940BAFF00E98AD2 /* E16_MetaParticles.fsh in Resources */, 627 | D3EF49901919AE7D003E8B91 /* slider-handle-ipadhd.png in Resources */, 628 | D3EFD7031919DFA600EA8874 /* E05_Chromatic.fsh in Resources */, 629 | D3EF49891919AE7D003E8B91 /* Interface-hd.plist in Resources */, 630 | D38827B3191D617F006C1A75 /* E10_Water.vsh in Resources */, 631 | D3EF47201919997E003E8B91 /* Icon@2x.png in Resources */, 632 | D3EF498E1919AE7D003E8B91 /* slider-background-ipadhd.png in Resources */, 633 | D3EF47321919997E003E8B91 /* Icon-Small@2x.png in Resources */, 634 | D3EF47241919997E003E8B91 /* Icon-72@2x.png in Resources */, 635 | D38827A6191D60FA006C1A75 /* BisectionNoise.png in Resources */, 636 | 753B79FC191A8D970034A6D5 /* E11_Diffusion.fsh in Resources */, 637 | D38827A9191D60FA006C1A75 /* Rocks-ipadhd.png in Resources */, 638 | D38827B1191D617F006C1A75 /* E10_Water.fsh in Resources */, 639 | D3EF47151919997E003E8B91 /* Default.png in Resources */, 640 | D3EF498C1919AE7D003E8B91 /* Interface-ipadhd.png in Resources */, 641 | D3EF471E1919997E003E8B91 /* Icon.png in Resources */, 642 | D3EF49931919BE55003E8B91 /* E03_SpriteDistort.fsh in Resources */, 643 | D32754F4191A94EC00865098 /* E08_Outline.fsh in Resources */, 644 | D3275507191AE26A00865098 /* E09_Static.fsh in Resources */, 645 | D3EF472C1919997E003E8B91 /* Icon-iPad-Spotlight-iOS7@2x.png in Resources */, 646 | D3EF49791919A343003E8B91 /* E01_SimplestShader.fsh in Resources */, 647 | D3BC84DB1940BAF100E98AD2 /* Fog.plist in Resources */, 648 | D38827A8191D60FA006C1A75 /* Rocks-hd.png in Resources */, 649 | D3EF471B1919997E003E8B91 /* Default-Landscape~ipad.png in Resources */, 650 | D3EF47301919997E003E8B91 /* Icon-Small.png in Resources */, 651 | D33E2B30191D86EC00FEB214 /* Flag-ipadhd.png in Resources */, 652 | D3EF497F1919ABCB003E8B91 /* E02_SpriteColor.fsh in Resources */, 653 | D3EFD6F71919DA1700EA8874 /* E04_Grayscale.fsh in Resources */, 654 | D3EF472E1919997E003E8B91 /* Icon-Small-50.png in Resources */, 655 | D3A6CD4C1922FFCA000E4134 /* DistanceField.png in Resources */, 656 | D33E2B2F191D86EC00FEB214 /* Flag-hd.png in Resources */, 657 | D3EF498B1919AE7D003E8B91 /* Interface-ipadhd.plist in Resources */, 658 | D32754F8191A973D00865098 /* E08_Outline.vsh in Resources */, 659 | D327550D191AEB2400865098 /* gaussianNoise.png in Resources */, 660 | D327550B191AE5E600865098 /* E09_Static.vsh in Resources */, 661 | D3EF47221919997E003E8B91 /* Icon-72.png in Resources */, 662 | D3EF47191919997E003E8B91 /* Default-568h@2x.png in Resources */, 663 | D3A6CD441922A39A000E4134 /* E15_SignedDistanceField.fsh in Resources */, 664 | D3EF49771919A222003E8B91 /* Logo-ipadhd.png in Resources */, 665 | D3EF47341919997E003E8B91 /* Icon-Spotlight-iOS7.png in Resources */, 666 | 753B7A03191A92840034A6D5 /* E11_Diffusion.vsh in Resources */, 667 | 753B79F9191A89800034A6D5 /* TODO.txt in Resources */, 668 | D3EF498F1919AE7D003E8B91 /* slider-handle-hd.png in Resources */, 669 | D3EF47281919997E003E8B91 /* Icon-76@2x.png in Resources */, 670 | D3EFD7061919E51800EA8874 /* E06_Shadow.fsh in Resources */, 671 | D3EF49761919A222003E8B91 /* Logo-hd.png in Resources */, 672 | D33E2B2A191D866000FEB214 /* E14_Flag.fsh in Resources */, 673 | D3EFD70A1919F89C00EA8874 /* E07_ColorFlash.fsh in Resources */, 674 | D38827A7191D60FA006C1A75 /* Caustic.png in Resources */, 675 | D3EF498A1919AE7D003E8B91 /* Interface-hd.png in Resources */, 676 | 753B7A0A191AD9710034A6D5 /* E13_MotionBlur.fsh in Resources */, 677 | D3EF498D1919AE7D003E8B91 /* slider-background-hd.png in Resources */, 678 | D3EF47361919997E003E8B91 /* Icon-Spotlight-iOS7@2x.png in Resources */, 679 | D3EF47261919997E003E8B91 /* Icon-76.png in Resources */, 680 | ); 681 | runOnlyForDeploymentPostprocessing = 0; 682 | }; 683 | /* End PBXResourcesBuildPhase section */ 684 | 685 | /* Begin PBXSourcesBuildPhase section */ 686 | D3EF46F11919997E003E8B91 /* Sources */ = { 687 | isa = PBXSourcesBuildPhase; 688 | buildActionMask = 2147483647; 689 | files = ( 690 | 753B79FD191A8D970034A6D5 /* E11_Diffusion.m in Sources */, 691 | D3EFD6F81919DA1700EA8874 /* E04_Grayscale.m in Sources */, 692 | D3EF49801919ABCB003E8B91 /* E02_SpriteColor.m in Sources */, 693 | D3EF49941919BE55003E8B91 /* E03_SpriteDistort.m in Sources */, 694 | D3EF494A19199980003E8B91 /* main.m in Sources */, 695 | D3EF495F19199B09003E8B91 /* E01_SimplestShader.m in Sources */, 696 | 753B7A0B191AD9710034A6D5 /* E13_MotionBlur.m in Sources */, 697 | D3EFD70B1919F89C00EA8874 /* E07_ColorFlash.m in Sources */, 698 | 753B7A06191AC2DD0034A6D5 /* E12_ColorMatrix.m in Sources */, 699 | D33E2B2B191D866000FEB214 /* E14_Flag.m in Sources */, 700 | D3EFD7071919E51800EA8874 /* E06_Shadow.m in Sources */, 701 | D3275508191AE26A00865098 /* E09_Static.m in Sources */, 702 | D3EFD7001919DFA100EA8874 /* E05_Chromatic.m in Sources */, 703 | D3A6CD451922A39A000E4134 /* E15_SignedDistanceField.m in Sources */, 704 | D32754F5191A94EC00865098 /* E08_Outline.m in Sources */, 705 | D3EF494E19199980003E8B91 /* AppDelegate.m in Sources */, 706 | D38827B2191D617F006C1A75 /* E10_Water.m in Sources */, 707 | D3BC84E01940BAFF00E98AD2 /* E16_MetaParticles.m in Sources */, 708 | D3EF49971919C543003E8B91 /* ExampleBase.m in Sources */, 709 | ); 710 | runOnlyForDeploymentPostprocessing = 0; 711 | }; 712 | /* End PBXSourcesBuildPhase section */ 713 | 714 | /* Begin PBXTargetDependency section */ 715 | D3EF496F19199DBA003E8B91 /* PBXTargetDependency */ = { 716 | isa = PBXTargetDependency; 717 | name = cocos2d; 718 | targetProxy = D3EF496E19199DBA003E8B91 /* PBXContainerItemProxy */; 719 | }; 720 | /* End PBXTargetDependency section */ 721 | 722 | /* Begin XCBuildConfiguration section */ 723 | D3EF495519199980003E8B91 /* Debug */ = { 724 | isa = XCBuildConfiguration; 725 | buildSettings = { 726 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 727 | CLANG_ENABLE_OBJC_ARC = YES; 728 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 729 | GCC_C_LANGUAGE_STANDARD = gnu99; 730 | GCC_OPTIMIZATION_LEVEL = 0; 731 | GCC_PREPROCESSOR_DEFINITIONS = ( 732 | DEBUG, 733 | "COCOS2D_DEBUG=1", 734 | ); 735 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 736 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 737 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 738 | GCC_WARN_UNUSED_VARIABLE = YES; 739 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 740 | SDKROOT = iphoneos; 741 | TARGETED_DEVICE_FAMILY = 2; 742 | }; 743 | name = Debug; 744 | }; 745 | D3EF495619199980003E8B91 /* Release */ = { 746 | isa = XCBuildConfiguration; 747 | buildSettings = { 748 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 749 | CLANG_ENABLE_OBJC_ARC = YES; 750 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 751 | GCC_C_LANGUAGE_STANDARD = gnu99; 752 | GCC_PREPROCESSOR_DEFINITIONS = ( 753 | NDEBUG, 754 | "NS_BLOCK_ASSERTIONS=1", 755 | ); 756 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 757 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 758 | GCC_WARN_UNUSED_VARIABLE = YES; 759 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 760 | SDKROOT = iphoneos; 761 | TARGETED_DEVICE_FAMILY = 2; 762 | }; 763 | name = Release; 764 | }; 765 | D3EF495B19199980003E8B91 /* Debug */ = { 766 | isa = XCBuildConfiguration; 767 | buildSettings = { 768 | ALWAYS_SEARCH_USER_PATHS = NO; 769 | ARCHS = "$(ARCHS_STANDARD)"; 770 | COPY_PHASE_STRIP = NO; 771 | GCC_DYNAMIC_NO_PIC = NO; 772 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 773 | GCC_PREFIX_HEADER = "Cookbook/Supporting Files/Prefix.pch"; 774 | HEADER_SEARCH_PATHS = ( 775 | "\"$(SRCROOT)/Cocos2D/cocos2d\"/**", 776 | "\"$(SRCROOT)/Cocos2D/external/ObjectAL\"/**", 777 | "\"$(SRCROOT)/Cocos2D/external/Chipmunk/include\"", 778 | "\"$(SRCROOT)/Cocos2D/external/Chipmunk/objectivec/include\"", 779 | "\"$(SRCROOT)/Cocos2D/cocos2d-ui\"/**", 780 | ); 781 | INFOPLIST_FILE = Cookbook/Resources/Info.plist; 782 | ONLY_ACTIVE_ARCH = YES; 783 | OTHER_LDFLAGS = ( 784 | "-lz", 785 | "-lsqlite3", 786 | "-ObjC", 787 | ); 788 | PRODUCT_NAME = Cocos2DShaderCookbook; 789 | TARGETED_DEVICE_FAMILY = "1,2"; 790 | WRAPPER_EXTENSION = app; 791 | }; 792 | name = Debug; 793 | }; 794 | D3EF495C19199980003E8B91 /* Release */ = { 795 | isa = XCBuildConfiguration; 796 | buildSettings = { 797 | ALWAYS_SEARCH_USER_PATHS = NO; 798 | ARCHS = "$(ARCHS_STANDARD)"; 799 | COPY_PHASE_STRIP = YES; 800 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 801 | GCC_PREFIX_HEADER = "Cookbook/Supporting Files/Prefix.pch"; 802 | HEADER_SEARCH_PATHS = ( 803 | "\"$(SRCROOT)/Cocos2D/cocos2d\"/**", 804 | "\"$(SRCROOT)/Cocos2D/external/ObjectAL\"/**", 805 | "\"$(SRCROOT)/Cocos2D/external/Chipmunk/include\"", 806 | "\"$(SRCROOT)/Cocos2D/external/Chipmunk/objectivec/include\"", 807 | "\"$(SRCROOT)/Cocos2D/cocos2d-ui\"/**", 808 | ); 809 | INFOPLIST_FILE = Cookbook/Resources/Info.plist; 810 | OTHER_LDFLAGS = ( 811 | "-lz", 812 | "-lsqlite3", 813 | "-ObjC", 814 | ); 815 | PRODUCT_NAME = Cocos2DShaderCookbook; 816 | TARGETED_DEVICE_FAMILY = "1,2"; 817 | VALIDATE_PRODUCT = YES; 818 | WRAPPER_EXTENSION = app; 819 | }; 820 | name = Release; 821 | }; 822 | /* End XCBuildConfiguration section */ 823 | 824 | /* Begin XCConfigurationList section */ 825 | D3EF46F01919997E003E8B91 /* Build configuration list for PBXProject "Cocos2DShaderCookbook" */ = { 826 | isa = XCConfigurationList; 827 | buildConfigurations = ( 828 | D3EF495519199980003E8B91 /* Debug */, 829 | D3EF495619199980003E8B91 /* Release */, 830 | ); 831 | defaultConfigurationIsVisible = 0; 832 | defaultConfigurationName = Release; 833 | }; 834 | D3EF495A19199980003E8B91 /* Build configuration list for PBXNativeTarget "Cocos2DShaderCookbook" */ = { 835 | isa = XCConfigurationList; 836 | buildConfigurations = ( 837 | D3EF495B19199980003E8B91 /* Debug */, 838 | D3EF495C19199980003E8B91 /* Release */, 839 | ); 840 | defaultConfigurationIsVisible = 0; 841 | defaultConfigurationName = Release; 842 | }; 843 | /* End XCConfigurationList section */ 844 | }; 845 | rootObject = D3EF46ED1919997E003E8B91 /* Project object */; 846 | } 847 | -------------------------------------------------------------------------------- /Cookbook/Classes/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import "cocos2d.h" 2 | 3 | @interface AppDelegate : CCAppDelegate 4 | @end 5 | -------------------------------------------------------------------------------- /Cookbook/Classes/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | #import "ExampleBase.h" 3 | 4 | @implementation AppDelegate 5 | 6 | // 7 | -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 8 | { 9 | // This is the only app delegate method you need to implement when inheriting from CCAppDelegate. 10 | // This method is a good place to add one time setup code that only runs when your app is first launched. 11 | 12 | // Setup Cocos2D with reasonable defaults for everything. 13 | // There are a number of simple options you can change. 14 | // If you want more flexibility, you can configure Cocos2D yourself instead of calling setupCocos2dWithOptions:. 15 | [self setupCocos2dWithOptions:@{ 16 | // Show the FPS and draw call label. 17 | // CCSetupShowDebugStats: @(YES), 18 | 19 | // More examples of options you might want to fiddle with: 20 | // (See CCAppDelegate.h for more information) 21 | 22 | // Use a 16 bit color buffer: 23 | // CCSetupPixelFormat: kEAGLColorFormatRGB565, 24 | // Use a simplified coordinate system that is shared across devices. 25 | // CCSetupScreenMode: CCScreenModeFixed, 26 | // Run in portrait mode. 27 | CCSetupScreenOrientation: CCScreenOrientationPortrait, 28 | // Run at a reduced framerate. 29 | // CCSetupAnimationInterval: @(1.0/30.0), 30 | // Run the fixed timestep extra fast. 31 | // CCSetupFixedUpdateInterval: @(1.0/180.0), 32 | // Make iPad's act like they run at a 2x content scale. (iPad retina 4x) 33 | CCSetupTabletScale2X: @(YES), 34 | }]; 35 | 36 | return YES; 37 | } 38 | 39 | -(CCScene *)startScene 40 | { 41 | char *startExample = getenv("StartExample"); 42 | Class klass = objc_getClass(startExample) ?: ExampleBase.examples.firstObject; 43 | 44 | return [klass scene]; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Cookbook/Classes/ExampleBase.h: -------------------------------------------------------------------------------- 1 | #import "cocos2d.h" 2 | #import "cocos2d-ui.h" 3 | 4 | 5 | @interface ExampleBase : CCScene { 6 | CCNode *_exampleContent; 7 | CCLabelTTF *_sourceLabel; 8 | } 9 | 10 | +(NSArray *)examples; 11 | 12 | +(instancetype)scene; 13 | 14 | @property(nonatomic, readonly) NSString *exampleName; 15 | 16 | @property(nonatomic, readonly) NSString *shaderName; 17 | @property(nonatomic, readonly) CCTime time; 18 | 19 | @property(nonatomic, readonly) CCNode *exampleContent; 20 | 21 | @end 22 | 23 | 24 | @interface ExampleSlider : CCSlider 25 | 26 | +(instancetype)sliderNamed:(NSString *)name; 27 | 28 | @end 29 | 30 | 31 | @interface FloatSlider : ExampleSlider 32 | 33 | @property(nonatomic, assign) float startValue, endValue; 34 | @property(nonatomic, copy) void (^valueBlock)(float value); 35 | 36 | @end 37 | 38 | 39 | @interface ColorSlider : ExampleSlider 40 | 41 | @property(nonatomic, strong) CCColor *startColor, *endColor; 42 | @property(nonatomic, copy) void (^colorBlock)(CCColor *color); 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Cookbook/Classes/ExampleBase.m: -------------------------------------------------------------------------------- 1 | #import "ExampleBase.h" 2 | 3 | 4 | @implementation ExampleBase 5 | 6 | +(NSArray *)examples 7 | { 8 | NSMutableArray *arr = [NSMutableArray array]; 9 | 10 | int count = objc_getClassList(NULL, 0); 11 | Class classes[count]; 12 | objc_getClassList(classes, count); 13 | 14 | for(int i=0; iCCShader *monsterShader = [CCShader shaderNamed:@"MonsterShader"]; 13 | sprite.shader = monsterShader; 14 | 15 | This would look for a file named `MonsterShader.fsh` with your fragment shader code in it. You can also provide `MonsterShader.vsh` if you don't want Cocos2D to use it's default vertex shader. These two shaders get compiled together into a `CCShader` object. 16 | 17 | ## Dive In: 18 | 19 | Enough talk. What does a shader actually look like? This is the simplest shader I could think of and it draws a sprite as pure red. 20 | 21 |
void main(){
22 |   gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
23 | }
24 | 
25 | 26 | Shaders for Cocos2D are written in the GLSL language provided by OpenGL. Since it's meant to look a lot like C, it should already look somewhat familiar. 27 | 28 | Every GLSL fragment shader needs two things: 29 | 30 | * Like a C or Objective-C program, it needs to have a `main()` function that is called each time the shader is run. 31 | * It needs to assign a color to the builtin `gl_FragColor` variable. 32 | 33 | OpenGL uses _vectors_ to store colors and positions. So to output a color, you just need to make a 4 component vector for the red, green, blue and alpha chanels. You can initialize colors in GLSL in several ways: 34 | 35 |
// You can create a vector using the vec4 constructor:
36 | gl_FragColor = vec4(redValue, greenValue, blueValue, alphaValue);
37 | 
38 | // You can set color components individually:
39 | gl_FragColor.r = redValue;
40 | gl_FragColor.g = greenValue;
41 | gl_FragColor.b = blueValue;
42 | gl_FragColor.a = alphaValue;
43 | 
44 | // Vectors can also be treated like arrays:
45 | gl_FragColor[0] = redValue;
46 | gl_FragColor[1] = greenValue;
47 | gl_FragColor[2] = blueValue;
48 | gl_FragColor[3] = alphaValue;
49 | 
50 | 51 | Lastly, GLSL uses floating point numbers between 0 and 1 for colors. Forget that you've ever heard the number 255 in relation to colors! 52 | 53 | ## What you should know now: 54 | 55 | * How to load a shader. 56 | * How to apply a shader to a sprite. 57 | * The basic structure of a fragment shader. 58 | * GLSL colors are stored in vectors. 59 | 60 | ## Exercises: 61 | 62 | * Make the shader output blue. 63 | * Make the shader output 50% gray. -------------------------------------------------------------------------------- /Cookbook/Docs/E01_SimplestShader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E01_SimplestShader.png -------------------------------------------------------------------------------- /Cookbook/Docs/E02_SpriteColor.md: -------------------------------------------------------------------------------- 1 | # E02: Sprite Color 2 | ![image](E02_SpriteColor.png) 3 | 4 | Neat, so example 1 taught us how to use shaders to draw pure red sprites so you can make the next hit game with a minimalist style. This next example is actually the default Cocos2D shader and is responsible for most of the drawing you see in Cocos2D games. 5 | 6 |
void main(){
 7 |   // Read the sprite's texture's color for the current pixel.
 8 |   vec4 textureColor = texture2D(cc_MainTexture, cc_FragTexCoord1);
 9 |   
10 |   // Tint the texture color by the sprite's color.
11 |   gl_FragColor = cc_FragColor*textureColor;
12 | }
13 | 
14 | 15 | ## Sampling Textures: 16 | 17 | In order to draw a sprite, you need to figure out what texture pixel to draw for each screen pixel. When you think about rotating, scaling or skewing sprites this might sound complicated. Fortunately OpenGL and Cocos2D do most of the work for you! 18 | 19 | Let's break down the first line: 20 | 21 | * `texture2D()` is a builtin GLSL function that samples a texture at a certain location. 22 | * `cc_MainTexture` is a builtin variable that Cocos2D provides for the current sprite being rendered. 23 | * `cc_FragTexCoord1` is another builtin variable that Cocos2D provides. It's the texture coordinate you should read from in a fragment shader to correctly draw a sprite. 24 | 25 | Putting that all together, `texture2D(cc_MainTexture, cc_FragTexCoord1)` reads a color from the sprite's texture for the current output pixel. That's not so bad. 26 | 27 | 28 | ## Color Math: 29 | 30 | Sprites in Cocos2D have a tinting color. As the tint color gets darker, so does the sprite. As the color gets more red, the sprite gets more red. As the color gets more transparent, so does the sprite. Let's implement that. 31 | 32 | First you need to know about another builtin Cocos2D variable `cc_FragColor`. For sprites, this is its _premultiplied_ color. Premultiplying a color just means that it's original red, green, and blue values have been multiplied by the alpha. This might sound like a dumb and random thing to do, but it solves a _lot_ of problems. Most every color value you will ever use in a shader will be premultiplied. The default alpha blending function in Cocos2D requires shaders to output premultiplied colors as well. 33 | 34 | So, how do you ipmlement tinting in a shader? It's actually really easy. All you need to do is muliply the two colors together. 35 | 36 |
// You can do it the long way:
37 | gl_FragColor.r = cc_FragColor.r*textureColor.r;
38 | gl_FragColor.g = cc_FragColor.g*textureColor.g;
39 | gl_FragColor.b = cc_FragColor.b*textureColor.b;
40 | gl_FragColor.a = cc_FragColor.a*textureColor.a;
41 | 
42 | // Or use a vector multiply to do the same thing:
43 | gl_FragColor = cc_FragColor*textureColor;
44 | 
45 | 46 | Because both `textureColor` and `cc_FragColor` were premultiplied, the result is premultiplied as well. Handy right? 47 | 48 | "Vector math" might sound scary, but it doesn't have to. Just think of it as doing the same operation to each component like in the example above. The +, -, *, and / operators all work the same way. 49 | 50 | ## Exercises: 51 | 52 | * Modify the shader to brighten the sprite by it's color instead. 53 | -------------------------------------------------------------------------------- /Cookbook/Docs/E02_SpriteColor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E02_SpriteColor.png -------------------------------------------------------------------------------- /Cookbook/Docs/E03_SpriteDistort.md: -------------------------------------------------------------------------------- 1 | # E03: Sprite Distort 2 | ![image](E03_SpriteDistort.png) 3 | 4 | Example 2 showed you how to draw a textured sprite in a shader, but that's still really basic. Now let's try something more interesting that you can only do with a shader. What happens if we change the magically calculated texture coordinate before accessing the texture? 5 | 6 |
void main(){
 7 |   vec2 texCoord = cc_FragTexCoord1;
 8 |   
 9 |   float time = cc_Time[0];
10 |   texCoord.x += 0.1*sin(10.0*texCoord.y + time);
11 |   
12 |   gl_FragColor = cc_FragColor*texture2D(cc_MainTexture, texCoord);
13 | }
14 | 
15 | Some new stuff here: 16 | 17 | * Vector sizes. Up to this point we've only been using for component vectors for colors. You can make 2 and 3 component vectors as well. `cc_FragTexCoord1` is an x/y coordinate, so we need to store it in a vec2 variable. 18 | * New Cocos2D builtin variable `cc_Time`. This is a 4 component vector that stores varous time related values. The first element is regular time. 19 | * Yet another way to access vectors. You can use xyzw in addition to rgba or array notation. (Also stpq... but forget I mentioned it) 20 | * More builtin GLSL functions.[^1] In this case `sin()`. 21 | 22 | So now instead of reading the texture coordinates directly as Cocos2D calculated them, use some animated sine waves to distort the texture. It's important to keep in mind that a fragment shader can't change what pixels a sprite will draw _into_. It can only change what pixels it draws _from_. I intentionally made the sine wave cause the sprite to clip against it's left and right edges to show this. 23 | 24 | ## Texture Coordinates: 25 | 26 | It's important to know that texture coordinates are normalized and __not in pixels__. This means that (0, 0) is the lowel left of a texture and (1, 1) is the upper right. If you want to apply distortions to a sprite's texture, you need to keep in mind the size and aspect ratio of the texture. 27 | 28 | The reason why OpenGL works this way is so that it's easy to substitute a higher resolution texture without needing to recalculate texture coordinates. It doesn't always make it easy to do special effects shaders though. 29 | 30 | ## Exercises: 31 | 32 | * Experiment with more ways to distort the texture. See if you can make any fun effects. 33 | 34 | 35 | [^1]: For a nice GLSL summary, [here](http://www.khronos.org/opengles/sdk/docs/reference_cards/OpenGL-ES-2_0-Reference-card.pdf) is a handy GLSL ES Cheat Sheet. I would highly recommend saving it somewhere convenient. -------------------------------------------------------------------------------- /Cookbook/Docs/E03_SpriteDistort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E03_SpriteDistort.png -------------------------------------------------------------------------------- /Cookbook/Docs/E04_Grayscale.md: -------------------------------------------------------------------------------- 1 | # E04: Grayscale 2 | ![image](E04_Grayscale.png) 3 | 4 | Here's another simple but common shader effect. 5 | 6 |
void main(){
 7 |   gl_FragColor = cc_FragColor*texture2D(cc_MainTexture, cc_FragTexCoord1);
 8 |   
 9 |   float gray = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b)/3.0;
10 |   gl_FragColor.rgb = vec3(gray);
11 | }
12 | 
13 | 14 | It's starts out reading the texture color and tinting it. Then averages the red, green and blue channels together. Lastly, it uses that average value to make a new color. Pretty simple. 15 | 16 | This is a simple way to convert to grayscale, but it does not preserve _luminance_, or overall brightness. This is because the human eye is equally sensitive to red, green and blue light and computer displays are calibrated to take advantage of this. 17 | 18 | ## Vector Swizzling and Slicing: 19 | 20 | GLSL has a lot of really handy syntax for working with vectors. Hopefully the meaning of the following example is clear just by looking at it. It creates a 3 component vector that repeats the same value 3 times. Then it replaces the rgb values in `gl_FragColor` with this new vector. 21 | 22 | ``` 23 | float gray = ...; 24 | gl_FragColor.rgb = vec3(gray); 25 | ``` 26 | 27 | More examples! 28 | 29 | ``` 30 | color1.rgb = color.gbr; 31 | position = vec3(vec2(x, y), z); 32 | color3 = vec4(vec2(r, g), vec2(b, a)); 33 | color4 = vec4(r, g, color5.ba); 34 | position2.yz = vec2(y, z). 35 | ``` 36 | 37 | That should give you a pretty good idea of what you can do with GLSL vectors. 38 | 39 | ## Exercises: 40 | 41 | * Rewrite the shader to apply the tint color after converting to grayscale. 42 | * Read about proper grayscale conversion: http://en.wikipedia.org/wiki/Luminance_(relative). 43 | * See if you can figure out how to use GLSL's `dot()` function to simplify the averaging. 44 | -------------------------------------------------------------------------------- /Cookbook/Docs/E04_Grayscale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E04_Grayscale.png -------------------------------------------------------------------------------- /Cookbook/Docs/E05_Chromatic.md: -------------------------------------------------------------------------------- 1 | # E05: Chromatic 2 | ![image](E05_Chromatic.png) 3 | 4 | Here's a fun effect you see in games sometimes that makes it look like you are looking through a prism. It works by sampling the texture multiple times at slightly different places and then combines them back together. 5 | 6 |
void main(){
 7 |   float t = cc_Time[0];
 8 |   vec2 uv = cc_FragTexCoord1;
 9 |   float wave = 0.01;
10 |   
11 |   // Sample the same texture several times at different locations.
12 |   vec4 r = texture2D(cc_MainTexture, uv + vec2(wave*sin(1.0*t + uv.y*5.0), 0.0));
13 |   vec4 g = texture2D(cc_MainTexture, uv + vec2(wave*sin(1.3*t + uv.y*5.0), 0.0));
14 |   vec4 b = texture2D(cc_MainTexture, uv + vec2(wave*sin(1.6*t + uv.y*5.0), 0.0));
15 |   
16 |   // Combine the channels, average the alpha values.
17 |   gl_FragColor = vec4(r.r, g.g, b.b, (r.a + b.a + g.a)/3.0);
18 | }
19 | 
20 | 21 | ## Exercises 22 | 23 | * Experiment with other distortion patterns. 24 | * See if you can figure out how to do more than just three colors/samples. 25 | * Are there other ways to combine the colors together? 26 | -------------------------------------------------------------------------------- /Cookbook/Docs/E05_Chromatic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E05_Chromatic.png -------------------------------------------------------------------------------- /Cookbook/Docs/E06_Shadow.md: -------------------------------------------------------------------------------- 1 | # E06: Shadow 2 | ![image](E06_Shadow.png) 3 | 4 | Since you can sample a texture more than once, you can do all sorts of simple effects. Keep some things in mind though. The default blending mode for sprites is premultiplied alpha blending, and this should be your go to blending mode. It will allow you to composite multiple additive or alpha blended layers in the shader and output a single premultiplied value for all of them. If you need to mix other kinds of blending together, you might need to render using multiple sprites stacked on top of one another. Also, because you cannot render outside of a sprite's bounds, make sure you have enough transparent padding around your sprite for any effects you plan to add. 5 | 6 | Here is an example shader that uses the texture's alpha to composite a shadow layer underneath the sprite. As long as the shadow is black, it can use alpha blending to composite it. 7 | 8 |
vec4 composite(vec4 over, vec4 under){
 9 |   return over + (1.0 - over.a)*under;
10 | }
11 | 
12 | void main(){
13 |   vec4 textureColor = cc_FragColor*texture2D(cc_MainTexture, cc_FragTexCoord1);
14 |   
15 |   // Offset of the shadow in texture coordinates.
16 |   vec2 shadowOffset = vec2(-0.03, -0.03);
17 |   float shadowMask = texture2D(cc_MainTexture, cc_FragTexCoord1 + shadowOffset).a;
18 |   
19 |   const float shadowOpacity = 0.5;
20 |   vec4 shadowColor = vec4(vec3(0.0), shadowMask*shadowOpacity);
21 |   
22 |   gl_FragColor = composite(textureColor, shadowColor);
23 | }
24 | 
25 | 26 | The `composite()` function is simple enough. It should look familiar as the linear interpolation formula, but with one of the multiplies removed. Since the color's are premultiplied already, there is no need to do it again. The output color is even properly premultiplied. Handy! 27 | 28 | The `main()` function starts off simple enough by reading the texture normally and again at a constant offset. It only keeps the alpha value of the second sample since it will only be used for a mask. 29 | 30 | Next it calculates the shadow color. Since the shadow is black, it's already properly premultiplied no matter what the alpha is (0 times anything is still zero). 31 | 32 | # Exercises: 33 | 34 | * Can you figure out how add a colored layer instead of a shadow underneath? You'll need to calculate a premultiplied color. 35 | * Can you figure out how to make the shadow respect the sprite's alpha? 36 | * Can you figure out how to apply an inner shadow instead? 37 | -------------------------------------------------------------------------------- /Cookbook/Docs/E06_Shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E06_Shadow.png -------------------------------------------------------------------------------- /Cookbook/Docs/E07_ColorFlash.md: -------------------------------------------------------------------------------- 1 | # E07: Color Flash 2 | 3 | ![image](E07_ColorFlash.png) 4 | 5 | Cocos2D's default shader allows you to tint a sprite by it's color, but there are other things you might want to do with the color. One thing that you often see in old 2D games is to make a sprite flash a solid color. This is a very easy effect to do in a shader. 6 | 7 | To make it a little more interesting, let's say you want to have a separate flash and tint color. We'll have to pass the flash color into the shader in a different way. 8 | 9 |
uniform vec4 u_ColorFlash;
10 | 
11 | void main(){
12 |   vec4 color = texture2D(cc_MainTexture, cc_FragTexCoord1);
13 |   
14 |   // Composite the flash color over the texture color.
15 |   // mix() is a builtin GLSL function that does linear interpolation.
16 |   color.rgb = mix(color.rgb, u_ColorFlash.rgb*color.a, u_ColorFlash.a);
17 |   
18 |   gl_FragColor = cc_FragColor*color;
19 | }
20 | 
21 | 22 | Simple enough, but let's break it down: 23 | 24 | * The `uniform` keyword on the `u_FlashColor` tells GLSL that the variable is set from your program. More on that below. 25 | * GLSL's builtin `mix()` function implements run of the mill alpha blending. 26 | * Since the flash color is being masked by the texture's alpha, we need to premultiply it by the texture's alpha. 27 | * Finally tint the composited color. 28 | 29 | ## Uniform Variables: 30 | 31 | Uniform variables are variables that you can set from your Objective-C code. They are "uniform" because the value will be the same for every pixel in a sprite. You can use them to pass colors, positions, offsets, textures and matrices to a shader. 32 | 33 | You've actually used a number of uniform variables already. Many of Cocos2D's builtin shader variables are uniforms. `cc_MainTexture` and `cc_Time` are both uniforms. [^1] 34 | 35 | [^1]: Later you'll also learn about GLSL's `attribute` and `varying` variable types. 36 | 37 | There are two ways to set a uniform variable in Cocos2D, both using dictionaries to store the values. The fastest way is to use the `CCDirector.globalShaderUniforms` dictionary. These global uniforms are shared by all shaders on every object. You can also set uniforms for specific sprites. The reason why global uniforms are faster is Cocos2D cannot automatically batch the rendering of sprites that have custom uniform values. 38 | 39 | 40 | ``` 41 | // Pass colors using CCColor objects. 42 | sprite.shaderUniforms[@"MyColor"] = [CCColor redColor]; 43 | 44 | // Pass floats using NSNumber objects. 45 | sprite.shaderUniforms[@"MyFloat"] = @(123.456); 46 | 47 | // Pass positions, offsets, or sizes using NSValue objects. 48 | sprite.shaderUniforms[@"MyPoint"] = [NSValue valueWithCGPoint:point]; 49 | sprite.shaderUniforms[@"MySize"] = [NSValue valueWithCGSize:size]; 50 | 51 | // Global uniforms work the same way, but are set on the CCDirector. 52 | [CCDirector sharedDirector].globalShaderUniforms[@"FortyTwo"] = @(42); 53 | ``` 54 | 55 | For a full list of shader uniform types, see the [Cocos2D wiki](https://github.com/cocos2d/cocos2d-iphone/wiki/CustomRenderingQuickGuide#custom-shaders) or peek at the CCShader.m code. 56 | 57 | ## Exercises: 58 | 59 | * Try rearranging the shader to apply the tinting before applying the flash while still preserving the sprite's alpha. 60 | * Try modifying the shadow shader to use a uniform for the shadow offset. -------------------------------------------------------------------------------- /Cookbook/Docs/E07_ColorFlash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E07_ColorFlash.png -------------------------------------------------------------------------------- /Cookbook/Docs/E08_Outline.md: -------------------------------------------------------------------------------- 1 | # E08: Outline 2 | 3 | ![image](E08_Outline.png) 4 | 5 | The idea for this shader is similar to the shadow shader. Instead of just taking one texture sample where the shadow will be, take several in a circular pattern. Once they are blended together, you'll have a mask of the pixels near the sprite. Blend that mask with a color and composite it under the sprite. Tada! Let's look at the fragment shader. 6 | 7 |
const int SAMPLES = 6;
  8 | varying vec2 v_OutlineSamples[SAMPLES];
  9 | 
 10 | vec4 composite(vec4 over, vec4 under){
 11 |   return over + (1.0 - over.a)*under;
 12 | }
 13 | 
 14 | void main(){
 15 |   // Use the coordinates from the v_OutlineSamples[] array.
 16 |   float outlineAlpha = 0.0;
 17 |   for(int i=0; i<SAMPLES; i++){
 18 |     float alpha = texture2D(cc_MainTexture, v_OutlineSamples[i]).a;
 19 |     
 20 |     // Blend the alpha with our other samples.
 21 |     outlineAlpha = outlineAlpha + (1.0 - outlineAlpha)*alpha;
 22 |   }
 23 |   
 24 |   // Let's repurpose cc_FragColor for the outline color.
 25 |     vec4 outlineColor = cc_FragColor*outlineAlpha;
 26 |   vec4 textureColor = texture2D(cc_MainTexture, cc_FragTexCoord1);
 27 |   gl_FragColor = composite(textureColor, outlineColor);
 28 | }
 29 | 
30 | 31 | Let's break it down: 32 | 33 | * `v_OutlineSamples` is a array of `vec2`. It also uses the `varying` keyword. Must mean something important! 34 | * A for loop, just like you'd see in Objective-C. It blends a bunch of texture samples together for the outline's alpha. 35 | * `cc_FragColor` is used for the outline color instead of using like a tint color. Multiply it against the outline alpha to make the correct premultiplied color. 36 | * Finally the texture and outline are composited together. 37 | 38 | The only real question is, what is that magical `v_OutlineSamples` that had all the right texture coordinates? It has to do with that `varying` keyword. That means that it's calculated in a _vertex shader_. More code! 39 | 40 | ## Vertex Shaders and Varying Variables: 41 | 42 | If you've never done OpenGL programming before, you are probably wondering what vertexes have to do with rendering sprites? It turns out that modern GPUs only know about drawing triangles. To draw a rectangle (a sprite), you need to draw two triangles. In order to draw the triangles, you need the four corners of the rectangle. The corners are the vertexes. The vertex shader tells the GPU where the vertexes are on the screen and sets variables used by the fragment shader like the color and texture coordinates. I've never met anybody that thought vertex shaders were intuitive. Don't be discouraged if they don't make sense at first. 43 | 44 | If you remember from the first example, I mentioned that every CCShader needs both a vertex shader and a fragment shader. Since we've only been making fragment shaders, Cocos2D has been pairing them with it's default vertex shader. Let's look at that first. It's actually pretty simple. 45 | 46 |
void main(){
 47 |   gl_Position = cc_Position;
 48 |   cc_FragColor = clamp(cc_Color, 0.0, 1.0);
 49 |   cc_FragTexCoord1 = cc_TexCoord1;
 50 |   cc_FragTexCoord2 = cc_TexCoord2;
 51 | }
 52 | 
53 | 54 | A lot of this should look familiar already. It starts out with a `main()` function that writes to a GL variable and some builtin Cocos2D variables. Like how fragment shaders must write to the `gl_FragColor` variable, a vertex shader must write to `gl_Position`. This is the position of the vertex on the screen. Cocos2D calculates this when batching sprites, so the vertex shader just needs to copy it. 55 | 56 | What about the `cc_Frag*` variables though? Each pixel gets a different value, but the vertex shader only sets the value once. That's what `varying` variables are. When a pixel is halfway between two vertexes, when the fragment shader runs the varying variable will be halfway between the value set in the two vertexes. 57 | 58 | Ok! So what does the outline vertex shader look like? 59 | 60 |
uniform vec2 u_MainTextureSize;
 61 | uniform float u_OutlineWidth;
 62 | 
 63 | const int SAMPLES = 6;
 64 | varying vec2 v_OutlineSamples[SAMPLES];
 65 | 
 66 | void main(){
 67 |   gl_Position = cc_Position;
 68 |   cc_FragColor = clamp(cc_Color, 0.0, 1.0);
 69 |   cc_FragTexCoord1 = cc_TexCoord1;
 70 |   
 71 |   vec2 outlineSize = u_OutlineWidth/u_MainTextureSize;
 72 |   for(int i=0; i<SAMPLES; i++){
 73 |     float angle = 2.0*3.14159*float(i)/float(SAMPLES);
 74 |     v_OutlineSamples[i] = cc_TexCoord1 + outlineSize*vec2(cos(angle), sin(angle));
 75 |   }
 76 | }
 77 | 
78 | 79 | Let's break it down: 80 | 81 | * The `main()` function starts out the same way as the default. It skips `cc_FragTexCoord2` since it's not used. 82 | * Another for loop that iterates over the array. This one calculates offsets from the regular texture coordinate in a circle. 83 | * Since the offsets are in texture coordinates, not Cocos2D points, we need to pass the texture size in using a uniform to rescale the offsets. 84 | 85 | ## Why Vertex Shaders? 86 | 87 | ### Avoiding Redundant Calculations: 88 | 89 | Vertex shaders seem like an awful lot of work. So why use them? Think about it this way. Given a 100x100 pixel sprite, the fragment shader has to run 10,000 times while the vertex shader only needs to run 4. You can save a *lot* of work for the GPU if you can calculate something in a vertex shader instead of a fragment shader. 90 | 91 | ### Dependent Texture Samples: 92 | 93 | Remember back to the basic Cocos2D shader. It looked up the texture like this: 94 | 95 | texture2D(cc_MainTexture, cc_FragTexCoord1) 96 | 97 | In this case, the texture coordinate is constant value. Because of this, the GPU can actually look up the texture sample before the fragment shader program even starts. If your shader makes many texture samples, the GPU can even do them at the same time! 98 | 99 | On the other hand, some of the shaders we've made so far have looked like this: 100 | 101 | texture2D(cc_MainTexture, somethingWeCalculated); 102 | 103 | The sample coordinate is no longer constant. The GPU has to start the program running to calculate the texture coordinate then stop the program to make the sample. This is called a dependent texture sample. If you make many samples, it will have to start and stop your program many times. The same thing happens when you access RAM on a regular CPU, but the effect is usually much worse on a GPU.[^1] It's one of the more expensive things you can do in a fragment shader. 104 | 105 | [^1]: Apple's documentation for the A7 (iPad Air, iPhone 5s) states that dependent texture reads aren't penalized. 106 | 107 | ## Excercises: 108 | 109 | * Try rewriting the effect to only use the fragment shader. -------------------------------------------------------------------------------- /Cookbook/Docs/E08_Outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E08_Outline.png -------------------------------------------------------------------------------- /Cookbook/Docs/E09_Static.md: -------------------------------------------------------------------------------- 1 | # E09: Static 2 | 3 | ![image](E09_Static.png) 4 | 5 | So this is a fun effect. Some nice static like you see on a TV screen. Since there is no `rand()` function to use in a shader we'll use a texture full of random pixels instead. Time to dive into the code. 6 | 7 |
uniform vec2 u_NoiseTextureSize;
 8 | 
 9 | void main(){
10 |   gl_Position = cc_Position;
11 |   cc_FragColor = clamp(cc_Color, 0.0, 1.0);
12 |   cc_FragTexCoord1 = cc_TexCoord1;
13 |   
14 |   vec2 screen01 = (0.5*gl_Position.xy/gl_Position.w + 0.5);
15 |   cc_FragTexCoord2 = screen01*cc_ViewSizeInPixels/u_NoiseTextureSize;
16 |   cc_FragTexCoord2 += cc_Random01.xy;
17 | }
18 | 
19 | Another vertex shader! Woo? Boo? It starts out the same way as the default vertex shader, but what do those last three lines do? 20 | 21 | vec2 screen01 = (0.5*gl_Position.xy/gl_Position.w + 0.5); 22 | 23 | In OpenGL, the `gl_Position` coordinates go from (-1, -1) for the bottom left corner of the screen to (1, 1) for the top right. This is called _clip coordinates_. This isn't quite the same as texture coordinates so we need to do a little math to put them into the [0, 1] range. So what's up with dividing by `gl_Position.w`? Well... It's complicated, and mostly required if you use 3D effects. _"Perspective divide"_ is the term to Google for if you want to know more. 24 | 25 | cc_FragTexCoord2 = screen01*cc_ViewSizeInPixels/u_NoiseTextureSize; 26 | 27 | Now that we have a [0, 1] value for the vertex relative to the screen, we can multiply that be the screen size to convert it to pixels. Fortunately, Cocos2D provides a builtin uniform for that, `cc_ViewSiveInPixels`. Since the texture was set to repeat in the Objective-C code, if we divide the pixel coordinate by the noise texture's size We now have a texture coordinate where the pixels in the texture will always line up with the screen. This might be a lot to take in, but it's a common pattern in special effect shaders and definitely something you'll want to learn. 28 | 29 | cc_FragTexCoord2 += cc_Random01.xy; 30 | 31 | This last line makes the static animate. While you don't get a `rand()` function in shaders, Cocos2D provides a builtin `vec4` uniform that it fills with random numbers in the range [0, 1] each frame. We can just add this as an offset to the texture coordinate to make the static jitter around randomly. Neat. Onto the fragment shader. 32 | 33 |
uniform sampler2D u_NoiseTexture;
34 | 
35 | uniform float u_NoiseAmount;
36 | 
37 | void main(){
38 |   vec4 textureColor = texture2D(cc_MainTexture, cc_FragTexCoord1);
39 |   vec4 noiseColor = texture2D(u_NoiseTexture, cc_FragTexCoord2);
40 |   
41 |   gl_FragColor = cc_FragColor*textureColor;
42 |   gl_FragColor.rgb += (textureColor.a*u_NoiseAmount)*(2.0*noiseColor.rgb - 1.0);
43 | }
44 | 
45 | 46 | Nothing fancy here. Note that the noise value is converted to the [-1, 1] range and premultiplied by the texture's alpha. 47 | 48 | ## Excercises: 49 | 50 | * Try making the static grayscale instead of colored. 51 | * Try making the static scroll instead of jumping around randomly. -------------------------------------------------------------------------------- /Cookbook/Docs/E09_Static.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E09_Static.png -------------------------------------------------------------------------------- /Cookbook/Docs/E09_Water.md: -------------------------------------------------------------------------------- 1 | # E10: Water 2 | 3 | ![image](E10_Water.png) 4 | 5 | Here's a practical animated water effect. 6 | 7 | It's works like the earlier Sprite Distort example, but instead of using a trig function to distort the texture coordinates, we'll use colors out of another texture. Similar to how GLSL doesn't have special vectors for colors and positions, textures aren't really special either. You can treat a texture as containing colors, offsets, or a function lookup table. It's all just numbers to OpenGL. 8 | 9 | Code time! We'll start with the vertex shader. 10 | 11 |
uniform vec2 u_NoiseTextureSize;
12 | 
13 | void main(){
14 |   gl_Position = cc_Position;
15 |   cc_FragColor = clamp(cc_Color, 0.0, 1.0);
16 |   cc_FragTexCoord1 = cc_TexCoord1;
17 |   cc_FragTexCoord2 = cc_TexCoord2;
18 |   
19 |   vec2 distortionScroll = vec2(cc_Time[0], 0.0);
20 |   vec2 screen01 = (0.5*gl_Position.xy/gl_Position.w + 0.5);
21 |   cc_FragTexCoord2 = screen01*cc_ViewSizeInPixels/u_NoiseTextureSize + distortionScroll;
22 | }
23 | 
24 | 25 | This should look familiar. It's not too different than the last one. On to the fragment shader. 26 | 27 |
uniform sampler2D u_NoiseTexture;
28 | uniform sampler2D u_CausticTexture;
29 | 
30 | void main(){
31 |   vec2 distortion = 2.0*texture2D(u_NoiseTexture, cc_FragTexCoord2).xy - 1.0;
32 |   vec2 distortionOffset = distortion*0.05;
33 |   
34 |   gl_FragColor = cc_FragColor*texture2D(cc_MainTexture, cc_FragTexCoord1 + distortionOffset);
35 |   gl_FragColor += 0.5*texture2D(u_CausticTexture, cc_FragTexCoord1 - distortionOffset);
36 | }
37 | 
38 | 39 | Nothing particularly new here, just new combinations. 40 | 41 | ## Exercises: 42 | 43 | * Try experimenting with the noise texture. See if you can make different kinds of waves. -------------------------------------------------------------------------------- /Cookbook/Docs/E10_Water.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E10_Water.png -------------------------------------------------------------------------------- /Cookbook/Docs/E11_Diffusion.md: -------------------------------------------------------------------------------- 1 | #E11: Diffusion 2 | 3 | ![image](E11_Diffusion.png) 4 | 5 | This is one of my favorite effects. It uses a noise texture to offset each pixel slightly. This produces a nice little noisy blur effect. Since it only requires a single dependent texture lookup per pixel, it's pretty cheap as a blur. 6 | 7 | The vertex shader should look quite familiar already. 8 | 9 |
uniform vec2 u_NoiseTextureSize;
10 | 
11 | uniform float u_AnimationEnabled;
12 | uniform float u_BlockSize;
13 | 
14 | void main(){
15 |   gl_Position = cc_Position;
16 |   cc_FragColor = clamp(cc_Color, 0.0, 1.0);
17 |   cc_FragTexCoord1 = cc_TexCoord1;
18 |   
19 |   vec2 screen01 = (0.5*gl_Position.xy/gl_Position.w + 0.5);
20 |   cc_FragTexCoord2 = screen01*cc_ViewSizeInPixels/u_NoiseTextureSize;
21 |   vec2 randomAnimatedOffset = cc_Random01.xy*u_AnimationEnabled;
22 |   cc_FragTexCoord2 = (uv + randomAnimatedOffset)/u_BlockSize;
23 | }
24 | 
25 | 26 | The fragment shader is also unsurprising. 27 | 28 |
uniform float u_Radius;
29 | uniform vec2 u_MainTextureSize;
30 | uniform sampler2D u_NoiseTexture;
31 | 
32 | void main(){
33 |   vec2 noise = 2.0*texture2D(u_NoiseTexture, cc_FragTexCoord2).xy - 1.0;
34 |   vec2 distortionOffset = u_BlurRadius*noise/u_MainTextureSize;
35 |   
36 |   gl_FragColor = cc_FragColor*texture2D(cc_MainTexture, cc_FragTexCoord1 + distortionOffset);
37 | }
38 | 
39 | 40 | One important thing to note here is that the noise texture I used has a gausian distribution. This means that the color values are more likely to be gray than white or black. If it had a uniform distribution, meaning it's just as likely to be white, gray or black, then the blur wouldn't look as good. 41 | 42 | ## Exercises: 43 | 44 | * Try different noise textures. See how it changes the result. -------------------------------------------------------------------------------- /Cookbook/Docs/E11_Diffusion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E11_Diffusion.png -------------------------------------------------------------------------------- /Cookbook/Docs/E12_ColorMatrix.md: -------------------------------------------------------------------------------- 1 | # E12: Color Matrix 2 | 3 | ![image](E12_ColorMatrix.png) 4 | 5 | Have you ever wanted to have color adjustments in Cocos2D like you do in PhotoShop? Some way to adjust the hue, saturation, brightness, contrast, or exposure of a sprite on the fly? 6 | 7 | Well it turns out that it's really quite simple to do with a shader: 8 | 9 |
uniform mat4 u_ColorMatrix;
10 | 
11 | void main(){
12 |   gl_FragColor = u_ColorMatrix*texture2D(cc_MainTexture, cc_FragTexCoord1);
13 | }
14 | 
15 | 16 | You can use transformation matrices to rotate or scale sprites. Since colors are just vectors, it makes just as much sense to use matrices on colors. The catch is of course finding the right matrix to apply. There are some [good examples](http://www.graficaobscura.com/matrix/) online. 17 | 18 | Take a look at the Objective-C code for this example to see how the matrices are made. 19 | 20 | ## Exercises: 21 | 22 | * See if you can find any more interesting color matrices. -------------------------------------------------------------------------------- /Cookbook/Docs/E12_ColorMatrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E12_ColorMatrix.png -------------------------------------------------------------------------------- /Cookbook/Docs/E13_MotionBlur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E13_MotionBlur.png -------------------------------------------------------------------------------- /Cookbook/Docs/E15_SignedDistanceField.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Docs/E15_SignedDistanceField.png -------------------------------------------------------------------------------- /Cookbook/Examples/E01_SimplestShader.fsh: -------------------------------------------------------------------------------- 1 | // Like a C program, every shader needs at least a main funcntion. 2 | void main(){ 3 | // Set the output color to red. 4 | gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); 5 | } 6 | -------------------------------------------------------------------------------- /Cookbook/Examples/E01_SimplestShader.m: -------------------------------------------------------------------------------- 1 | #import "cocos2d.h" 2 | #import "ExampleBase.h" 3 | 4 | 5 | @interface E01_SimplestShader : ExampleBase @end 6 | @implementation E01_SimplestShader 7 | 8 | -(CCNode *)exampleContent 9 | { 10 | CCSprite *sprite = [CCSprite spriteWithImageNamed:@"Logo.png"]; 11 | 12 | // Load the fragment shader in the file name E01_SimplestShader.fsh. 13 | // Also loads E01_SimplestShader.vsh as the vertex shader if it exists. 14 | sprite.shader = [CCShader shaderNamed:self.shaderName]; 15 | 16 | return sprite; 17 | } 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Cookbook/Examples/E01_SimplestShader.webarchive: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Examples/E01_SimplestShader.webarchive -------------------------------------------------------------------------------- /Cookbook/Examples/E02_SpriteColor.fsh: -------------------------------------------------------------------------------- 1 | void main(){ 2 | // Read the sprite's texture's color for the current pixel. 3 | vec4 textureColor = texture2D(cc_MainTexture, cc_FragTexCoord1); 4 | 5 | // Tint the texture color by the sprite's color. 6 | gl_FragColor = cc_FragColor*textureColor; 7 | } 8 | -------------------------------------------------------------------------------- /Cookbook/Examples/E02_SpriteColor.m: -------------------------------------------------------------------------------- 1 | #import "ExampleBase.h" 2 | 3 | 4 | @interface E02_SpriteColor : ExampleBase @end 5 | @implementation E02_SpriteColor 6 | 7 | -(CCNode *)exampleContent 8 | { 9 | CCSprite *sprite = [CCSprite spriteWithImageNamed:@"Logo.png"]; 10 | sprite.shader = [CCShader shaderNamed:self.shaderName]; 11 | 12 | ColorSlider *slider = [ColorSlider sliderNamed:@"Tint Color"]; 13 | slider.positionType = CCPositionTypeNormalized; 14 | slider.position = ccp(0.5, 0.25); 15 | slider.anchorPoint = ccp(0.5, 0.5); 16 | slider.endColor = [CCColor magentaColor]; 17 | slider.colorBlock = ^(CCColor *color){sprite.color = color;}; 18 | 19 | CCLayoutBox *content = [CCLayoutBox node]; 20 | content.anchorPoint = ccp(0.5, 0.5); 21 | content.direction = CCLayoutBoxDirectionVertical; 22 | 23 | [content addChild:slider]; 24 | [content addChild:sprite]; 25 | 26 | return content; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Cookbook/Examples/E02_SpriteColor.webarchive: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Examples/E02_SpriteColor.webarchive -------------------------------------------------------------------------------- /Cookbook/Examples/E03_SpriteDistort.fsh: -------------------------------------------------------------------------------- 1 | void main(){ 2 | vec2 texCoord = cc_FragTexCoord1; 3 | 4 | float time = cc_Time[0]; 5 | texCoord.x += 0.1*sin(10.0*texCoord.y + time); 6 | 7 | gl_FragColor = cc_FragColor*texture2D(cc_MainTexture, texCoord); 8 | } 9 | -------------------------------------------------------------------------------- /Cookbook/Examples/E03_SpriteDistort.m: -------------------------------------------------------------------------------- 1 | #import "ExampleBase.h" 2 | 3 | 4 | @interface E03_SpriteDistort : ExampleBase @end 5 | @implementation E03_SpriteDistort 6 | 7 | -(CCNode *)exampleContent 8 | { 9 | CCSprite *sprite = [CCSprite spriteWithImageNamed:@"Logo.png"]; 10 | sprite.shader = [CCShader shaderNamed:self.shaderName]; 11 | 12 | return sprite; 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Cookbook/Examples/E03_SpriteDistort.webarchive: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Examples/E03_SpriteDistort.webarchive -------------------------------------------------------------------------------- /Cookbook/Examples/E04_Grayscale.fsh: -------------------------------------------------------------------------------- 1 | void main(){ 2 | gl_FragColor = cc_FragColor*texture2D(cc_MainTexture, cc_FragTexCoord1); 3 | 4 | float gray = (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b)/3.0; 5 | gl_FragColor.rgb = vec3(gray); 6 | } 7 | -------------------------------------------------------------------------------- /Cookbook/Examples/E04_Grayscale.m: -------------------------------------------------------------------------------- 1 | #import "ExampleBase.h" 2 | 3 | 4 | #define EXAMPLENAME E04_Grayscale 5 | 6 | 7 | @interface EXAMPLENAME : ExampleBase @end 8 | @implementation EXAMPLENAME 9 | 10 | -(CCNode *)exampleContent 11 | { 12 | CCSprite *sprite = [CCSprite spriteWithImageNamed:@"Logo.png"]; 13 | sprite.shader = [CCShader shaderNamed:self.shaderName]; 14 | 15 | return sprite; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Cookbook/Examples/E04_Grayscale.webarchive: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Examples/E04_Grayscale.webarchive -------------------------------------------------------------------------------- /Cookbook/Examples/E05_Chromatic.fsh: -------------------------------------------------------------------------------- 1 | void main(){ 2 | float t = cc_Time[0]; 3 | vec2 uv = cc_FragTexCoord1; 4 | float wave = 0.01; 5 | 6 | // Sample the same texture several times at different locations. 7 | vec4 r = texture2D(cc_MainTexture, uv + vec2(wave*sin(1.0*t + uv.y*5.0), 0.0)); 8 | vec4 g = texture2D(cc_MainTexture, uv + vec2(wave*sin(1.3*t + uv.y*5.0), 0.0)); 9 | vec4 b = texture2D(cc_MainTexture, uv + vec2(wave*sin(1.6*t + uv.y*5.0), 0.0)); 10 | 11 | // Combine the channels, average the alpha values. 12 | gl_FragColor = vec4(r.r, g.g, b.b, (r.a + b.a + g.a)/3.0); 13 | } 14 | -------------------------------------------------------------------------------- /Cookbook/Examples/E05_Chromatic.m: -------------------------------------------------------------------------------- 1 | #import "ExampleBase.h" 2 | 3 | 4 | #define EXAMPLENAME E05_Chromatic 5 | 6 | 7 | @interface EXAMPLENAME : ExampleBase @end 8 | @implementation EXAMPLENAME 9 | 10 | -(CCNode *)exampleContent 11 | { 12 | CCSprite *sprite = [CCSprite spriteWithImageNamed:@"Logo.png"]; 13 | sprite.shader = [CCShader shaderNamed:self.shaderName]; 14 | 15 | return sprite; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Cookbook/Examples/E05_Chromatic.webarchive: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Examples/E05_Chromatic.webarchive -------------------------------------------------------------------------------- /Cookbook/Examples/E06_Shadow.fsh: -------------------------------------------------------------------------------- 1 | vec4 composite(vec4 over, vec4 under){ 2 | return over + (1.0 - over.a)*under; 3 | } 4 | 5 | void main(){ 6 | vec4 textureColor = cc_FragColor*texture2D(cc_MainTexture, cc_FragTexCoord1); 7 | 8 | // Offset of the shadow in texture coordinates. 9 | vec2 shadowOffset = vec2(-0.03, -0.03); 10 | float shadowMask = texture2D(cc_MainTexture, cc_FragTexCoord1 + shadowOffset).a; 11 | 12 | const float shadowOpacity = 0.5; 13 | vec4 shadowColor = vec4(vec3(0.0), shadowMask*shadowOpacity); 14 | 15 | gl_FragColor = composite(textureColor, shadowColor); 16 | } 17 | -------------------------------------------------------------------------------- /Cookbook/Examples/E06_Shadow.m: -------------------------------------------------------------------------------- 1 | #import "ExampleBase.h" 2 | 3 | 4 | #define EXAMPLENAME E06_Shadow 5 | 6 | 7 | @interface EXAMPLENAME : ExampleBase @end 8 | @implementation EXAMPLENAME 9 | 10 | -(CCNode *)exampleContent 11 | { 12 | CCSprite *sprite = [CCSprite spriteWithImageNamed:@"Logo.png"]; 13 | sprite.shader = [CCShader shaderNamed:self.shaderName]; 14 | 15 | return sprite; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Cookbook/Examples/E06_Shadow.webarchive: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Examples/E06_Shadow.webarchive -------------------------------------------------------------------------------- /Cookbook/Examples/E07_Color Flash.webarchive: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Examples/E07_Color Flash.webarchive -------------------------------------------------------------------------------- /Cookbook/Examples/E07_ColorFlash.fsh: -------------------------------------------------------------------------------- 1 | uniform vec4 u_ColorFlash; 2 | 3 | void main(){ 4 | vec4 color = texture2D(cc_MainTexture, cc_FragTexCoord1); 5 | 6 | // Composite the flash color over the texture color. 7 | // mix() is a builtin GLSL function that does linear interpolation. 8 | color.rgb = mix(color.rgb, u_ColorFlash.rgb*color.a, u_ColorFlash.a); 9 | 10 | gl_FragColor = cc_FragColor*color; 11 | } 12 | -------------------------------------------------------------------------------- /Cookbook/Examples/E07_ColorFlash.m: -------------------------------------------------------------------------------- 1 | #import "ExampleBase.h" 2 | 3 | 4 | #define EXAMPLENAME E07_ColorFlash 5 | 6 | 7 | @interface EXAMPLENAME : ExampleBase @end 8 | @implementation EXAMPLENAME 9 | 10 | -(CCNode *)exampleContent 11 | { 12 | CCSprite *sprite = [CCSprite spriteWithImageNamed:@"Logo.png"]; 13 | sprite.shader = [CCShader shaderNamed:self.shaderName]; 14 | 15 | ColorSlider *flashSlider = [ColorSlider sliderNamed:@"Flash Color"]; 16 | flashSlider.startColor = [CCColor colorWithRed:1 green:0 blue:0 alpha:0]; 17 | flashSlider.endColor = [CCColor redColor]; 18 | flashSlider.colorBlock = ^(CCColor *color){sprite.shaderUniforms[@"u_ColorFlash"] = color;}; 19 | 20 | ColorSlider *tintSlider = [ColorSlider sliderNamed:@"Tint Color"]; 21 | tintSlider.endColor = [CCColor colorWithRed:1 green:1 blue:1 alpha:0]; 22 | tintSlider.colorBlock = ^(CCColor *color){sprite.colorRGBA = color;}; 23 | 24 | CCLayoutBox *content = [CCLayoutBox node]; 25 | content.anchorPoint = ccp(0.5, 0.5); 26 | content.direction = CCLayoutBoxDirectionVertical; 27 | 28 | [content addChild:tintSlider]; 29 | [content addChild:flashSlider]; 30 | [content addChild:sprite]; 31 | 32 | return content; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Cookbook/Examples/E08_Outline.fsh: -------------------------------------------------------------------------------- 1 | const int SAMPLES = 6; 2 | varying vec2 v_OutlineSamples[SAMPLES]; 3 | 4 | vec4 composite(vec4 over, vec4 under){ 5 | return over + (1.0 - over.a)*under; 6 | } 7 | 8 | void main(){ 9 | // Use the coordinates from the v_OutlineSamples[] array. 10 | float outlineAlpha = 0.0; 11 | for(int i=0; i 2 | 3 | 4 | 5 | angle 6 | 90 7 | angleVariance 8 | 360 9 | blendFuncDestination 10 | 771 11 | blendFuncSource 12 | 1 13 | duration 14 | -1 15 | emitterType 16 | 0.0 17 | finishColorAlpha 18 | 0.0 19 | finishColorBlue 20 | 1 21 | finishColorGreen 22 | 1 23 | finishColorRed 24 | 1 25 | finishColorVarianceAlpha 26 | 0.0 27 | finishColorVarianceBlue 28 | 0.0 29 | finishColorVarianceGreen 30 | 0.0 31 | finishColorVarianceRed 32 | 0.0 33 | finishParticleSize 34 | 71 35 | finishParticleSizeVariance 36 | 0.0 37 | gravityx 38 | 0.0 39 | gravityy 40 | -20 41 | maxParticles 42 | 200 43 | maxRadius 44 | 276.20999145507812 45 | maxRadiusVariance 46 | 154.94999694824219 47 | minRadius 48 | 0.0 49 | particleLifespan 50 | 4 51 | particleLifespanVariance 52 | 1 53 | radialAccelVariance 54 | 18 55 | radialAcceleration 56 | -16 57 | rotatePerSecond 58 | 35.529998779296875 59 | rotatePerSecondVariance 60 | 0.0 61 | rotationEnd 62 | 0.0 63 | rotationEndVariance 64 | 0.0 65 | rotationStart 66 | 0.0 67 | rotationStartVariance 68 | 0.0 69 | sourcePositionVariancex 70 | 0.0 71 | sourcePositionVariancey 72 | 0.0 73 | sourcePositionx 74 | 169.30743408203125 75 | sourcePositiony 76 | 261.10903930664062 77 | speed 78 | 19 79 | speedVariance 80 | 28 81 | startColorAlpha 82 | 1 83 | startColorBlue 84 | 1 85 | startColorGreen 86 | 1 87 | startColorRed 88 | 1 89 | startColorVarianceAlpha 90 | 0.0 91 | startColorVarianceBlue 92 | 0.0 93 | startColorVarianceGreen 94 | 0.0 95 | startColorVarianceRed 96 | 0.0 97 | startParticleSize 98 | 78 99 | startParticleSizeVariance 100 | 10 101 | tangentialAccelVariance 102 | 44 103 | tangentialAcceleration 104 | 0.0 105 | textureFileName 106 | particleTexture.png 107 | textureImageData 108 | H4sIAAAAAAAAAwFmA5n8iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAADLUlEQVRYCcXX51JbQRCEUeOc/f6v6ZzxHKFPLAoI84epmrp7985294QVxcXl5eWjh7Sn9yB/MWcej19sXQb87/iP8f+yiztWAOmzcYL5k/F9AX9m7/fWf83zTmLOVeD5AHECWieiKpR95D8nlhPcepbH7TYBL+dI/mrWRCRkrQIBZY9Q5vzb+PdxQj2P2ikBCPnrxb0TRMQpAYiRIa9lVcregR0TgATZm/G3W7cmxn5VaA6qQNkjEkNAMbPcDOpBJfYF6DMByJC/H3+3XSfC97IziATov8FD8HUcDmzZs+bETSF0Z+cEICeCE0TYOQFlHznSZoTQkwIc5PW+FqwC7NUGVagCXTvlXzNHXnXE5LsrulYAYFduX4Ts11b4LlaWlbXBWzNH2GxojzN4jgogJgENYreganyYGELsq1YCAOp9CZX5eivEwy9mltcvPvqwirBHSGKIQE6Eitg35forO5mxSo5cDJyVHIf3TRVSIxNgiUgIUO5Abel2qII4hLJnSk5M7XC2rMPGU5s2APO++11PiKBVUECEyAq5athHyvS6TO2vhOHB72/ILK+VtHnb0+EEAkeiLZGV2UpyG94cvRbgh+KcGyzenZb5l3FPbbBfzDks3zcmE9aBCIBF1FCt16meO98M6L3BEpeohIUHP65ZXvXJM2IH8oCAATZYiJWc+a7swJF/HvddnHjnuLgwE4RvY1XAAVMuwAHvHPA61cUDNnD6DUws8k/j2kJEZ8NahdjbWIBeVvJIgSISh4yJ8931SgBwpMhVwtPZKiIeaSJmeWWrgMolENh6pSKXrTjftcKU66m9ziViFSI+AWJ3tgoQADTwrtdKLvvinE2AfcAylTXyj9tn1UiE8ztbBdhUIiD2u9ez3PS5LP0QJe6UgKpgJhpOuPBv2DEBMubAmbI3H0BqDYEJcBOAy06mqpCI/xIw5zYViFx/gZc98IZyX0DtITIR+4M4n27afgX6CgB52dffsq9FawWqkipUCWLyWR7aKQEiHVwFuHbrX7batApNRO3wPOj77O3swf8zuquAneJZaEPZ14KqcOOKrYdOre8j4BTWvfZl8qD2D7ghcomuE8XXAAAAAElFTkSuQmCCksg8PmYDAAA= 109 | 110 | 111 | -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon-120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon-120.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon-72.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon-72@2x.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon-76.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon-76@2x.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon-Small-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon-Small-50.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon-Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon-Small.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon-Small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon-Small@2x.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon-Spotlight-iOS7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon-Spotlight-iOS7.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon-Spotlight-iOS7@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon-Spotlight-iOS7@2x.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon-iPad-Spotlight-iOS7@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon-iPad-Spotlight-iOS7@2x.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon.png -------------------------------------------------------------------------------- /Cookbook/Resources/Icons/Icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Icons/Icon@2x.png -------------------------------------------------------------------------------- /Cookbook/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIconFiles 14 | 15 | Icon.png 16 | Icon@2x.png 17 | Icon-72.png 18 | Icon-72@2x.png 19 | Icon-76.png 20 | Icon-76@2x.png 21 | Icon-120.png 22 | Icon-iPad-Spotlight-iOS7@2x.png 23 | Icon-Small-50.png 24 | Icon-Small.png 25 | Icon-Small@2x.png 26 | Icon-Spotlight-iOS7.png 27 | Icon-Spotlight-iOS7@2x.png 28 | 29 | CFBundleIdentifier 30 | org.cocos2d-iphone.${PRODUCT_NAME:rfc1034identifier} 31 | CFBundleInfoDictionaryVersion 32 | 6.0 33 | CFBundleName 34 | ${PRODUCT_NAME} 35 | CFBundlePackageType 36 | APPL 37 | CFBundleSignature 38 | ???? 39 | CFBundleVersion 40 | 1.0 41 | LSRequiresIPhoneOS 42 | 43 | UIPrerenderedIcon 44 | 45 | UIRequiredDeviceCapabilities 46 | 47 | accelerometer 48 | 49 | opengles-2 50 | 51 | 52 | UIStatusBarHidden 53 | 54 | UISupportedInterfaceOrientations 55 | 56 | UIInterfaceOrientationPortrait 57 | 58 | UISupportedInterfaceOrientations~ipad 59 | 60 | UIInterfaceOrientationPortrait 61 | 62 | UIViewControllerBasedStatusBarAppearance 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /Cookbook/Resources/Interface-hd.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | frames 6 | 7 | Interface/btn-back.png 8 | 9 | frame 10 | {{19, 1}, {13, 21}} 11 | offset 12 | {0, 0} 13 | rotated 14 | 15 | sourceColorRect 16 | {{9, 6}, {13, 21}} 17 | sourceSize 18 | {32, 32} 19 | 20 | Interface/btn-next.png 21 | 22 | frame 23 | {{19, 16}, {15, 19}} 24 | offset 25 | {0, 0} 26 | rotated 27 | 28 | sourceColorRect 29 | {{8, 7}, {15, 19}} 30 | sourceSize 31 | {32, 32} 32 | 33 | Interface/btn-prev.png 34 | 35 | frame 36 | {{40, 23}, {14, 19}} 37 | offset 38 | {0, 0} 39 | rotated 40 | 41 | sourceColorRect 42 | {{9, 7}, {14, 19}} 43 | sourceSize 44 | {32, 32} 45 | 46 | Interface/btn-reload.png 47 | 48 | frame 49 | {{42, 1}, {20, 20}} 50 | offset 51 | {0, 0} 52 | rotated 53 | 54 | sourceColorRect 55 | {{6, 6}, {20, 20}} 56 | sourceSize 57 | {32, 32} 58 | 59 | Interface/header.png 60 | 61 | frame 62 | {{1, 1}, {16, 44}} 63 | offset 64 | {0, 0} 65 | rotated 66 | 67 | sourceColorRect 68 | {{0, 0}, {16, 44}} 69 | sourceSize 70 | {16, 44} 71 | 72 | Interface/table-bg-hilite.png 73 | 74 | frame 75 | {{39, 39}, {16, 16}} 76 | offset 77 | {0, 0} 78 | rotated 79 | 80 | sourceColorRect 81 | {{0, 0}, {16, 16}} 82 | sourceSize 83 | {16, 16} 84 | 85 | Interface/table-bg-normal.png 86 | 87 | frame 88 | {{1, 47}, {16, 16}} 89 | offset 90 | {0, 0} 91 | rotated 92 | 93 | sourceColorRect 94 | {{0, 0}, {16, 16}} 95 | sourceSize 96 | {16, 16} 97 | 98 | Interface/textfield-bg.png 99 | 100 | frame 101 | {{19, 33}, {18, 18}} 102 | offset 103 | {0, 0} 104 | rotated 105 | 106 | sourceColorRect 107 | {{1, 1}, {18, 18}} 108 | sourceSize 109 | {20, 20} 110 | 111 | 112 | metadata 113 | 114 | format 115 | 2 116 | size 117 | {64, 64} 118 | textureFileName 119 | Interface.png 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /Cookbook/Resources/Interface-hd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Interface-hd.png -------------------------------------------------------------------------------- /Cookbook/Resources/Interface-ipadhd.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | frames 6 | 7 | Interface/btn-back.png 8 | 9 | frame 10 | {{35, 1}, {24, 41}} 11 | offset 12 | {0, 0} 13 | rotated 14 | 15 | sourceColorRect 16 | {{20, 12}, {24, 41}} 17 | sourceSize 18 | {64, 64} 19 | 20 | Interface/btn-next.png 21 | 22 | frame 23 | {{90, 1}, {27, 37}} 24 | offset 25 | {0, 0} 26 | rotated 27 | 28 | sourceColorRect 29 | {{18, 14}, {27, 37}} 30 | sourceSize 31 | {64, 64} 32 | 33 | Interface/btn-prev.png 34 | 35 | frame 36 | {{61, 1}, {27, 37}} 37 | offset 38 | {0, 0} 39 | rotated 40 | 41 | sourceColorRect 42 | {{18, 14}, {27, 37}} 43 | sourceSize 44 | {64, 64} 45 | 46 | Interface/btn-reload.png 47 | 48 | frame 49 | {{35, 44}, {38, 38}} 50 | offset 51 | {0, 0} 52 | rotated 53 | 54 | sourceColorRect 55 | {{13, 13}, {38, 38}} 56 | sourceSize 57 | {64, 64} 58 | 59 | Interface/header.png 60 | 61 | frame 62 | {{1, 1}, {32, 88}} 63 | offset 64 | {0, 0} 65 | rotated 66 | 67 | sourceColorRect 68 | {{0, 0}, {32, 88}} 69 | sourceSize 70 | {32, 88} 71 | 72 | Interface/table-bg-hilite.png 73 | 74 | frame 75 | {{39, 84}, {32, 32}} 76 | offset 77 | {0, 0} 78 | rotated 79 | 80 | sourceColorRect 81 | {{0, 0}, {32, 32}} 82 | sourceSize 83 | {32, 32} 84 | 85 | Interface/table-bg-normal.png 86 | 87 | frame 88 | {{90, 30}, {32, 32}} 89 | offset 90 | {0, 0} 91 | rotated 92 | 93 | sourceColorRect 94 | {{0, 0}, {32, 32}} 95 | sourceSize 96 | {32, 32} 97 | 98 | Interface/textfield-bg.png 99 | 100 | frame 101 | {{1, 91}, {36, 36}} 102 | offset 103 | {0, 0} 104 | rotated 105 | 106 | sourceColorRect 107 | {{2, 2}, {36, 36}} 108 | sourceSize 109 | {40, 40} 110 | 111 | 112 | metadata 113 | 114 | format 115 | 2 116 | size 117 | {128, 128} 118 | textureFileName 119 | Interface.png 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /Cookbook/Resources/Interface-ipadhd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Interface-ipadhd.png -------------------------------------------------------------------------------- /Cookbook/Resources/Logo-hd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Logo-hd.png -------------------------------------------------------------------------------- /Cookbook/Resources/Logo-ipadhd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Logo-ipadhd.png -------------------------------------------------------------------------------- /Cookbook/Resources/Rocks-hd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Rocks-hd.png -------------------------------------------------------------------------------- /Cookbook/Resources/Rocks-ipadhd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/Rocks-ipadhd.png -------------------------------------------------------------------------------- /Cookbook/Resources/gaussianNoise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/gaussianNoise.png -------------------------------------------------------------------------------- /Cookbook/Resources/slider-background-hd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/slider-background-hd.png -------------------------------------------------------------------------------- /Cookbook/Resources/slider-background-ipadhd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/slider-background-ipadhd.png -------------------------------------------------------------------------------- /Cookbook/Resources/slider-handle-hd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/slider-handle-hd.png -------------------------------------------------------------------------------- /Cookbook/Resources/slider-handle-ipadhd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/slembcke/Cocos2DShaderCookbook/9bdc87b341fcf229b7c9aecc2c4891a5770732aa/Cookbook/Resources/slider-handle-ipadhd.png -------------------------------------------------------------------------------- /Cookbook/Supporting Files/Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Test' target in the 'Test' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /Cookbook/Supporting Files/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Shaders4Cocos2D 4 | // 5 | // Created by Scott Lembcke on 5/6/14. 6 | // Copyright Cocos2D-iPhone 2014. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | @autoreleasepool { 14 | int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate"); 15 | return retVal; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Scott Lembcke 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cocos2DShaderCookbook 2 | 3 | Cocos2D v3.1 includes a new rendering engine with vastly improved support for shaders. This project is intended as both a beginner introduction to writing shaders for Cocos2D as well as a "cook book" of ideas to make your own. 4 | 5 | You'll want to perform a recursive checkout of the project since the project has a submodule for Cocos2D. Change directory (cd) to your project directory and then perform a recursive checkout. The GitHub for Mac client might do this part for you, I'm not sure. The CLI tools do not. 6 | 7 | cd myProjectsDirectory/orWhatever 8 | git clone --recursive https://github.com/slembcke/Cocos2DShaderCookbook.git 9 | 10 | Then you'll have a nice fresh checkout named Cocos2DShaderCookbook in the current directory. 11 | 12 | Each of the examples is fairly self contained and includes an explanation to go along with the code. If you've never written a shader before, you'll want to start at the beginning since the explanations are meant to be read in order. 13 | 14 | ![example](http://files.slembcke.net/upshot/upshot_u6k2m0Ko.png) 15 | 16 | Good luck! 17 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | * Tableview of examples 2 | 3 | Example ideas: 4 | * Color replacement 5 | * Normal mapped lighting 6 | * CLUT 7 | * Scanlines 8 | --------------------------------------------------------------------------------