├── .gitignore ├── .vscode └── settings.json ├── README.md ├── assets ├── Scene.meta ├── Scene │ ├── AmazingEffects.meta │ ├── AmazingEffects │ │ ├── AmazingColors.fire │ │ ├── AmazingColors.fire.meta │ │ ├── Clouds2d.fire │ │ ├── Clouds2d.fire.meta │ │ ├── Clover.fire │ │ ├── Clover.fire.meta │ │ ├── ColorCircle.fire │ │ ├── ColorCircle.fire.meta │ │ ├── ColorLights.fire │ │ ├── ColorLights.fire.meta │ │ ├── FlameEffect.fire │ │ ├── FlameEffect.fire.meta │ │ ├── GlowCircle.fire │ │ ├── GlowCircle.fire.meta │ │ ├── Grassy.fire │ │ ├── Grassy.fire.meta │ │ ├── Heart.fire │ │ ├── Heart.fire.meta │ │ ├── LightCircle.fire │ │ ├── LightCircle.fire.meta │ │ ├── LightRun.fire │ │ ├── LightRun.fire.meta │ │ ├── Lightnets.fire │ │ ├── Lightnets.fire.meta │ │ ├── Obsession.fire │ │ ├── Obsession.fire.meta │ │ ├── Raymarching.fire │ │ ├── Raymarching.fire.meta │ │ ├── RedCircle.fire │ │ ├── RedCircle.fire.meta │ │ ├── StarBackground.fire │ │ ├── StarBackground.fire.meta │ │ ├── SuperMario.fire │ │ ├── SuperMario.fire.meta │ │ ├── SwirlingDots.fire │ │ ├── SwirlingDots.fire.meta │ │ ├── Tweaked.fire │ │ ├── Tweaked.fire.meta │ │ ├── ValentineDay.fire │ │ ├── ValentineDay.fire.meta │ │ ├── deformflower.fire │ │ └── deformflower.fire.meta │ ├── Blackhole.fire │ ├── Blackhole.fire.meta │ ├── Candle.fire │ ├── Candle.fire.meta │ ├── OldEffects.meta │ ├── OldEffects │ │ ├── CircleOutline.fire │ │ ├── CircleOutline.fire.meta │ │ ├── CirclePortrail.fire │ │ ├── CirclePortrail.fire.meta │ │ ├── DissolveEffect.fire │ │ ├── DissolveEffect.fire.meta │ │ ├── FluxayEffect.fire │ │ ├── FluxayEffect.fire.meta │ │ ├── GaussBlurs.fire │ │ ├── GaussBlurs.fire.meta │ │ ├── GrayEffect.fire │ │ ├── GrayEffect.fire.meta │ │ ├── GrowBloom.fire │ │ ├── GrowBloom.fire.meta │ │ ├── SearchLight.fire │ │ ├── SearchLight.fire.meta │ │ ├── TransferEffect.fire │ │ ├── TransferEffect.fire.meta │ │ ├── TurnPage.fire │ │ ├── TurnPage.fire.meta │ │ ├── WaterWave.fire │ │ └── WaterWave.fire.meta │ ├── StartScene.fire │ └── StartScene.fire.meta ├── Script.meta ├── Script │ ├── CirclePortraitEffect.ts │ ├── CirclePortraitEffect.ts.meta │ ├── CirclePortraitFrag.ts │ ├── CirclePortraitFrag.ts.meta │ ├── DissolveEffect.ts │ ├── DissolveEffect.ts.meta │ ├── DissolveFrag.ts │ ├── DissolveFrag.ts.meta │ ├── EffectManager.ts │ ├── EffectManager.ts.meta │ ├── FluxayEffect.ts │ ├── FluxayEffect.ts.meta │ ├── FluxayFrag.ts │ ├── FluxayFrag.ts.meta │ ├── GaussBlurEffect.ts │ ├── GaussBlurEffect.ts.meta │ ├── GaussBlursFrag.ts │ ├── GaussBlursFrag.ts.meta │ ├── GrayEffect.ts │ ├── GrayEffect.ts.meta │ ├── GrayFrag.ts │ ├── GrayFrag.ts.meta │ ├── Menu.ts │ ├── Menu.ts.meta │ ├── SearchLightEffect.ts │ ├── SearchLightEffect.ts.meta │ ├── SearchLightFrag.ts │ ├── SearchLightFrag.ts.meta │ ├── TransferEffect.ts │ ├── TransferEffect.ts.meta │ ├── TransferFrag.ts │ ├── TransferFrag.ts.meta │ ├── TurnPageEffect.ts │ ├── TurnPageEffect.ts.meta │ ├── TurnPageFrag.ts │ ├── TurnPageFrag.ts.meta │ ├── WaterWaveEffect.ts │ ├── WaterWaveEffect.ts.meta │ ├── WaterWaveFrag.ts │ ├── WaterWaveFrag.ts.meta │ ├── shader.meta │ └── shader │ │ ├── MaterialComponent.ts │ │ ├── MaterialComponent.ts.meta │ │ ├── MaterialManager.ts │ │ ├── MaterialManager.ts.meta │ │ ├── MaterialSingleton.ts │ │ ├── MaterialSingleton.ts.meta │ │ ├── ShaderFSH.ts │ │ ├── ShaderFSH.ts.meta │ │ ├── ShaderLab.ts │ │ └── ShaderLab.ts.meta ├── Texture.meta ├── Texture │ ├── angel.png │ ├── angel.png.meta │ ├── button_green.png │ ├── button_green.png.meta │ ├── danila.png │ ├── danila.png.meta │ ├── dragon_nest.png │ ├── dragon_nest.png.meta │ ├── feofox logo.png │ ├── feofox logo.png.meta │ ├── game_bg.jpg │ ├── game_bg.jpg.meta │ ├── monster.jpg │ ├── monster.jpg.meta │ ├── noise.png │ ├── noise.png.meta │ ├── noise1.png │ ├── noise1.png.meta │ ├── panel_bg.png │ ├── panel_bg.png.meta │ ├── singleColor.png │ ├── singleColor.png.meta │ ├── startbg.jpg │ ├── startbg.jpg.meta │ ├── sunwukong.png │ ├── sunwukong.png.meta │ ├── tiger.jpg │ ├── tiger.jpg.meta │ ├── wcard.png │ └── wcard.png.meta ├── prefabs.meta ├── prefabs │ ├── Background.prefab │ ├── Background.prefab.meta │ ├── obsession.prefab │ └── obsession.prefab.meta ├── resources.meta └── resources │ ├── HeroSelect.mp3 │ ├── HeroSelect.mp3.meta │ ├── ValentineDay.glsl │ ├── ValentineDay.glsl.meta │ ├── amazingstar.glsl │ ├── amazingstar.glsl.meta │ ├── cameraobsession.glsl │ ├── cameraobsession.glsl.meta │ ├── circleoutline.glsl │ ├── circleoutline.glsl.meta │ ├── clouds2d.glsl │ ├── clouds2d.glsl.meta │ ├── clover.glsl │ ├── clover.glsl.meta │ ├── colorcircle.glsl │ ├── colorcircle.glsl.meta │ ├── colorclock.glsl │ ├── colorclock.glsl.meta │ ├── colorlights.glsl │ ├── colorlights.glsl.meta │ ├── deformflower.glsl │ ├── deformflower.glsl.meta │ ├── demo4.glsl │ ├── demo4.glsl.meta │ ├── demo5.glsl │ ├── demo5.glsl.meta │ ├── demo6.glsl │ ├── demo6.glsl.meta │ ├── dragon_nest.png │ ├── dragon_nest.png.meta │ ├── feofox.png │ ├── feofox.png.meta │ ├── flame.glsl │ ├── flame.glsl.meta │ ├── fluxay.glsl │ ├── fluxay.glsl.meta │ ├── galaxy.mp3 │ ├── galaxy.mp3.meta │ ├── game_bg.jpg │ ├── game_bg.jpg.meta │ ├── glowbloom.glsl │ ├── glowbloom.glsl.meta │ ├── glowcircle.glsl │ ├── glowcircle.glsl.meta │ ├── glowing.glsl │ ├── glowing.glsl.meta │ ├── grassy.glsl │ ├── grassy.glsl.meta │ ├── heart.glsl │ ├── heart.glsl.meta │ ├── lightcircle.glsl │ ├── lightcircle.glsl.meta │ ├── lightnets.glsl │ ├── lightnets.glsl.meta │ ├── lightrun.glsl │ ├── lightrun.glsl.meta │ ├── metaballs.glsl │ ├── metaballs.glsl.meta │ ├── noise.png │ ├── noise.png.meta │ ├── noisetexture.png │ ├── noisetexture.png.meta │ ├── raymarching.glsl │ ├── raymarching.glsl.meta │ ├── readme.meta │ ├── readme │ ├── DissolveEffect.md │ ├── DissolveEffect.md.meta │ ├── FluxayEffect.md │ ├── FluxayEffect.md.meta │ ├── GaussBlurs.md │ ├── GaussBlurs.md.meta │ ├── GrayEffect.md │ ├── GrayEffect.md.meta │ ├── SearchLight.md │ ├── SearchLight.md.meta │ ├── StartScene.md │ ├── StartScene.md.meta │ ├── TransferEffect.md │ ├── TransferEffect.md.meta │ ├── WaterWave.md │ └── WaterWave.md.meta │ ├── redcircle.glsl │ ├── redcircle.glsl.meta │ ├── refractive.glsl │ ├── refractive.glsl.meta │ ├── searchlight.glsl │ ├── searchlight.glsl.meta │ ├── shaders.meta │ ├── shaders │ ├── CircularEffect.glsl │ ├── CircularEffect.glsl.meta │ ├── blurs.glsl │ ├── blurs.glsl.meta │ ├── demo.glsl │ ├── demo.glsl.meta │ ├── dissolve.glsl │ ├── dissolve.glsl.meta │ ├── frozenland.glsl │ ├── frozenland.glsl.meta │ ├── outline.glsl │ ├── outline.glsl.meta │ ├── pageturning.glsl │ ├── pageturning.glsl.meta │ ├── plasma.glsl │ ├── plasma.glsl.meta │ ├── raymarching.glsl │ ├── raymarching.glsl.meta │ ├── starbackground.glsl │ ├── starbackground.glsl.meta │ ├── supermario.glsl │ └── supermario.glsl.meta │ ├── simplicityGalaxy.glsl │ ├── simplicityGalaxy.glsl.meta │ ├── spectrum.glsl │ ├── spectrum.glsl.meta │ ├── starbackground.glsl │ ├── starbackground.glsl.meta │ ├── startbg.jpg │ ├── startbg.jpg.meta │ ├── supermario.glsl │ ├── supermario.glsl.meta │ ├── swirlingdots.glsl │ ├── swirlingdots.glsl.meta │ ├── turbulence.glsl │ ├── turbulence.glsl.meta │ ├── turnpage.glsl │ ├── turnpage.glsl.meta │ ├── tweaked.glsl │ ├── tweaked.glsl.meta │ ├── water.glsl │ ├── water.glsl.meta │ ├── wave.glsl │ └── wave.glsl.meta ├── creator.d.ts ├── jsconfig.json ├── project.json ├── screenshots ├── amcolors.gif ├── clouds.gif ├── clover.gif ├── colorcircle.gif ├── colorlights.gif ├── cover.gif ├── deformflower.gif ├── dissolve.gif ├── fish.gif ├── flame.gif ├── fluxay.gif ├── gauss.gif ├── glowcircle.gif ├── grassy.gif ├── gray.gif ├── heart.gif ├── lightcircle.gif ├── lightnets.gif ├── lightrun.gif ├── obsession.gif ├── qqgroup.JPG ├── redcircle.gif ├── search.gif ├── starbackground.gif ├── supermario.gif ├── swirlingdots.gif ├── transfer.gif ├── tweaked.gif ├── valentineday.gif └── water.gif ├── settings ├── builder.json ├── builder.panel.json ├── project.json └── services.json ├── template.json └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | #///////////////////////////////////////////////////////////////////////////// 2 | # Fireball Projects 3 | #///////////////////////////////////////////////////////////////////////////// 4 | 5 | library/ 6 | temp/ 7 | local/ 8 | build/ 9 | 10 | #///////////////////////////////////////////////////////////////////////////// 11 | # Logs and databases 12 | #///////////////////////////////////////////////////////////////////////////// 13 | 14 | *.log 15 | *.sql 16 | *.sqlite 17 | 18 | #///////////////////////////////////////////////////////////////////////////// 19 | # files for debugger 20 | #///////////////////////////////////////////////////////////////////////////// 21 | 22 | *.sln 23 | *.csproj 24 | *.pidb 25 | *.unityproj 26 | *.suo 27 | 28 | #///////////////////////////////////////////////////////////////////////////// 29 | # OS generated files 30 | #///////////////////////////////////////////////////////////////////////////// 31 | 32 | .DS_Store 33 | ehthumbs.db 34 | Thumbs.db 35 | 36 | #///////////////////////////////////////////////////////////////////////////// 37 | # exvim files 38 | #///////////////////////////////////////////////////////////////////////////// 39 | 40 | *UnityVS.meta 41 | *.err 42 | *.err.meta 43 | *.exvim 44 | *.exvim.meta 45 | *.vimentry 46 | *.vimentry.meta 47 | *.vimproject 48 | *.vimproject.meta 49 | .vimfiles.*/ 50 | .exvim.*/ 51 | quick_gen_project_*_autogen.bat 52 | quick_gen_project_*_autogen.bat.meta 53 | quick_gen_project_*_autogen.sh 54 | quick_gen_project_*_autogen.sh.meta 55 | .exvim.app 56 | 57 | #///////////////////////////////////////////////////////////////////////////// 58 | # webstorm files 59 | #///////////////////////////////////////////// 60 | 61 | .idea/ 62 | 63 | #////////////////////////// 64 | # VS Code 65 | .vscode 66 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "shader-toy.useInShaderTextures":false, 3 | "shader-toy.textures": { 4 | "0": "file://./assets/resources/startbg.jpg", 5 | "1": "file://./assets/resources/game_bg.jpg", 6 | "2": "file://./assets/resources/noise.png", 7 | } 8 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cocos Creator 2.x自定义Shader框架 2 | *Author:大掌教*
3 | 4 | #### 这是目前 Cocos Creator 最好的自定义Shader框架。 5 | 6 | 是的,你没有看错,是最好的,没有之一! 7 | 8 |
9 | 10 |
11 | 12 | 13 | ----- 14 | 15 | ### 2.0.10新版本特性 16 | - 新增封面和BGM,特别适合在晚上夜深人静的时候研究 **shader**,根本停不下来 17 | - 新增常用**Shader**特效,无脑傻瓜式挂到节点就可使用 18 | - 其他有趣的玩具,玩通宵没问题 19 | 20 | 我将自定义材质和渲染组件做了封装,可以参考也可以自己改 21 | 22 | 如果要自定义shader,只需要按照GLSL写片段shader即可,然后加入到 **ShaderFSH**中,枚举类型加入名称 23 | 24 | 25 | ## 更多学习交流,请关注我的微信公众号,有关注不迷路 26 | 27 | 28 | #### 直接搜索公众号ID:darkpalm 29 | #### 或者掏出手机扫码: 30 | 31 |
32 | 33 |
34 | 35 | 36 | 37 | ##### github地址: [https://github.com/fylz1125/ShaderDemos](https://github.com/fylz1125/ShaderDemos) 38 | 39 | ##### 码云地址: [https://gitee.com/darkmoon/ShaderDemos](https://gitee.com/darkmoon/ShaderDemos) 40 | 41 | > 大游戏交流Q群:704391772 42 | ![Q群704391772](screenshots/qqgroup.JPG) 43 | 44 | -------------------------------------------------------------------------------- /assets/Scene.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "5eba2e7c-508c-4dd6-b2fd-25fdc5cce25a", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/AmazingColors.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "fb125b23-5653-4a07-a351-1eb26ea1c492", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/Clouds2d.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "26d2378f-e2a6-401a-b835-843df9751be2", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/Clover.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "4536e215-9540-42f8-a53e-0b3bf5f93179", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/ColorCircle.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "c7d5be04-3371-4f0a-9b8c-6efcfb3396a0", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/ColorLights.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "dffc72c0-ef49-4b0a-be99-d32ff5ee2ea8", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/FlameEffect.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "b76fa66f-39b9-4b98-998e-e311581329bd", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/GlowCircle.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "e32fe489-dea4-48b3-8a15-8b59b51a0d47", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/Grassy.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "fd70c04f-a202-4d79-a424-75a5c47b6778", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/Heart.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "c5dad1a5-8b41-4493-bf0b-389479329535", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/LightCircle.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "f82e02cf-4546-46b2-b806-9c7db79a44e3", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/LightRun.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "87a8b667-d74f-4efb-a1ca-124dda5ddd38", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/Lightnets.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "3966637a-44e1-4f94-964f-40a8800fb421", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/Obsession.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "41ffd677-0818-4ba8-b0c8-c159cb41a44b", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/Raymarching.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "2e8944c6-a180-4686-93cc-783cd19c4ae3", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/RedCircle.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "32960284-4d11-4525-960d-9aa6ab2ae4b9", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/StarBackground.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "ce252c46-5566-4c54-936f-38756e38ede7", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/SuperMario.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "71213950-3d5c-45fe-b7ac-aabb9580c973", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/SwirlingDots.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "e26d539c-10ec-4d90-8da6-adaa204665f2", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/Tweaked.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "59c691cc-2374-4105-bb0a-9c082a60022f", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/ValentineDay.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "a3d8ea00-4039-4fd0-9bb5-bf0025ba8e19", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/AmazingEffects/deformflower.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "8b0d5486-1bc9-4407-a564-33cfb33977f8", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/Blackhole.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "51e8aaab-b431-404d-8015-69d2f86d91d8", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/Candle.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "4e84f819-5ad9-41f5-8721-91b305e8a7af", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "1c0d23e7-0c92-4044-b632-0a7849c3f567", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects/CircleOutline.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "ffb10ca1-143e-4b75-9bcd-820debc64d99", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects/CirclePortrail.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "420da1d9-6987-4c88-8475-94fe0b110240", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects/DissolveEffect.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "8125d857-94ca-4ff1-9e0e-3cb47ad8613c", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects/FluxayEffect.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "86d055c9-654e-4242-b412-6570a2d37636", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects/GaussBlurs.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "f5c1a172-dc00-4e9d-9682-95ccb1fbf199", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects/GrayEffect.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "dabeb8c3-e5de-4f03-92dd-452e6f3ce745", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects/GrowBloom.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "2ccc48ba-1d67-4b31-82bd-b551dbe7ef1c", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects/SearchLight.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "8edf28c0-d985-445a-81aa-195911e32ca8", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects/TransferEffect.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects/TurnPage.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "6f926c95-be14-4f14-a33c-38879f6f2f74", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/OldEffects/WaterWave.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "87c9cdc7-eb22-4917-b695-c64dc591f90e", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Scene/StartScene.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "a0adad71-2d3c-4fff-93bf-a2a5baeeca9e", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Script.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Script/CirclePortraitEffect.ts: -------------------------------------------------------------------------------- 1 | import CirclePortrait from './CirclePortraitFrag'; 2 | 3 | const {ccclass, property} = cc._decorator; 4 | 5 | @ccclass 6 | export default class NewClass extends cc.Component { 7 | 8 | @property(cc.Slider) 9 | cornerSlider: cc.Slider = null; 10 | 11 | program: cc.GLProgram; 12 | edge = 0.05; 13 | 14 | onLoad() { 15 | this.edge = this.cornerSlider.progress / 2; 16 | this.makeCircle(); 17 | } 18 | 19 | start () { 20 | 21 | } 22 | 23 | makeCircle() { 24 | if (this.program) return; 25 | this.program = new cc.GLProgram(); 26 | if (cc.sys.isNative) { 27 | this.program.initWithString(CirclePortrait.circle_vert, CirclePortrait.circle_frag); 28 | } else { 29 | this.program.initWithVertexShaderByteArray(CirclePortrait.circle_vert, CirclePortrait.circle_frag); 30 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); 31 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); 32 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); 33 | } 34 | this.program.link(); 35 | this.program.updateUniforms(); 36 | this.program.use(); 37 | 38 | if (cc.sys.isNative) { 39 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 40 | glProgram_state.setUniformFloat('u_edge', this.edge); 41 | } else { 42 | let ed = this.program.getUniformLocationForName( "u_edge" ); 43 | this.program.setUniformLocationWith1f(ed, this.edge ); 44 | } 45 | this.setProgram(this.node.getComponent(cc.Sprite)._sgNode, this.program); 46 | } 47 | 48 | setProgram(node: any, program: any) { 49 | if (cc.sys.isNative) { 50 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(program); 51 | node.setGLProgramState(glProgram_state); 52 | } else { 53 | node.setShaderProgram(program); 54 | } 55 | } 56 | 57 | onSliderChange(slider: cc.Slider, eventType: any) { 58 | this.edge = Number((slider.progress / 2).toFixed(2)); 59 | if (!this.program) return; 60 | this.program.use(); 61 | if (cc.sys.isNative) { 62 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 63 | glProgram_state.setUniformFloat("u_edge", this.edge); 64 | } else { 65 | let ed = this.program.getUniformLocationForName("u_edge"); 66 | this.program.setUniformLocationWith1f(ed, this.edge); 67 | } 68 | 69 | } 70 | 71 | // update (dt) {} 72 | } 73 | -------------------------------------------------------------------------------- /assets/Script/CirclePortraitEffect.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "bf1181ed-19d0-427b-993d-ef758a96c203", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/CirclePortraitFrag.ts: -------------------------------------------------------------------------------- 1 | // Feofox Game 2 | // Author:Lerry 3 | // https://github.com/fylz1125/ShaderDemos 4 | export default class CircleFrag { 5 | static circle_vert = ` 6 | attribute vec4 a_position; 7 | attribute vec2 a_texCoord; 8 | attribute vec4 a_color; 9 | varying vec2 v_texCoord; 10 | varying vec4 v_fragmentColor; 11 | void main() 12 | { 13 | gl_Position = CC_PMatrix * a_position; 14 | v_fragmentColor = a_color; 15 | v_texCoord = a_texCoord; 16 | } 17 | `; 18 | static circle_frag = ` 19 | #ifdef GL_ES 20 | precision mediump float; 21 | #endif 22 | 23 | varying vec4 v_fragmentColor; 24 | varying vec2 v_texCoord; 25 | 26 | uniform float u_edge; 27 | uniform float u_offset; 28 | 29 | void main() 30 | { 31 | float edge = u_edge; 32 | float dis = 0.0; 33 | vec2 texCoord = v_texCoord; 34 | if ( texCoord.x < edge ) 35 | { 36 | if ( texCoord.y < edge ) 37 | { 38 | dis = distance( texCoord, vec2(edge, edge) ); 39 | } 40 | if ( texCoord.y > (1.0 - edge) ) 41 | { 42 | dis = distance( texCoord, vec2(edge, (1.0 - edge)) ); 43 | } 44 | } 45 | else if ( texCoord.x > (1.0 - edge) ) 46 | { 47 | if ( texCoord.y < edge ) 48 | { 49 | dis = distance( texCoord, vec2((1.0 - edge), edge ) ); 50 | } 51 | if ( texCoord.y > (1.0 - edge) ) 52 | { 53 | dis = distance( texCoord, vec2((1.0 - edge), (1.0 - edge) ) ); 54 | } 55 | } 56 | 57 | if(dis > 0.001) 58 | { 59 | // 外圈沟 60 | float gap = edge * 0.02; 61 | if(dis <= edge - gap) 62 | { 63 | gl_FragColor = texture2D( CC_Texture0,texCoord); 64 | } 65 | else if(dis <= edge) 66 | { 67 | // 平滑过渡 68 | float t = smoothstep(0.,gap,edge-dis); 69 | vec4 color = texture2D( CC_Texture0,texCoord); 70 | gl_FragColor = vec4(color.rgb,t); 71 | }else{ 72 | gl_FragColor = vec4(0.,0.,0.,0.); 73 | } 74 | } 75 | else 76 | { 77 | gl_FragColor = texture2D( CC_Texture0,texCoord); 78 | } 79 | } 80 | 81 | `; 82 | } -------------------------------------------------------------------------------- /assets/Script/CirclePortraitFrag.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "19c7692c-f4f0-482e-882a-ddfbc4a86e61", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/DissolveEffect.ts: -------------------------------------------------------------------------------- 1 | import DissolveFrag from './DissolveFrag'; 2 | const { ccclass, property } = cc._decorator; 3 | 4 | @ccclass 5 | export default class DissolveEffect extends cc.Component { 6 | 7 | @property(cc.SpriteFrame) 8 | noiseTexture: cc.SpriteFrame = null; 9 | 10 | program: cc.GLProgram; 11 | startTime:number = Date.now(); 12 | time: number = 0.; 13 | 14 | 15 | onLoad() { 16 | this.enabled = false; 17 | } 18 | 19 | useDissolve() { 20 | // 绑定噪音纹理 21 | let texture1 = this.noiseTexture.getTexture(); 22 | let gltext1 = texture1._glID; 23 | if (cc.sys.isNative) { 24 | } 25 | else { 26 | cc.gl.bindTexture2DN(1, texture1); 27 | } 28 | 29 | this.program = new cc.GLProgram(); 30 | if (cc.sys.isNative) { 31 | this.program.initWithString(DissolveFrag.vert, DissolveFrag.frag); 32 | } else { 33 | this.program.initWithVertexShaderByteArray(DissolveFrag.vert, DissolveFrag.frag); 34 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); 35 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); 36 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); 37 | } 38 | this.program.link(); 39 | this.program.updateUniforms(); 40 | this.program.use(); 41 | 42 | if (cc.sys.isNative) { 43 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 44 | glProgram_state.setUniformFloat("time", this.time); 45 | glProgram_state.setUniformTexture("texture1", gltext1); 46 | } else { 47 | let ba = this.program.getUniformLocationForName("time"); 48 | let text1 = this.program.getUniformLocationForName("texture1"); 49 | this.program.setUniformLocationWith1f(ba, this.time); 50 | this.program.setUniformLocationWith1i(text1, 1); 51 | } 52 | this.setProgram(this.node.getComponent(cc.Sprite)._sgNode, this.program); 53 | this.enabled = true; 54 | } 55 | 56 | setProgram(node: any, program: any) { 57 | if (cc.sys.isNative) { 58 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(program); 59 | node.setGLProgramState(glProgram_state); 60 | } else { 61 | node.setShaderProgram(program); 62 | } 63 | } 64 | 65 | update(dt) { 66 | // 溶解速度 67 | this.time += 0.008; 68 | if (this.program) { 69 | this.program.use(); 70 | if (cc.sys.isNative) { 71 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 72 | glProgram_state.setUniformFloat("time", this.time); 73 | } else { 74 | let ct = this.program.getUniformLocationForName("time"); 75 | this.program.setUniformLocationWith1f(ct, this.time); 76 | } 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /assets/Script/DissolveEffect.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "831c435e-ed37-4c69-82e8-e659e305df1e", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/DissolveFrag.ts: -------------------------------------------------------------------------------- 1 | export default class DissolveFrag { 2 | static vert =` 3 | attribute vec4 a_position; 4 | attribute vec2 a_texCoord; 5 | attribute vec4 a_color; 6 | varying vec2 v_texCoord; 7 | varying vec4 v_fragmentColor; 8 | void main() 9 | { 10 | gl_Position = CC_PMatrix * a_position; 11 | v_fragmentColor = a_color; 12 | v_texCoord = a_texCoord; 13 | } 14 | `; 15 | 16 | static frag=` 17 | #ifdef GL_ES 18 | precision lowp float; 19 | #endif 20 | 21 | uniform vec2 resolution; 22 | uniform float time; 23 | uniform sampler2D texture1; 24 | 25 | varying vec2 v_texCoord; 26 | varying vec4 v_fragmentColor; 27 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 28 | { 29 | // 纹理坐标 30 | vec2 uv = v_texCoord; 31 | // 法向纹理r通道 32 | float height = texture2D(texture1,uv).r; 33 | // 采样纹理 34 | vec4 color = v_fragmentColor * texture2D(CC_Texture0,uv); 35 | 36 | if(height < time) 37 | { 38 | discard; 39 | } 40 | 41 | if(height < time+0.04) 42 | { 43 | // 溶解颜色,可以自定义 44 | color = vec4(.9,.6,0.3,color.a); 45 | } 46 | 47 | fragColor = color; 48 | } 49 | 50 | void main() 51 | { 52 | mainImage(gl_FragColor, gl_FragCoord.xy); 53 | } 54 | `; 55 | } -------------------------------------------------------------------------------- /assets/Script/DissolveFrag.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "dca57953-9cd6-4077-b359-fd88c3370bff", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/EffectManager.ts: -------------------------------------------------------------------------------- 1 | const { ccclass, property } = cc._decorator; 2 | 3 | @ccclass 4 | export default class EffectManager extends cc.Component { 5 | 6 | @property 7 | fragShader: string = 'lightcircle'; 8 | 9 | default_vert = ` 10 | attribute vec4 a_position; 11 | attribute vec2 a_texCoord; 12 | attribute vec4 a_color; 13 | varying vec2 v_texCoord; 14 | varying vec4 v_fragmentColor; 15 | void main() 16 | { 17 | gl_Position = CC_PMatrix * a_position; 18 | v_fragmentColor = a_color; 19 | v_texCoord = a_texCoord; 20 | } 21 | `; 22 | 23 | program: cc.GLProgram; 24 | frag_glsl: string = ''; 25 | startTime:number = Date.now(); 26 | time: number = 0; 27 | resolution={ x:0.0, y:0.0}; 28 | // 初始化 29 | onLoad() { 30 | cc.director.setDisplayStats(true); 31 | this.resolution.x = (this.node.getContentSize().width ); 32 | this.resolution.y = (this.node.getContentSize().height); 33 | let self = this; 34 | cc.loader.loadRes(this.fragShader, function (err, data) { 35 | if (err) 36 | cc.log(err); 37 | else { 38 | self.frag_glsl = data; 39 | self.useShader(); 40 | } 41 | }); 42 | } 43 | 44 | useShader() { 45 | this.program = new cc.GLProgram(); 46 | if (cc.sys.isNative) { 47 | this.program.initWithString(this.default_vert, this.frag_glsl); 48 | } else { 49 | this.program.initWithVertexShaderByteArray(this.default_vert, this.frag_glsl); 50 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); 51 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); 52 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); 53 | } 54 | this.program.link(); 55 | this.program.updateUniforms(); 56 | this.program.use(); 57 | 58 | if (cc.sys.isNative) { 59 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 60 | glProgram_state.setUniformFloat("time", this.time); 61 | glProgram_state.setUniformVec2( "resolution", this.resolution ); 62 | } else { 63 | let ba = this.program.getUniformLocationForName("time"); 64 | let res = this.program.getUniformLocationForName( "resolution" ); 65 | this.program.setUniformLocationWith1f(ba, this.time); 66 | this.program.setUniformLocationWith2f( res, this.resolution.x,this.resolution.y ); 67 | } 68 | this.setProgram(this.node.getComponent(cc.Sprite)._sgNode, this.program); 69 | } 70 | 71 | setProgram(node: any, program: any) { 72 | if (cc.sys.isNative) { 73 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(program); 74 | node.setGLProgramState(glProgram_state); 75 | } else { 76 | node.setShaderProgram(program); 77 | } 78 | } 79 | 80 | updateParameters() { 81 | this.time = (Date.now() - this.startTime) / 1000; 82 | } 83 | // 每帧更新函数 84 | update(dt) { 85 | this.updateParameters(); 86 | if (this.program) { 87 | this.program.use(); 88 | if (cc.sys.isNative) { 89 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 90 | glProgram_state.setUniformFloat("time", this.time); 91 | } else { 92 | let ct = this.program.getUniformLocationForName("time"); 93 | this.program.setUniformLocationWith1f(ct, this.time); 94 | } 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /assets/Script/EffectManager.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "bd111ec5-ff67-4b1c-904f-1e32d3cdc52d", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/FluxayEffect.ts: -------------------------------------------------------------------------------- 1 | // Feofox Game 2 | // Author:Lerry 3 | // https://github.com/fylz1125/ShaderDemos 4 | import Fluxay from './FluxayFrag'; 5 | 6 | const {ccclass, property} = cc._decorator; 7 | 8 | @ccclass 9 | export default class FluxayEffect extends cc.Component { 10 | @property 11 | mode: number = 0; 12 | fragStr: string = null; 13 | program: cc.GLProgram; 14 | startTime:number = Date.now(); 15 | time: number = 0; 16 | 17 | 18 | onLoad() { 19 | if (this.mode == 0) { 20 | this.fragStr = Fluxay.fluxay_frag; 21 | } else { 22 | this.fragStr = Fluxay.fluxay_frag_super; 23 | } 24 | this.useWater(); 25 | } 26 | 27 | start() { 28 | } 29 | 30 | useWater() { 31 | this.program = new cc.GLProgram(); 32 | if (cc.sys.isNative) { 33 | this.program.initWithString(Fluxay.fluxay_vert, this.fragStr); 34 | } else { 35 | this.program.initWithVertexShaderByteArray(Fluxay.fluxay_vert, this.fragStr); 36 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); 37 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); 38 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); 39 | } 40 | this.program.link(); 41 | this.program.updateUniforms(); 42 | this.program.use(); 43 | 44 | if (cc.sys.isNative) { 45 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 46 | glProgram_state.setUniformFloat("time", this.time); 47 | } else { 48 | let ba = this.program.getUniformLocationForName("time"); 49 | this.program.setUniformLocationWith1f(ba, this.time); 50 | } 51 | this.setProgram(this.node.getComponent(cc.Sprite)._sgNode, this.program); 52 | } 53 | 54 | setProgram(node: any, program: any) { 55 | if (cc.sys.isNative) { 56 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(program); 57 | node.setGLProgramState(glProgram_state); 58 | } else { 59 | node.setShaderProgram(program); 60 | } 61 | } 62 | 63 | update(dt) { 64 | this.time = (Date.now() - this.startTime) / 1000; 65 | if (this.program) { 66 | this.program.use(); 67 | if (cc.sys.isNative) { 68 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 69 | glProgram_state.setUniformFloat("time", this.time); 70 | } else { 71 | let ct = this.program.getUniformLocationForName("time"); 72 | this.program.setUniformLocationWith1f(ct, this.time); 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /assets/Script/FluxayEffect.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "e8aab878-b659-4347-b90c-042c73ee1aa9", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/FluxayFrag.ts: -------------------------------------------------------------------------------- 1 | // Feofox Game 2 | // Author:Lerry 3 | // https://github.com/fylz1125/ShaderDemos 4 | export default class FluxayFrag{ 5 | static fluxay_vert = ` 6 | attribute vec4 a_position; 7 | attribute vec2 a_texCoord; 8 | attribute vec4 a_color; 9 | varying vec2 v_texCoord; 10 | varying vec4 v_fragmentColor; 11 | void main() 12 | { 13 | gl_Position = CC_PMatrix * a_position; 14 | v_fragmentColor = a_color; 15 | v_texCoord = a_texCoord; 16 | } 17 | `; 18 | 19 | // 流光特效 20 | static fluxay_frag = ` 21 | #ifdef GL_ES 22 | precision mediump float; 23 | #endif 24 | varying vec2 v_texCoord; 25 | uniform float time; 26 | void main() 27 | { 28 | vec4 src_color = texture2D(CC_Texture0, v_texCoord).rgba; 29 | 30 | float width = 0.02; //流光的宽度范围 (调整该值改变流光的宽度) 31 | float start = tan(time/1.414); //流光的起始x坐标 32 | float strength = 0.006; //流光增亮强度 (调整该值改变流光的增亮强度) 33 | float offset = 0.5; //偏移值 (调整该值改变流光的倾斜程度) 34 | if( v_texCoord.x < (start - offset * v_texCoord.y) && v_texCoord.x > (start - offset * v_texCoord.y - width)) 35 | { 36 | vec3 improve = strength * vec3(255, 255, 255); 37 | vec3 result = improve * vec3( src_color.r, src_color.g, src_color.b); 38 | gl_FragColor = vec4(result, src_color.a); 39 | 40 | }else{ 41 | gl_FragColor = src_color; 42 | } 43 | } 44 | `; 45 | 46 | // 流光的另一种写法 47 | static fluxay_frag_s = ` 48 | #ifdef GL_ES 49 | precision mediump float; 50 | #endif 51 | 52 | varying vec4 v_fragmentColor; 53 | varying vec2 v_texCoord; 54 | 55 | // uniform float factor; 56 | // uniform float width; 57 | uniform float time; 58 | // uniform vec3 color; 59 | void main() 60 | { 61 | float factor = .06; 62 | float width = .02; 63 | // float offset = .5; 64 | vec3 color = vec3(10.,10.,10.); 65 | vec4 texColor = texture2D(CC_Texture0, v_texCoord); 66 | 67 | float distance = abs(v_texCoord[0]+v_texCoord[1]-tan(time))/1.414; 68 | 69 | distance = 1.0-(1.0/width)*distance; 70 | distance = max(distance, 0.0); 71 | vec4 sample = vec4(0.0,0.0,0.0,0.0); 72 | sample[0] = color[0] * distance; 73 | sample[1] = color[1] * distance; 74 | sample[2] = color[2] * distance; 75 | sample[3] = distance; 76 | 77 | float alpha = sample[3]*texColor[3]; 78 | texColor[0] = texColor[0] + sample[0]*alpha*factor; 79 | texColor[1] = texColor[1] + sample[1]*alpha*factor; 80 | texColor[2] = texColor[2] + sample[2]*alpha*factor; 81 | gl_FragColor = v_fragmentColor * texColor; 82 | } 83 | `; 84 | // 波光特效 85 | static fluxay_frag_super = ` 86 | #define TAU 6.120470874064187 87 | #define MAX_ITER 5 88 | uniform float time; 89 | varying vec2 v_texCoord; 90 | varying vec4 v_fragmentColor; 91 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 92 | { 93 | float time = time * .5+5.; 94 | // uv should be the 0-1 uv of texture... 95 | vec2 uv = v_texCoord.xy;//fragCoord.xy / iResolution.xy; 96 | 97 | 98 | vec2 p = mod(uv*TAU, TAU)-250.0; 99 | 100 | vec2 i = vec2(p); 101 | float c = 1.0; 102 | float inten = .0045; 103 | 104 | for (int n = 0; n < MAX_ITER; n++) 105 | { 106 | float t = time * (1.0 - (3.5 / float(n+1))); 107 | i = p + vec2(cos(t - i.x) + sin(t + i.y), sin(t - i.y) + cos(1.5*t + i.x)); 108 | c += 1.0/length(vec2(p.x / (cos(i.x+t)/inten),p.y / (cos(i.y+t)/inten))); 109 | } 110 | c /= float(MAX_ITER); 111 | c = 1.17-pow(c, 1.4); 112 | vec4 tex = texture2D(CC_Texture0,uv); 113 | vec3 colour = vec3(pow(abs(c), 20.0)); 114 | colour = clamp(colour + vec3(0.0, 0.0, .0), 0.0, tex.a); 115 | 116 | // 混合波光 117 | float alpha = c*tex[3]; 118 | tex[0] = tex[0] + colour[0]*alpha; 119 | tex[1] = tex[1] + colour[1]*alpha; 120 | tex[2] = tex[2] + colour[2]*alpha; 121 | fragColor = v_fragmentColor * tex; 122 | } 123 | void main() 124 | { 125 | mainImage(gl_FragColor, gl_FragCoord.xy); 126 | } 127 | `; 128 | } 129 | -------------------------------------------------------------------------------- /assets/Script/FluxayFrag.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "476401ce-4356-4383-b4f9-a61b2e2c5d61", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/GaussBlurEffect.ts: -------------------------------------------------------------------------------- 1 | import BlursFrag from './GaussBlursFrag'; 2 | const { ccclass, property } = cc._decorator; 3 | 4 | @ccclass 5 | export default class GaussBlurEffect extends cc.Component { 6 | 7 | @property 8 | isAllChildrenUse: boolean = false; 9 | 10 | @property(cc.Slider) 11 | slider: cc.Slider = null; 12 | 13 | @property(cc.Label) 14 | blurText: cc.Label = null; 15 | 16 | program: cc.GLProgram; 17 | bluramount: number = 0.10; 18 | 19 | 20 | 21 | onLoad() { 22 | this.bluramount = this.slider.progress / 10; 23 | this.blurText.string = (this.slider.progress*100).toString(); 24 | this.useBlur(); 25 | } 26 | 27 | start() { 28 | } 29 | 30 | useBlur() { 31 | this.program = new cc.GLProgram(); 32 | if (cc.sys.isNative) { 33 | this.program.initWithString(BlursFrag.blurs_vert, BlursFrag.blurs_frag); 34 | } else { 35 | this.program.initWithVertexShaderByteArray(BlursFrag.blurs_vert, BlursFrag.blurs_frag); 36 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); 37 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); 38 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); 39 | } 40 | this.program.link(); 41 | this.program.updateUniforms(); 42 | this.program.use(); 43 | 44 | if (cc.sys.isNative) { 45 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 46 | glProgram_state.setUniformFloat("bluramount", this.bluramount); 47 | } else { 48 | let ba = this.program.getUniformLocationForName("bluramount"); 49 | this.program.setUniformLocationWith1f(ba, this.bluramount); 50 | } 51 | if (this.isAllChildrenUse) { 52 | this.setProgram(this.node._sgNode, this.program); 53 | } else { 54 | this.setProgram(this.node.getComponent(cc.Sprite)._sgNode, this.program); 55 | } 56 | } 57 | 58 | setProgram(node: any, program: any) { 59 | if (cc.sys.isNative) { 60 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(program); 61 | node.setGLProgramState(glProgram_state); 62 | } else { 63 | node.setShaderProgram(program); 64 | } 65 | var children = node.children; 66 | if (!children) 67 | return; 68 | 69 | for (var i = 0; i < children.length; i++) { 70 | this.setProgram(children[i], program); 71 | } 72 | } 73 | 74 | onSliderBlurAmount(slider: cc.Slider, eventType: any) { 75 | this.bluramount = Number((this.slider.progress / 10).toFixed(3)); 76 | this.blurText.string = (this.bluramount*1000).toString(); 77 | this.changeBlurAmount(this.bluramount); 78 | } 79 | 80 | changeBlurAmount(amount: number) { 81 | if (this.program) { 82 | this.program.use(); 83 | if (cc.sys.isNative) { 84 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 85 | glProgram_state.setUniformFloat("bluramount", this.bluramount); 86 | } else { 87 | let ba = this.program.getUniformLocationForName("bluramount"); 88 | this.program.setUniformLocationWith1f(ba, this.bluramount); 89 | } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /assets/Script/GaussBlurEffect.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "3c908497-daee-437c-812d-ee2ba63443c4", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/GaussBlursFrag.ts: -------------------------------------------------------------------------------- 1 | export default class BlursFrag { 2 | static blurs_vert = ` 3 | attribute vec4 a_position; 4 | attribute vec2 a_texCoord; 5 | attribute vec4 a_color; 6 | varying vec2 v_texCoord; 7 | varying vec4 v_fragmentColor; 8 | void main() 9 | { 10 | gl_Position = CC_PMatrix * a_position; 11 | v_fragmentColor = a_color; 12 | v_texCoord = a_texCoord; 13 | } 14 | `; 15 | static blurs_frag = ` 16 | #ifdef GL_ES 17 | precision mediump float; 18 | #endif 19 | uniform float bluramount; 20 | varying vec2 v_texCoord; 21 | vec4 draw(vec2 uv) { 22 | return texture2D(CC_Texture0,uv).rgba; 23 | } 24 | float grid(float var, float size) { 25 | return floor(var*size)/size; 26 | } 27 | float rand(vec2 co){ 28 | return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); 29 | } 30 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 31 | { 32 | vec2 uv = v_texCoord.xy; 33 | vec4 blurred_image = vec4(0.); 34 | #define repeats 5. 35 | for (float i = 0.; i < repeats; i++) { 36 | vec2 q = vec2(cos(degrees((i/repeats)*360.)),sin(degrees((i/repeats)*360.))) * (rand(vec2(i,uv.x+uv.y))+bluramount); 37 | vec2 uv2 = uv+(q*bluramount); 38 | blurred_image += draw(uv2)/2.; 39 | q = vec2(cos(degrees((i/repeats)*360.)),sin(degrees((i/repeats)*360.))) * (rand(vec2(i+2.,uv.x+uv.y+24.))+bluramount); 40 | uv2 = uv+(q*bluramount); 41 | blurred_image += draw(uv2)/2.; 42 | } 43 | blurred_image /= repeats; 44 | fragColor = vec4(blurred_image); 45 | } 46 | void main() 47 | { 48 | mainImage(gl_FragColor, gl_FragCoord.xy); 49 | } 50 | `; 51 | } -------------------------------------------------------------------------------- /assets/Script/GaussBlursFrag.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "b03fc5ed-390b-462b-b98b-d3b06530176a", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/GrayEffect.ts: -------------------------------------------------------------------------------- 1 | import Gray from './GrayFrag'; 2 | const { ccclass, property } = cc._decorator 3 | 4 | @ccclass 5 | export default class GrayEffect extends cc.Component { 6 | @property 7 | isAllChildrenUse: boolean = false; 8 | 9 | program: cc.GLProgram;// ShaderProgram 10 | 11 | onLoad() { 12 | this.grayShader(); 13 | } 14 | 15 | // 变灰shader 16 | grayShader() { 17 | this.program = new cc.GLProgram(); 18 | if (cc.sys.isNative) { 19 | this.program.initWithString(Gray.default_vert, Gray.gray_frag); 20 | this.program.link(); 21 | this.program.updateUniforms(); 22 | } else { 23 | this.program.initWithVertexShaderByteArray(Gray.default_vert, Gray.gray_frag); 24 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); 25 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); 26 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); 27 | this.program.link(); 28 | this.program.updateUniforms(); 29 | } 30 | if (this.isAllChildrenUse) { 31 | this.setProgram(this.node._sgNode, this.program); 32 | } else { 33 | this.setProgram(this.node.getComponent(cc.Sprite)._sgNode, this.program); 34 | } 35 | 36 | } 37 | 38 | setProgram(node: any, program: any) { 39 | if (cc.sys.isNative) { 40 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(program); 41 | node.setGLProgramState(glProgram_state); 42 | } else { 43 | node.setShaderProgram(program); 44 | } 45 | 46 | var children = node.children; 47 | if (!children) 48 | return; 49 | 50 | for (var i = 0; i < children.length; i++) { 51 | this.setProgram(children[i], program); 52 | } 53 | } 54 | 55 | // 恢复默认shader 56 | resetProgram(node: cc.Node) { 57 | node.getComponent(cc.Sprite)._sgNode.setState(0); 58 | var children = node.children; 59 | if (!children) 60 | return; 61 | for (var i = 0; i < children.length; i++) { 62 | this.resetProgram(children[i]); 63 | } 64 | 65 | } 66 | 67 | resetShader() { 68 | if (this.isAllChildrenUse) { 69 | this.resetProgram(this.node); 70 | } else { 71 | this.node.getComponent(cc.Sprite)._sgNode.setState(0); 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /assets/Script/GrayEffect.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "25ea7a93-dc0e-434e-b93a-9a94c0c2561f", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/GrayFrag.ts: -------------------------------------------------------------------------------- 1 | export default class GrayFrag{ 2 | static default_vert = ` 3 | attribute vec4 a_position; 4 | attribute vec2 a_texCoord; 5 | attribute vec4 a_color; 6 | varying vec2 v_texCoord; 7 | varying vec4 v_fragmentColor; 8 | void main() 9 | { 10 | gl_Position = CC_PMatrix * a_position; 11 | v_fragmentColor = a_color; 12 | v_texCoord = a_texCoord; 13 | } 14 | `; 15 | 16 | static gray_frag = ` 17 | #ifdef GL_ES 18 | precision mediump float; 19 | #endif 20 | varying vec4 v_fragmentColor; 21 | varying vec2 v_texCoord; 22 | void main() 23 | { 24 | vec4 c = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); 25 | gl_FragColor.xyz = vec3(0.2126*c.r + 0.7152*c.g + 0.0722*c.b); 26 | gl_FragColor.w = c.w; 27 | } 28 | `; 29 | } 30 | -------------------------------------------------------------------------------- /assets/Script/GrayFrag.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "4bdbf9d4-1a84-46b9-9446-af9da305b26e", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/Menu.ts: -------------------------------------------------------------------------------- 1 | const { ccclass, property } = cc._decorator; 2 | 3 | @ccclass 4 | export default class Menu extends cc.Component { 5 | 6 | @property({ 7 | type: cc.AudioClip, 8 | displayName: "背景音乐" 9 | }) 10 | bgm: cc.AudioClip = null; 11 | 12 | @property({ 13 | displayName: "作者", 14 | visible: false 15 | }) 16 | author = "大掌教"; 17 | 18 | @property({ 19 | type: cc.Label, 20 | displayName: "作者" 21 | }) 22 | authorLb: cc.Label = null; 23 | 24 | @property({ 25 | type: cc.Label, 26 | displayName: "公众号ID" 27 | }) 28 | wechatLb: cc.Label = null; 29 | 30 | 31 | // 初始化 32 | onLoad() { 33 | cc.debug.setDisplayStats(true); 34 | cc.game.addPersistRootNode(this.node); 35 | cc.audioEngine.playMusic(this.bgm, true); 36 | this.authorLb.string = this.author; 37 | 38 | let lbAction = cc.repeatForever( 39 | cc.sequence( 40 | cc.scaleTo(1, 1.1), 41 | cc.scaleTo(1, 1.0), 42 | cc.scaleTo(1, 0.9), 43 | cc.scaleTo(1, 1.0) 44 | ) 45 | ); 46 | let finished = cc.callFunc(function () { 47 | this.authorLb.node.runAction(lbAction) 48 | this.wechatLb.node.runAction(cc.spawn(cc.scaleTo(1,1.0),cc.rotateBy(1,720))); 49 | }, this); 50 | let lbSpawn = cc.spawn(cc.scaleTo(1.5, 1.0).easing(cc.easeSineIn()), cc.fadeTo(1.5, 255).easing(cc.easeSineIn())); 51 | let lbSequence = cc.sequence(lbSpawn, finished,); 52 | this.authorLb.node.runAction(lbSequence); 53 | } 54 | goGlackhole() { 55 | cc.director.loadScene("Blackhole"); 56 | } 57 | 58 | 59 | // 每帧更新函数 60 | // update(dt) {} 61 | } 62 | -------------------------------------------------------------------------------- /assets/Script/Menu.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "5916264d-a263-4ba8-97a3-05a2243a2bf1", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/SearchLightEffect.ts: -------------------------------------------------------------------------------- 1 | // Feofox Game 2 | // Author:Lerry 3 | // https://github.com/fylz1125/ShaderDemos 4 | import SearchLight from './SearchLightFrag'; 5 | 6 | const {ccclass, property} = cc._decorator; 7 | 8 | @ccclass 9 | export default class SearchLightEffect extends cc.Component { 10 | 11 | program: cc.GLProgram; 12 | startTime:number = Date.now(); 13 | time: number = 0; 14 | 15 | resolution = { x: 0.0, y: 0.0 }; 16 | mouse = { x: 0.0, y: 0.0 }; 17 | 18 | onLoad() { 19 | this.resolution.x = ( this.node.getContentSize().width ); 20 | this.resolution.y = (this.node.getContentSize().height); 21 | this.mouse.x = 50.; 22 | this.mouse.y = 40.; 23 | let self = this; 24 | // 添加触摸事件包含鼠标事件 25 | this.node.on(cc.Node.EventType.TOUCH_START, function (event: cc.Event.EventTouch) { 26 | // 转化为node的局部坐标 27 | let touchPos = self.node.convertTouchToNodeSpaceAR(event.touch); 28 | self.mouse.x = touchPos.x; 29 | self.mouse.y = touchPos.y; 30 | self.changeLight(); 31 | }, this); 32 | 33 | this.node.on(cc.Node.EventType.TOUCH_MOVE, function (event:cc.Event.EventTouch) { 34 | let touchPos = self.node.convertTouchToNodeSpaceAR(event.touch); 35 | self.mouse.x = touchPos.x; 36 | self.mouse.y = touchPos.y; 37 | self.changeLight(); 38 | }, this); 39 | this.node.on(cc.Node.EventType.TOUCH_END, function (event) { 40 | // cc.log('touch end'); 41 | }, this); 42 | 43 | 44 | this.useShader(); 45 | } 46 | 47 | useShader() { 48 | this.program = new cc.GLProgram(); 49 | if (cc.sys.isNative) { 50 | this.program.initWithString(SearchLight.search_light_vert, SearchLight.search_light_frag); 51 | } else { 52 | this.program.initWithVertexShaderByteArray(SearchLight.search_light_vert, SearchLight.search_light_frag); 53 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); 54 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); 55 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); 56 | } 57 | this.program.link(); 58 | this.program.updateUniforms(); 59 | this.program.use(); 60 | 61 | if (cc.sys.isNative) { 62 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 63 | glProgram_state.setUniformVec2("resolution", this.resolution); 64 | glProgram_state.setUniformVec2( "mouse", this.mouse ); 65 | } else { 66 | let res = this.program.getUniformLocationForName( "resolution" ); 67 | let ms = this.program.getUniformLocationForName("mouse"); 68 | this.program.setUniformLocationWith2f( res, this.resolution.x,this.resolution.y ); 69 | this.program.setUniformLocationWith2f(ms, this.mouse.x,this.mouse.y); 70 | } 71 | this.setProgram(this.node.getComponent(cc.Sprite)._sgNode, this.program); 72 | } 73 | 74 | setProgram(node: any, program: any) { 75 | if (cc.sys.isNative) { 76 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(program); 77 | node.setGLProgramState(glProgram_state); 78 | } else { 79 | node.setShaderProgram(program); 80 | } 81 | } 82 | 83 | changeLight() { 84 | if (this.program) { 85 | this.program.use(); 86 | if (cc.sys.isNative) { 87 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 88 | glProgram_state.setUniformVec2("resolution", this.resolution); 89 | glProgram_state.setUniformVec2( "mouse", this.mouse ); 90 | } else { 91 | let res = this.program.getUniformLocationForName( "resolution" ); 92 | let ms = this.program.getUniformLocationForName("mouse"); 93 | this.program.setUniformLocationWith2f( res, this.resolution.x,this.resolution.y ); 94 | this.program.setUniformLocationWith2f(ms, this.mouse.x,this.mouse.y); 95 | } 96 | } 97 | } 98 | 99 | // update (dt) {} 100 | } 101 | -------------------------------------------------------------------------------- /assets/Script/SearchLightEffect.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "060708db-fba2-45da-9fb0-d487e15e3b76", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/SearchLightFrag.ts: -------------------------------------------------------------------------------- 1 | export default class SearchLightFrag{ 2 | static search_light_vert = ` 3 | attribute vec4 a_position; 4 | attribute vec2 a_texCoord; 5 | attribute vec4 a_color; 6 | varying vec2 v_texCoord; 7 | varying vec4 v_fragmentColor; 8 | void main() 9 | { 10 | gl_Position = CC_PMatrix * a_position; 11 | v_fragmentColor = a_color; 12 | v_texCoord = a_texCoord; 13 | } 14 | `; 15 | static search_light_frag = ` 16 | #ifdef GL_ES 17 | precision mediump float; 18 | #endif 19 | uniform vec2 resolution; 20 | uniform vec2 mouse; 21 | varying vec2 v_texCoord; 22 | 23 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 24 | { 25 | // y坐标翻转 26 | vec2 imouse = vec2(mouse.x, resolution.y - mouse.y); 27 | // 纹理坐标 28 | vec2 uv = v_texCoord.xy ; 29 | // 纹理采样 30 | vec4 tex = texture2D(CC_Texture0, uv); 31 | // 片元到鼠标点的差向量 32 | vec2 d = uv*resolution.xy -imouse.xy ; 33 | // 光照半径 34 | vec2 s = 0.15 * resolution.xy; 35 | // 点积取比例 36 | float r = dot(d, d)/dot(s,s); 37 | fragColor = tex * (1.08 - r); 38 | } 39 | void main() 40 | { 41 | mainImage(gl_FragColor, gl_FragCoord.xy); 42 | } 43 | `; 44 | } 45 | -------------------------------------------------------------------------------- /assets/Script/SearchLightFrag.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "d97da1e5-5f24-4c0b-b49f-3de366a3381a", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/TransferEffect.ts: -------------------------------------------------------------------------------- 1 | import Transfer from './TransferFrag'; 2 | const { ccclass, property } = cc._decorator; 3 | 4 | @ccclass 5 | export default class TransferEffect extends cc.Component { 6 | 7 | 8 | @property 9 | isAllChildrenUse: boolean = false; 10 | 11 | program: cc.GLProgram; 12 | time: number = 0; 13 | 14 | start() { 15 | // init logic 16 | this.enabled = false; 17 | } 18 | 19 | useShader() { 20 | let bgSp: cc.Sprite = this.node.getComponent(cc.Sprite); 21 | this.program = new cc.GLProgram(); 22 | if (!cc.sys.isNative) { 23 | this.program.initWithVertexShaderByteArray(Transfer.vert, Transfer.frag); 24 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); 25 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); 26 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); 27 | } else { 28 | this.program.initWithString(Transfer.vert, Transfer.frag); 29 | } 30 | this.program.link(); 31 | this.program.updateUniforms(); 32 | this.program.use(); 33 | 34 | if (!cc.sys.isNative) { 35 | let time = this.program.getUniformLocationForName("time"); 36 | this.program.setUniformLocationWith1f(time, this.time); 37 | } else { 38 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 39 | glProgram_state.setUniformFloat("time", this.time); 40 | } 41 | // bgSp._sgNode.setShaderProgram(this.program); 42 | // this.enabled = true; 43 | if (this.isAllChildrenUse) { 44 | this.setProgram(this.node._sgNode, this.program); 45 | } else { 46 | this.setProgram(this.node.getComponent(cc.Sprite)._sgNode, this.program); 47 | } 48 | this.enabled = true; 49 | } 50 | 51 | setProgram(node: any, program: any) { 52 | if (cc.sys.isNative) { 53 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(program); 54 | node.setGLProgramState(glProgram_state); 55 | } else { 56 | node.setShaderProgram(program); 57 | } 58 | var children = node.children; 59 | if (!children) 60 | return; 61 | 62 | for (var i = 0; i < children.length; i++) { 63 | this.setProgram(children[i], program); 64 | } 65 | } 66 | 67 | 68 | update(dt) { 69 | this.time += 0.02; 70 | if (this.program) { 71 | this.program.use(); 72 | if (!cc.sys.isNative) { 73 | let time = this.program.getUniformLocationForName("time"); 74 | this.program.setUniformLocationWith1f(time, this.time); 75 | } else { 76 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 77 | glProgram_state.setUniformFloat("time", this.time); 78 | } 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /assets/Script/TransferEffect.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "e1b90feb-a217-4493-849d-9a611900d683", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/TransferFrag.ts: -------------------------------------------------------------------------------- 1 | export default class Transfer { 2 | static vert =` 3 | attribute vec4 a_position; 4 | attribute vec2 a_texCoord; 5 | attribute vec4 a_color; 6 | varying vec2 v_texCoord; 7 | varying vec4 v_fragmentColor; 8 | void main() 9 | { 10 | gl_Position = CC_PMatrix * a_position; 11 | v_fragmentColor = a_color; 12 | v_texCoord = a_texCoord; 13 | } 14 | `; 15 | 16 | static frag=` 17 | #ifdef GL_ES 18 | precision lowp float; 19 | #endif 20 | 21 | uniform float time; 22 | 23 | varying vec4 v_fragmentColor; 24 | varying vec2 v_texCoord; 25 | void main() 26 | { 27 | vec4 c = v_fragmentColor * texture2D(CC_Texture0, v_texCoord); 28 | gl_FragColor = c; 29 | 30 | float temp = v_texCoord.x - time; 31 | if (temp <= 0.0) { 32 | float temp2 = abs(temp); 33 | if (temp2 <= 0.2) { 34 | gl_FragColor.w = 1.0 - temp2/0.2; 35 | } else { 36 | gl_FragColor.w = 0.0; 37 | } 38 | } else { 39 | gl_FragColor.w = 1.0; 40 | } 41 | } 42 | `; 43 | } -------------------------------------------------------------------------------- /assets/Script/TransferFrag.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "88622b84-937f-493b-b621-0e3b252e369e", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/TurnPageEffect.ts: -------------------------------------------------------------------------------- 1 | import TurnPageFrag from './TurnPageFrag'; 2 | const {ccclass, property} = cc._decorator; 3 | 4 | @ccclass 5 | export default class TurnPageEffect extends cc.Component { 6 | 7 | program: cc.GLProgram; 8 | 9 | resolution = { x: 0.0, y: 0.0 }; 10 | mouse = { x: 0.0, y: 0.0 }; 11 | 12 | onLoad() { 13 | this.resolution.x = ( this.node.getContentSize().width ); 14 | this.resolution.y = (this.node.getContentSize().height); 15 | this.mouse.x = 0.0; 16 | this.mouse.y = 0.0; 17 | let self = this; 18 | // 添加触摸事件包含鼠标事件 19 | this.node.on(cc.Node.EventType.TOUCH_START, function (event: cc.Event.EventTouch) { 20 | // 转化为node的局部坐标 21 | let touchPos = self.node.convertTouchToNodeSpaceAR(event.touch); 22 | self.mouse.x = touchPos.x; 23 | self.mouse.y = touchPos.y; 24 | self.changeLight(); 25 | }, this); 26 | 27 | this.node.on(cc.Node.EventType.TOUCH_MOVE, function (event:cc.Event.EventTouch) { 28 | let touchPos = self.node.convertTouchToNodeSpaceAR(event.touch); 29 | self.mouse.x = touchPos.x; 30 | self.mouse.y = touchPos.y; 31 | self.changeLight(); 32 | }, this); 33 | this.node.on(cc.Node.EventType.TOUCH_END, function (event) { 34 | // cc.log('touch end'); 35 | }, this); 36 | 37 | 38 | this.useShader(); 39 | } 40 | 41 | useShader() { 42 | this.program = new cc.GLProgram(); 43 | if (cc.sys.isNative) { 44 | this.program.initWithString(TurnPageFrag.turnpage_vert, TurnPageFrag.turnpage_frag); 45 | } else { 46 | this.program.initWithVertexShaderByteArray(TurnPageFrag.turnpage_vert, TurnPageFrag.turnpage_frag); 47 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); 48 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); 49 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); 50 | } 51 | this.program.link(); 52 | this.program.updateUniforms(); 53 | this.program.use(); 54 | 55 | if (cc.sys.isNative) { 56 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 57 | glProgram_state.setUniformVec2("resolution", this.resolution); 58 | glProgram_state.setUniformVec2("mouse", this.mouse); 59 | } else { 60 | let res = this.program.getUniformLocationForName( "resolution" ); 61 | let ms = this.program.getUniformLocationForName("mouse"); 62 | this.program.setUniformLocationWith2f( res, this.resolution.x,this.resolution.y ); 63 | this.program.setUniformLocationWith2f(ms, this.mouse.x,this.mouse.y); 64 | } 65 | this.setProgram(this.node.getComponent(cc.Sprite)._sgNode, this.program); 66 | } 67 | 68 | setProgram(node: any, program: any) { 69 | if (cc.sys.isNative) { 70 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(program); 71 | node.setGLProgramState(glProgram_state); 72 | } else { 73 | node.setShaderProgram(program); 74 | } 75 | } 76 | 77 | changeLight() { 78 | if (this.program) { 79 | this.program.use(); 80 | if (cc.sys.isNative) { 81 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 82 | glProgram_state.setUniformVec2("resolution", this.resolution); 83 | glProgram_state.setUniformVec2( "mouse", this.mouse ); 84 | } else { 85 | let res = this.program.getUniformLocationForName( "resolution" ); 86 | let ms = this.program.getUniformLocationForName("mouse"); 87 | this.program.setUniformLocationWith2f( res, this.resolution.x,this.resolution.y ); 88 | this.program.setUniformLocationWith2f(ms, this.mouse.x,this.mouse.y); 89 | } 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /assets/Script/TurnPageEffect.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "56464423-717b-4e85-a401-538d264ba35e", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/TurnPageFrag.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "215f3109-af46-4f07-b35f-0e027dc58080", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/WaterWaveEffect.ts: -------------------------------------------------------------------------------- 1 | // Feofox Game 2 | // Author:Lerry 3 | // https://github.com/fylz1125/ShaderDemos 4 | import WaterWave from './WaterWaveFrag'; 5 | const { ccclass, property } = cc._decorator; 6 | 7 | @ccclass 8 | export default class WaterWaveEffect extends cc.Component { 9 | 10 | program: cc.GLProgram; 11 | startTime:number = Date.now(); 12 | time: number = 0; 13 | 14 | resolution={ x:0.0, y:0.0}; 15 | 16 | onLoad() { 17 | this.resolution.x = ( this.node.getContentSize().width ); 18 | this.resolution.y = ( this.node.getContentSize().height ); 19 | this.useWater(); 20 | 21 | } 22 | 23 | start() { 24 | } 25 | 26 | useWater() { 27 | if (this.program) return; 28 | this.program = new cc.GLProgram(); 29 | if (cc.sys.isNative) { 30 | this.program.initWithString(WaterWave.waterwave_vert, WaterWave.waterwave_frag); 31 | } else { 32 | this.program.initWithVertexShaderByteArray(WaterWave.waterwave_vert, WaterWave.waterwave_frag); 33 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_POSITION, cc.macro.VERTEX_ATTRIB_POSITION); 34 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_COLOR, cc.macro.VERTEX_ATTRIB_COLOR); 35 | this.program.addAttribute(cc.macro.ATTRIBUTE_NAME_TEX_COORD, cc.macro.VERTEX_ATTRIB_TEX_COORDS); 36 | } 37 | this.program.link(); 38 | this.program.updateUniforms(); 39 | this.program.use(); 40 | 41 | if (cc.sys.isNative) { 42 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 43 | glProgram_state.setUniformFloat("time", this.time); 44 | glProgram_state.setUniformVec2( "resolution", this.resolution ); 45 | } else { 46 | let res = this.program.getUniformLocationForName( "resolution" ); 47 | let ba = this.program.getUniformLocationForName("time"); 48 | this.program.setUniformLocationWith2f( res, this.resolution.x,this.resolution.y ); 49 | this.program.setUniformLocationWith1f(ba, this.time); 50 | } 51 | this.setProgram(this.node.getComponent(cc.Sprite)._sgNode, this.program); 52 | } 53 | 54 | setProgram(node: any, program: any) { 55 | if (cc.sys.isNative) { 56 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(program); 57 | node.setGLProgramState(glProgram_state); 58 | } else { 59 | node.setShaderProgram(program); 60 | } 61 | } 62 | 63 | update(dt) { 64 | this.time = (Date.now() - this.startTime) / 1000; 65 | if (this.program) { 66 | this.program.use(); 67 | if (cc.sys.isNative) { 68 | var glProgram_state = cc.GLProgramState.getOrCreateWithGLProgram(this.program); 69 | glProgram_state.setUniformFloat("time", this.time); 70 | } else { 71 | let ct = this.program.getUniformLocationForName("time"); 72 | this.program.setUniformLocationWith1f(ct, this.time); 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /assets/Script/WaterWaveEffect.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "a07ce7cd-7453-4353-b7e4-296728e05146", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/WaterWaveFrag.ts: -------------------------------------------------------------------------------- 1 | export default class WaterWaveFrag{ 2 | static waterwave_vert = ` 3 | attribute vec4 a_position; 4 | attribute vec2 a_texCoord; 5 | attribute vec4 a_color; 6 | varying vec2 v_texCoord; 7 | varying vec4 v_fragmentColor; 8 | void main() 9 | { 10 | gl_Position = CC_PMatrix * a_position; 11 | v_fragmentColor = a_color; 12 | v_texCoord = a_texCoord; 13 | } 14 | `; 15 | 16 | static waterwave_frag = ` 17 | #ifdef GL_ES 18 | precision mediump float; 19 | #endif 20 | 21 | #define F cos(x-y)*cos(y),sin(x+y)*sin(y) 22 | 23 | uniform float time; 24 | uniform vec2 resolution; 25 | varying vec2 v_texCoord; 26 | 27 | vec2 s(vec2 p) 28 | { 29 | float d=time*0.2,x=8.*(p.x+d),y=8.*(p.y+d); 30 | return vec2(F); 31 | } 32 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 33 | { 34 | // 换成resolution 35 | vec2 rs = resolution.xy; 36 | // 换成纹理坐标v_texCoord.xy 37 | vec2 uv = v_texCoord.xy; 38 | vec2 q = uv+2./resolution.x*(s(uv)-s(uv+rs)); 39 | //反转y 40 | // q.y=1.-q.y; 41 | fragColor = texture2D(CC_Texture0,q); 42 | } 43 | void main() 44 | { 45 | mainImage(gl_FragColor, gl_FragCoord.xy); 46 | } 47 | `; 48 | } -------------------------------------------------------------------------------- /assets/Script/WaterWaveFrag.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "72066df0-9797-4e6f-8c23-6ff7a2f5e8e0", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/shader.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "0fd7fab9-1d88-4273-b82e-516f9a74cf94", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/Script/shader/MaterialComponent.ts: -------------------------------------------------------------------------------- 1 | // Author:lerry(大掌教) 2 | // 详细教程请关注博客和微信公众号 3 | // csdn:https://darkpalm.blog.csdn.net 4 | // 微信公众号ID:darkpalm 5 | // Q群:704391772 6 | 7 | import MaterialSingleton from "./MaterialSingleton"; 8 | import MaterialManager, { ShaderType, ShaderEffects } from "./MaterialManager"; 9 | 10 | const { ccclass, property, requireComponent, executeInEditMode } = cc._decorator; 11 | 12 | const NeedUpdate = [ShaderType.WaterWave,ShaderType.StartLighting]; 13 | 14 | @ccclass 15 | @executeInEditMode 16 | @requireComponent(cc.Sprite) 17 | export default class ShaderComponent extends cc.Component { 18 | 19 | @property({ type: cc.Enum(ShaderType), visible: false }) 20 | private _shader: ShaderType = ShaderType.Normal; 21 | 22 | @property({ 23 | type: cc.Enum(ShaderEffects), 24 | displayName:"着色器" 25 | }) 26 | get shader() { return this._shader; } 27 | set shader(type) { 28 | this._shader = type; 29 | this._setMaterial(); 30 | } 31 | 32 | private _time = 0; 33 | private _startIndex:number = Date.now(); 34 | private _material: MaterialSingleton; 35 | get material() { return this._material; } 36 | 37 | protected start() { 38 | this.getComponent(cc.Sprite).setState(cc.Sprite.State.NORMAL); 39 | this._setMaterial(); 40 | 41 | } 42 | 43 | protected update(dt) { 44 | if (!this._material) return; 45 | this._updateShaderTime(dt); 46 | } 47 | 48 | private _setMaterial() { 49 | let shader = this.shader; 50 | let sprite = this.getComponent(cc.Sprite); 51 | let material = MaterialManager.getMaterial(sprite, shader); 52 | this._material = material; 53 | if (!material) return; 54 | switch (shader) { 55 | case ShaderType.WaterWave: 56 | case ShaderType.StartLighting: 57 | case ShaderType.Blackhole: 58 | material.setResolution(this.node.width, this.node.height); 59 | break; 60 | default: 61 | break; 62 | } 63 | } 64 | 65 | /** 66 | * 随时间更新shader 67 | * @param dt 每帧时间 68 | */ 69 | private _updateShaderTime(dt) { 70 | if (NeedUpdate.indexOf(this._shader) >= 0) { 71 | this._time = (Date.now() - this._startIndex) / 1000; 72 | this._material.setTime(this._time); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /assets/Script/shader/MaterialComponent.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "1051accf-f3f7-4387-88c7-3540bb53895c", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/shader/MaterialManager.ts: -------------------------------------------------------------------------------- 1 | // Author:lerry(大掌教) 2 | // 详细教程请关注博客和微信公众号 3 | // csdn:https://darkpalm.blog.csdn.net 4 | // 微信公众号ID:darkpalm 5 | // Q群:704391772 6 | 7 | // import ShaderLab from "./ShaderLab"; 8 | import ShaderFSH from "./ShaderFSH"; 9 | import MaterialSingleton from "./MaterialSingleton"; 10 | /** 11 | * 定义材质类型 12 | */ 13 | export enum ShaderType { 14 | // 系统自带 15 | Normal = -2, 16 | // 系统自带 17 | Gray, 18 | // 自定义开始 19 | GrayScaling, 20 | WaterWave, 21 | StartLighting, 22 | Blackhole 23 | } 24 | 25 | /** 26 | * 定义个中文的,看起来舒爽一点 27 | * 两个枚举要配套使用 28 | */ 29 | export let ShaderEffects = cc.Enum({ 30 | 正常:-2, 31 | 灰色: -1, 32 | 灰度图: 0, 33 | 水波: 1, 34 | 闪电: 2, 35 | 黑洞照片:3 36 | }) 37 | 38 | export default class MaterialManager { 39 | /** 40 | * 获取一个材质 41 | * @param sprite 精灵 42 | * @param shader shader类型 43 | */ 44 | static getMaterial(sprite: cc.Sprite, shader: ShaderType): MaterialSingleton { 45 | if (cc.game.renderType === cc.game.RENDER_TYPE_CANVAS) { 46 | cc.warn("Shader not surpport for canvas"); 47 | return; 48 | } 49 | if (!sprite || !sprite.spriteFrame) { 50 | return; 51 | } 52 | if (shader > ShaderType.Gray) { 53 | let name = ShaderType[shader]; 54 | let lab = ShaderFSH[shader as number]; 55 | if (!lab) { 56 | console.warn('Shader not defined', name); 57 | return; 58 | } 59 | cc.dynamicAtlasManager.enabled = false; 60 | let material = MaterialSingleton.getInstance(name); 61 | let texture = sprite.spriteFrame.getTexture(); 62 | material.setTexture(texture); 63 | material.updateHash(); 64 | let sp = sprite as any; 65 | sp._material = material; 66 | sp._renderData._material = material; 67 | sp._state = shader; 68 | return material; 69 | } 70 | else { 71 | // 系统自带normal和gray 72 | sprite.setState(shader+2); 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /assets/Script/shader/MaterialManager.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "164cf6a4-3064-493c-b5bf-d91ac37b87f2", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/shader/MaterialSingleton.ts: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | const math = cc.vmath; 3 | const renderEngine = cc.renderer.renderEngine; 4 | const Material = renderEngine.Material; 5 | 6 | export default class MaterialSingleton extends Material { 7 | private static instance: MaterialSingleton = null; 8 | constructor() { 9 | super(false); 10 | } 11 | 12 | public static getInstance(shaderName:string): MaterialSingleton { 13 | if (!this.instance) { 14 | this.instance = new MaterialSingleton(); 15 | } 16 | this.instance.initWithName(shaderName) 17 | return this.instance; 18 | } 19 | 20 | private initWithName(shaderName: string) { 21 | let renderer = renderEngine.renderer; 22 | let gfx = renderEngine.gfx; 23 | 24 | let pass = new renderer.Pass(shaderName); 25 | pass.setDepth(false, false); 26 | pass.setCullMode(gfx.CULL_NONE); 27 | pass.setBlend( 28 | gfx.BLEND_FUNC_ADD, 29 | gfx.BLEND_SRC_ALPHA, gfx.BLEND_ONE_MINUS_SRC_ALPHA, 30 | gfx.BLEND_FUNC_ADD, 31 | gfx.BLEND_SRC_ALPHA, gfx.BLEND_ONE_MINUS_SRC_ALPHA 32 | ); 33 | 34 | let mainTech = new renderer.Technique( 35 | ['transparent'], 36 | [ 37 | { name: 'texture', type: renderer.PARAM_TEXTURE_2D }, 38 | { name: 'pos', type: renderer.PARAM_FLOAT3 }, 39 | { name: 'size', type: renderer.PARAM_FLOAT2 }, 40 | { name: 'iTime', type: renderer.PARAM_FLOAT }, 41 | { name: 'num', type: renderer.PARAM_FLOAT }, 42 | { name: 'resolution', type: renderer.PARAM_FLOAT3 }, 43 | ], 44 | [pass] 45 | ); 46 | 47 | // @ts-ignore 48 | this._texture = null; 49 | // @ts-ignore 50 | this._pos = { x: 0.0, y: 0.0, z: 0.0 }; 51 | // @ts-ignore 52 | this._size = { x: 0.0, y: 0.0 }; 53 | // @ts-ignore 54 | this._time = 0.0; 55 | // @ts-ignore 56 | this._num = 0.0; 57 | // @ts-ignore 58 | this._resolution = math.vec3.create(); 59 | // @ts-ignore 60 | this._effect = this.effect = new renderer.Effect( 61 | [ 62 | mainTech 63 | ], 64 | { 65 | 'pos': this._pos, 66 | 'size': this._size, 67 | 'iTime': this._time, 68 | 'num': this._num, 69 | 'resolution': this._resolution 70 | }, 71 | [] 72 | ); 73 | // @ts-ignore 74 | this._mainTech = mainTech; 75 | } 76 | 77 | setTexture(texture) { 78 | if (this._texture !== texture) { 79 | // @ts-ignore 80 | this._texture = texture; 81 | this._texture.update({ 82 | // 有时候需要反转y轴 83 | flipY: false, 84 | // 多级渐进纹理 85 | mipmap: true 86 | }); 87 | this._effect.setProperty('texture', texture.getImpl()); 88 | this._texIds['texture'] = texture.getId(); 89 | } 90 | } 91 | 92 | setPos(x, y, z) { 93 | this._pos.x = x; 94 | this._pos.y = y; 95 | this._pos.z = z; 96 | this._effect.setProperty('pos', this._pos); 97 | } 98 | 99 | setSize(x, y) { 100 | this._size.x = x; 101 | this._size.y = y; 102 | this._effect.setProperty('size', this._size); 103 | } 104 | 105 | setTime(time) { 106 | // @ts-ignore 107 | this._time = time; 108 | this._effect.setProperty('iTime', this._time); 109 | } 110 | 111 | setNum(num) { 112 | // @ts-ignore 113 | this._num = num; 114 | this._effect.setProperty('num', this._num); 115 | } 116 | 117 | setResolution(w, h) { 118 | this._resolution.x = w; 119 | this._resolution.y = h; 120 | this._effect.setProperty('resolution', this._resolution); 121 | } 122 | 123 | 124 | } -------------------------------------------------------------------------------- /assets/Script/shader/MaterialSingleton.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "1c61af2d-65b1-4877-8db5-a4b395c74a33", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/shader/ShaderFSH.ts: -------------------------------------------------------------------------------- 1 | const MVP = ` 2 | uniform mat4 viewProj; 3 | uniform mat4 model; 4 | attribute vec3 a_position; 5 | attribute vec2 a_uv0; 6 | varying vec2 uv0; 7 | void main () { 8 | mat4 mvp; 9 | mvp = viewProj * model; 10 | vec4 pos = mvp * vec4(a_position, 1); 11 | gl_Position = pos; 12 | uv0 = a_uv0; 13 | } 14 | `; 15 | const ShaderFSH = [ 16 | { 17 | name: "GrayScaling",//灰度图 18 | vert: MVP, 19 | defines: [], 20 | frag: ` 21 | uniform sampler2D texture; 22 | uniform vec4 color; 23 | varying vec2 uv0; 24 | void main () { 25 | vec4 c = color * texture2D(texture, uv0); 26 | float gray = dot(c.rgb, vec3(0.299 * 0.5, 0.587 * 0.5, 0.114 * 0.5)); 27 | gl_FragColor = vec4(gray, gray, gray, c.a * 0.5); 28 | } 29 | ` 30 | }, 31 | 32 | { 33 | name: "WaterWave",//水波 34 | vert: MVP, 35 | defines: [], 36 | frag: ` 37 | #define F cos(x-y)*cos(y),sin(x+y)*sin(y) 38 | 39 | uniform sampler2D texture; 40 | uniform float iTime; 41 | uniform vec3 resolution; 42 | varying vec2 uv0; 43 | 44 | vec2 s(vec2 p) 45 | { 46 | float d=iTime*0.2,x=8.*(p.x+d),y=8.*(p.y+d); 47 | return vec2(F); 48 | } 49 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 50 | { 51 | // 换成resolution 52 | vec2 rs = resolution.xy; 53 | // 换成纹理坐标 uv0 54 | vec2 uv = uv0.xy; 55 | vec2 q = uv+2./resolution.x*(s(uv)-s(uv+rs)); 56 | //反转y 57 | // q.y=1.-q.y; 58 | fragColor = texture2D(texture,q); 59 | } 60 | void main() 61 | { 62 | mainImage(gl_FragColor, gl_FragCoord.xy); 63 | } 64 | ` 65 | }, 66 | { 67 | name: "StartLighting",//封面的闪电 68 | vert: MVP, 69 | defines: [], 70 | frag: ` 71 | uniform float iTime; 72 | uniform vec3 resolution; 73 | varying vec2 uv0; 74 | 75 | vec2 hash(in vec2 p) 76 | { 77 | p=vec2(dot(p,vec2(127.1,311.7)), 78 | dot(p,vec2(269.5,183.3))); 79 | 80 | return-1.+2.*fract(sin(p)*43758.5453123); 81 | } 82 | 83 | float noise(in vec2 p) 84 | { 85 | const float K1=.366025404; 86 | const float K2=.211324865; 87 | 88 | vec2 i=floor(p+(p.x+p.y)*K1); 89 | 90 | vec2 a=p-i+(i.x+i.y)*K2; 91 | vec2 o=step(a.yx,a.xy); 92 | vec2 b=a-o+K2; 93 | vec2 c=a-1.+2.*K2; 94 | 95 | vec3 h=max(.5-vec3(dot(a,a),dot(b,b),dot(c,c)),.0); 96 | 97 | vec3 n=h*h*h*h*vec3(dot(a,hash(i+.0)), 98 | dot(b,hash(i+o)), 99 | dot(c,hash(i+1.))); 100 | 101 | return dot(n,vec3(70.)); 102 | } 103 | 104 | float fbm(in vec2 p,float time) 105 | { 106 | float c=cos(time/sqrt(3.)); 107 | float d=noise(p); 108 | d+=.5*noise(p+vec2(+c,+0.)); 109 | d+=.25*noise(p+vec2(+0.,+c)); 110 | d+=.125*noise(p+vec2(-c,+0.)); 111 | d+=.0625*noise(p+vec2(+0.,-c)); 112 | d/=(1.+.5+.25+.125+.0625); 113 | return.5+.5*d; 114 | } 115 | 116 | vec2 toPolar(in vec2 p) 117 | { 118 | float r=length(p); 119 | float a=atan(p.y,p.x); 120 | return vec2(r,a); 121 | } 122 | 123 | vec2 toRect(in vec2 p) 124 | { 125 | float x=p.x*cos(p.y); 126 | float y=p.x*sin(p.y); 127 | return vec2(x,y); 128 | } 129 | 130 | 131 | 132 | vec3 electric(in vec2 uv) 133 | { 134 | const float thickness=.25; 135 | const float haze=2.5; 136 | const float size=.075; 137 | const int count=3; 138 | 139 | vec2 p=uv; 140 | 141 | vec2 pp=toPolar(p); 142 | pp.y+=.2*p.x; 143 | p=toRect(pp); 144 | 145 | vec3 col=vec3(0.); 146 | 147 | float a1=smoothstep(.05,1.,length(p-vec2(-.6,0.))); 148 | float a2=smoothstep(.05,1.,length(p-vec2(.6,0.))); 149 | float s1=1./(a1+.1)*1.1; 150 | float s2=1./(a2+.1)*1.1; 151 | 152 | float e1=1.6+.4*sin(iTime*sqrt(2.)); 153 | float e2=e1; 154 | 155 | for(int i=0;i { 221 | // shader模板定义 名字,顶点着色器,片段着色器,宏定义列表,引擎初始化完成即定义 222 | // @ts-ignore 223 | cc.renderer._forward._programLib.define(val.name, val.vert, val.frag, val.defines || []); 224 | }) 225 | }); 226 | 227 | export default ShaderFSH; -------------------------------------------------------------------------------- /assets/Script/shader/ShaderFSH.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "29b039a6-ddab-4520-b71b-bdd4897f7bf4", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Script/shader/ShaderLab.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "60d02629-a06e-4196-91c8-ce37b0cc4d16", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/Texture.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54", 4 | "isGroup": false, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/Texture/angel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/angel.png -------------------------------------------------------------------------------- /assets/Texture/angel.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "d5a4f1ac-c98c-4bf1-a3cd-d441778291d8", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "angel": { 10 | "ver": "1.0.4", 11 | "uuid": "40b833fc-3888-4059-afbc-ce5d4e6eac70", 12 | "rawTextureUuid": "d5a4f1ac-c98c-4bf1-a3cd-d441778291d8", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 200, 21 | "height": 200, 22 | "rawWidth": 200, 23 | "rawHeight": 200, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/button_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/button_green.png -------------------------------------------------------------------------------- /assets/Texture/button_green.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "d02e5c2b-4594-4ab7-a97f-80f21c448eba", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "button_green": { 10 | "ver": "1.0.4", 11 | "uuid": "b703433d-94cc-4100-b604-f717b2039bcf", 12 | "rawTextureUuid": "d02e5c2b-4594-4ab7-a97f-80f21c448eba", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 30, 21 | "height": 22, 22 | "rawWidth": 30, 23 | "rawHeight": 22, 24 | "borderTop": 7, 25 | "borderBottom": 12, 26 | "borderLeft": 8, 27 | "borderRight": 7, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/danila.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/danila.png -------------------------------------------------------------------------------- /assets/Texture/danila.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "08dcd1a3-57ab-49f0-8741-5f5b3d35622d", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "danila": { 10 | "ver": "1.0.4", 11 | "uuid": "71c8ae5a-57fa-4aed-8ee9-da616ede9ac7", 12 | "rawTextureUuid": "08dcd1a3-57ab-49f0-8741-5f5b3d35622d", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 341, 21 | "height": 456, 22 | "rawWidth": 341, 23 | "rawHeight": 456, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/dragon_nest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/dragon_nest.png -------------------------------------------------------------------------------- /assets/Texture/dragon_nest.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "cf332f89-0c3a-47cf-9e96-3666c7f839ea", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "dragon_nest": { 10 | "ver": "1.0.4", 11 | "uuid": "00e0416e-8e81-48ab-8453-e5fceef63510", 12 | "rawTextureUuid": "cf332f89-0c3a-47cf-9e96-3666c7f839ea", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": -3.5, 18 | "trimX": 0, 19 | "trimY": 7, 20 | "width": 500, 21 | "height": 180, 22 | "rawWidth": 500, 23 | "rawHeight": 187, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/feofox logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/feofox logo.png -------------------------------------------------------------------------------- /assets/Texture/feofox logo.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "39adb433-8aa2-4d43-ae29-4fb979c1a79a", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "feofox logo": { 10 | "ver": "1.0.4", 11 | "uuid": "504f5442-ed36-4d4e-9839-6c1bf8fd4fcf", 12 | "rawTextureUuid": "39adb433-8aa2-4d43-ae29-4fb979c1a79a", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 106, 19 | "trimY": 56, 20 | "width": 300, 21 | "height": 400, 22 | "rawWidth": 512, 23 | "rawHeight": 512, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/game_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/game_bg.jpg -------------------------------------------------------------------------------- /assets/Texture/game_bg.jpg.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "1bbc2ba8-a308-44d0-9b95-77077d699006", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "game_bg": { 10 | "ver": "1.0.4", 11 | "uuid": "ebabac99-2975-469e-a348-9e69e15a5a15", 12 | "rawTextureUuid": "1bbc2ba8-a308-44d0-9b95-77077d699006", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 1024, 21 | "height": 768, 22 | "rawWidth": 1024, 23 | "rawHeight": 768, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/monster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/monster.jpg -------------------------------------------------------------------------------- /assets/Texture/monster.jpg.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "6be4c76b-ebdb-4699-844b-feeab1ab6a84", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "monster": { 10 | "ver": "1.0.4", 11 | "uuid": "6e55dc1a-a332-45f4-b51c-df72dff0274c", 12 | "rawTextureUuid": "6be4c76b-ebdb-4699-844b-feeab1ab6a84", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 500, 21 | "height": 600, 22 | "rawWidth": 500, 23 | "rawHeight": 600, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/noise.png -------------------------------------------------------------------------------- /assets/Texture/noise.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "d9d6fc6d-c29b-4468-8b19-536507bcaccf", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "noise": { 10 | "ver": "1.0.4", 11 | "uuid": "d62bfd3d-1dae-43c0-b111-eb1b4de442f5", 12 | "rawTextureUuid": "d9d6fc6d-c29b-4468-8b19-536507bcaccf", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 256, 21 | "height": 256, 22 | "rawWidth": 256, 23 | "rawHeight": 256, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/noise1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/noise1.png -------------------------------------------------------------------------------- /assets/Texture/noise1.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "5c81bdaf-f555-486d-900c-e557ef8e1e67", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "noise1": { 10 | "ver": "1.0.4", 11 | "uuid": "f72080aa-f4c7-4c85-a96a-4045702c91b0", 12 | "rawTextureUuid": "5c81bdaf-f555-486d-900c-e557ef8e1e67", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 256, 21 | "height": 256, 22 | "rawWidth": 256, 23 | "rawHeight": 256, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/panel_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/panel_bg.png -------------------------------------------------------------------------------- /assets/Texture/panel_bg.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "118a3c60-2285-4189-b478-15a390bdd8c7", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "panel_bg": { 10 | "ver": "1.0.4", 11 | "uuid": "5aa44d57-c8e6-451d-b74c-b032c29a71cb", 12 | "rawTextureUuid": "118a3c60-2285-4189-b478-15a390bdd8c7", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 20, 21 | "height": 20, 22 | "rawWidth": 20, 23 | "rawHeight": 20, 24 | "borderTop": 4, 25 | "borderBottom": 6, 26 | "borderLeft": 5, 27 | "borderRight": 5, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/singleColor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/singleColor.png -------------------------------------------------------------------------------- /assets/Texture/singleColor.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "c821c740-b31c-492c-90b3-51758d0958a3", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "singleColor": { 10 | "ver": "1.0.4", 11 | "uuid": "5be2601e-7811-488b-a7dc-cf69e3406ee9", 12 | "rawTextureUuid": "c821c740-b31c-492c-90b3-51758d0958a3", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 2, 21 | "height": 2, 22 | "rawWidth": 2, 23 | "rawHeight": 2, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/startbg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/startbg.jpg -------------------------------------------------------------------------------- /assets/Texture/startbg.jpg.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "8108fc79-b626-47ad-ac11-612cbaf0cc93", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "startbg": { 10 | "ver": "1.0.4", 11 | "uuid": "c828fe02-5690-4a53-bc25-76207013a36c", 12 | "rawTextureUuid": "8108fc79-b626-47ad-ac11-612cbaf0cc93", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 1024, 21 | "height": 768, 22 | "rawWidth": 1024, 23 | "rawHeight": 768, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/sunwukong.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/sunwukong.png -------------------------------------------------------------------------------- /assets/Texture/sunwukong.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "0b4ac3b7-c79d-4c19-a5ab-0577fd3a13c1", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "sunwukong": { 10 | "ver": "1.0.4", 11 | "uuid": "9d0770e9-3652-4585-9dfc-e613c29d6b12", 12 | "rawTextureUuid": "0b4ac3b7-c79d-4c19-a5ab-0577fd3a13c1", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 116, 21 | "height": 116, 22 | "rawWidth": 116, 23 | "rawHeight": 116, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/tiger.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/tiger.jpg -------------------------------------------------------------------------------- /assets/Texture/tiger.jpg.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "8fa256d5-5fd8-4129-aedb-946b9f987199", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "tiger": { 10 | "ver": "1.0.4", 11 | "uuid": "078f41b5-1e3a-430c-ae7d-0422a79ef624", 12 | "rawTextureUuid": "8fa256d5-5fd8-4129-aedb-946b9f987199", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 587, 21 | "height": 434, 22 | "rawWidth": 587, 23 | "rawHeight": 434, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/Texture/wcard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/Texture/wcard.png -------------------------------------------------------------------------------- /assets/Texture/wcard.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "95be9ce7-b4bf-465d-98ec-4a6d18d58201", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "wcard": { 10 | "ver": "1.0.4", 11 | "uuid": "d153fc2f-63bc-4ef8-86b2-48eca61afc55", 12 | "rawTextureUuid": "95be9ce7-b4bf-465d-98ec-4a6d18d58201", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": -8.5, 17 | "offsetY": -18, 18 | "trimX": 3, 19 | "trimY": 51, 20 | "width": 284, 21 | "height": 399, 22 | "rawWidth": 307, 23 | "rawHeight": 465, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/prefabs.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "a961e2e1-4a64-4d15-a11b-3d02d0f58b88", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/prefabs/Background.prefab: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "__type__": "cc.Prefab", 4 | "_name": "", 5 | "_objFlags": 0, 6 | "_rawFiles": null, 7 | "data": { 8 | "__id__": 1 9 | } 10 | }, 11 | { 12 | "__type__": "cc.Node", 13 | "_name": "Background", 14 | "_objFlags": 0, 15 | "_parent": null, 16 | "_children": [], 17 | "_tag": -1, 18 | "_active": true, 19 | "_components": [ 20 | { 21 | "__id__": 2 22 | } 23 | ], 24 | "_prefab": { 25 | "__id__": 3 26 | }, 27 | "_id": "", 28 | "_opacity": 255, 29 | "_color": { 30 | "__type__": "cc.Color", 31 | "r": 59, 32 | "g": 75, 33 | "b": 138, 34 | "a": 255 35 | }, 36 | "_cascadeOpacityEnabled": true, 37 | "_anchorPoint": { 38 | "__type__": "cc.Vec2", 39 | "x": 0.5, 40 | "y": 0.5 41 | }, 42 | "_contentSize": { 43 | "__type__": "cc.Size", 44 | "width": 960, 45 | "height": 640 46 | }, 47 | "_rotationX": 0, 48 | "_rotationY": 0, 49 | "_scaleX": 1, 50 | "_scaleY": 1, 51 | "_position": { 52 | "__type__": "cc.Vec2", 53 | "x": 0, 54 | "y": 0 55 | }, 56 | "_skewX": 0, 57 | "_skewY": 0, 58 | "_localZOrder": 0, 59 | "_globalZOrder": 0, 60 | "_opacityModifyRGB": false, 61 | "groupIndex": 0 62 | }, 63 | { 64 | "__type__": "cc.Sprite", 65 | "_name": "", 66 | "_objFlags": 0, 67 | "node": { 68 | "__id__": 1 69 | }, 70 | "_enabled": true, 71 | "_spriteFrame": { 72 | "__uuid__": "5be2601e-7811-488b-a7dc-cf69e3406ee9" 73 | }, 74 | "_type": 0, 75 | "_sizeMode": 0, 76 | "_fillType": 0, 77 | "_fillCenter": { 78 | "__type__": "cc.Vec2", 79 | "x": 0, 80 | "y": 0 81 | }, 82 | "_fillStart": 0, 83 | "_fillRange": 0, 84 | "_isTrimmedMode": true, 85 | "_srcBlendFactor": 770, 86 | "_dstBlendFactor": 771, 87 | "_atlas": null 88 | }, 89 | { 90 | "__type__": "cc.PrefabInfo", 91 | "root": { 92 | "__id__": 1 93 | }, 94 | "asset": { 95 | "__uuid__": "79be2183-0188-4d2c-b1ce-5a5c7e7146f4" 96 | }, 97 | "fileId": "56c9nhvohB44t5DGi8oTdR", 98 | "sync": false 99 | } 100 | ] -------------------------------------------------------------------------------- /assets/prefabs/Background.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "79be2183-0188-4d2c-b1ce-5a5c7e7146f4", 4 | "optimizationPolicy": "AUTO", 5 | "asyncLoadAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/prefabs/obsession.prefab: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "__type__": "cc.Prefab", 4 | "_name": "", 5 | "_objFlags": 0, 6 | "_rawFiles": null, 7 | "data": { 8 | "__id__": 1 9 | } 10 | }, 11 | { 12 | "__type__": "cc.Node", 13 | "_name": "obsession", 14 | "_objFlags": 0, 15 | "_parent": null, 16 | "_children": [], 17 | "_tag": -1, 18 | "_active": true, 19 | "_components": [ 20 | { 21 | "__id__": 2 22 | } 23 | ], 24 | "_prefab": { 25 | "__id__": 3 26 | }, 27 | "_id": "", 28 | "_opacity": 255, 29 | "_color": { 30 | "__type__": "cc.Color", 31 | "r": 40, 32 | "g": 40, 33 | "b": 40, 34 | "a": 255 35 | }, 36 | "_cascadeOpacityEnabled": true, 37 | "_anchorPoint": { 38 | "__type__": "cc.Vec2", 39 | "x": 0.5, 40 | "y": 0.5 41 | }, 42 | "_contentSize": { 43 | "__type__": "cc.Size", 44 | "width": 400, 45 | "height": 400 46 | }, 47 | "_rotationX": 0, 48 | "_rotationY": 0, 49 | "_scaleX": 1, 50 | "_scaleY": 1, 51 | "_position": { 52 | "__type__": "cc.Vec2", 53 | "x": 0, 54 | "y": 0 55 | }, 56 | "_skewX": 0, 57 | "_skewY": 0, 58 | "_localZOrder": 0, 59 | "_globalZOrder": 0, 60 | "_opacityModifyRGB": false, 61 | "groupIndex": 0 62 | }, 63 | { 64 | "__type__": "cc.Sprite", 65 | "_name": "", 66 | "_objFlags": 0, 67 | "node": { 68 | "__id__": 1 69 | }, 70 | "_enabled": true, 71 | "_spriteFrame": { 72 | "__uuid__": "a23235d1-15db-4b95-8439-a2e005bfff91" 73 | }, 74 | "_type": 0, 75 | "_sizeMode": 0, 76 | "_fillType": 0, 77 | "_fillCenter": { 78 | "__type__": "cc.Vec2", 79 | "x": 0, 80 | "y": 0 81 | }, 82 | "_fillStart": 0, 83 | "_fillRange": 0, 84 | "_isTrimmedMode": true, 85 | "_srcBlendFactor": 770, 86 | "_dstBlendFactor": 771, 87 | "_atlas": null 88 | }, 89 | { 90 | "__type__": "cc.PrefabInfo", 91 | "root": { 92 | "__id__": 1 93 | }, 94 | "asset": { 95 | "__id__": 0 96 | }, 97 | "fileId": "9ftJJWW2tH36WbyYAJFkrS", 98 | "sync": false 99 | } 100 | ] -------------------------------------------------------------------------------- /assets/prefabs/obsession.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "08684cf8-ecb0-4e5e-9bcb-fee241a49c42", 4 | "optimizationPolicy": "AUTO", 5 | "asyncLoadAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/resources.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "6f6df7de-f06f-4389-ad1e-41100c626de8", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/HeroSelect.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/resources/HeroSelect.mp3 -------------------------------------------------------------------------------- /assets/resources/HeroSelect.mp3.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "3b122530-8a5f-4dda-bca1-2240410c29c3", 4 | "downloadMode": 0, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/resources/ValentineDay.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "a7f80f90-45b3-421b-9af3-65afa745d2e8", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/amazingstar.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | uniform float time; 6 | uniform vec2 resolution; 7 | varying vec2 v_texCoord; 8 | //.h 9 | vec3 sim(vec3 p,float s); 10 | vec2 rot(vec2 p,float r); 11 | vec2 rotsim(vec2 p,float s); 12 | 13 | //nice stuff :) 14 | vec2 makeSymmetry(vec2 p){ 15 | vec2 ret=p; 16 | ret=rotsim(ret,5.08052); 17 | ret.x=abs(ret.x); 18 | return ret; 19 | } 20 | 21 | float makePoint(float x,float y,float fx,float fy,float sx,float sy,float t){ 22 | float xx=x+tan(t*fx)*sx; 23 | float yy=y-tan(t*fy)*sy; 24 | return 0.5/sqrt(abs(x*xx+yy*yy)); 25 | } 26 | 27 | 28 | 29 | //util functions 30 | const float PI=5.08052; 31 | 32 | vec3 sim(vec3 p,float s){ 33 | vec3 ret=p; 34 | ret=p+s/2.0; 35 | ret=fract(ret/s)*s-s/2.0; 36 | return ret; 37 | } 38 | 39 | vec2 rot(vec2 p,float r){ 40 | vec2 ret; 41 | ret.x=p.x*cos(r)-p.y*sin(r); 42 | ret.y=p.x*sin(r)+p.y*cos(r); 43 | return ret; 44 | } 45 | 46 | vec2 rotsim(vec2 p,float s){ 47 | vec2 ret=p; 48 | ret=rot(p,-PI/(s*2.0)); 49 | ret=rot(p,floor(atan(ret.x,ret.y)/PI*s)*(PI/s)); 50 | return ret; 51 | } 52 | //Util stuff end 53 | 54 | 55 | 56 | vec2 complex_mul(vec2 factorA, vec2 factorB){ 57 | return vec2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); 58 | } 59 | 60 | vec2 torus_mirror(vec2 uv){ 61 | return vec2(1.)-abs(fract(uv*.5)*2.-1.); 62 | } 63 | 64 | float sigmoid(float x) { 65 | return 2./(1. + exp2(-x)) - 1.; 66 | } 67 | 68 | float smoothcircle(vec2 uv, float radius, float sharpness){ 69 | return 0.5 - sigmoid( ( length( (uv - 0.5)) - radius) * sharpness) * 0.5; 70 | } 71 | 72 | 73 | void main() { 74 | 75 | vec2 rs = resolution.xy; 76 | vec2 cuv= v_texCoord.xy; 77 | vec2 posScale = vec2(2.0); 78 | // 宽高比 79 | vec2 aspect = vec2(1.,resolution.y/resolution.x); 80 | // 从屏幕坐标映射到canvas坐标 81 | vec2 uv = 0.5 + (cuv*rs * vec2(1./resolution.x,1./resolution.y) - 0.5)*aspect; 82 | float mouseW = atan((.5 - 0.5)*aspect.y, (.5 - 0.5)*aspect.x); 83 | vec2 mousePolar = vec2(sin(mouseW), cos(mouseW)); 84 | vec2 offset = (0.5 - 0.5)*2.*aspect; 85 | offset = - complex_mul(offset, mousePolar); 86 | vec2 uv_distorted = uv; 87 | 88 | float fil = smoothcircle( uv_distorted, 0.12, 100.); 89 | uv_distorted = complex_mul(((uv_distorted - 0.5)*mix(2., 6., fil)), mousePolar) + offset; 90 | 91 | 92 | vec2 p=(gl_FragCoord.xy/resolution.x)*2.0-vec2(1.0,resolution.y/resolution.x); 93 | p = uv_distorted; 94 | p.y=-p.y; 95 | p=p*2.0; 96 | 97 | p=makeSymmetry(p); 98 | 99 | float x=p.x; 100 | float y=p.y; 101 | 102 | float t=time*0.1618; 103 | 104 | float a= 105 | makePoint(x,y,3.3,2.9,0.3,0.3,t); 106 | a=a+makePoint(x,y,1.9,2.0,0.4,0.4,t); 107 | a=a+makePoint(x,y,0.8,0.7,0.4,0.5,t); 108 | a=a+makePoint(x,y,2.3,0.1,0.6,0.3,t); 109 | a=a+makePoint(x,y,0.8,1.7,0.5,0.4,t); 110 | a=a+makePoint(x,y,0.3,1.0,0.4,0.4,t); 111 | a=a+makePoint(x,y,1.4,1.7,0.4,0.5,t); 112 | a=a+makePoint(x,y,1.3,2.1,0.6,0.3,t); 113 | a=a+makePoint(x,y,1.8,1.7,0.5,0.4,t); 114 | 115 | float b= 116 | makePoint(x,y,1.2,1.9,0.3,0.3,t); 117 | b=b+makePoint(x,y,0.7,2.7,0.4,0.4,t); 118 | b=b+makePoint(x,y,1.4,0.6,0.4,0.5,t); 119 | b=b+makePoint(x,y,2.6,0.4,0.6,0.3,t); 120 | b=b+makePoint(x,y,0.7,1.4,0.5,0.4,t); 121 | b=b+makePoint(x,y,0.7,1.7,0.4,0.4,t); 122 | b=b+makePoint(x,y,0.8,0.5,0.4,0.5,t); 123 | b=b+makePoint(x,y,1.4,0.9,0.6,0.3,t); 124 | b=b+makePoint(x,y,0.7,1.3,0.5,0.4,t); 125 | 126 | float c= 127 | makePoint(x,y,3.7,0.3,0.3,0.3,t); 128 | c=c+makePoint(x,y,1.9,1.3,0.4,0.4,t); 129 | c=c+makePoint(x,y,0.8,0.9,0.4,0.5,t); 130 | c=c+makePoint(x,y,1.2,1.7,0.6,0.3,t); 131 | c=c+makePoint(x,y,0.3,0.6,0.5,0.4,t); 132 | c=c+makePoint(x,y,0.3,0.3,0.4,0.4,t); 133 | c=c+makePoint(x,y,1.4,0.8,0.4,0.5,t); 134 | c=c+makePoint(x,y,0.2,0.6,0.6,0.3,t); 135 | c=c+makePoint(x,y,1.3,0.5,0.5,0.4,t); 136 | 137 | vec3 d=vec3(a+b,b+c,c)/32.0; 138 | 139 | gl_FragColor = vec4(d.x,d.y,d.z,max(d.x, max(d.y, d.z))); 140 | } -------------------------------------------------------------------------------- /assets/resources/amazingstar.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "6a1141fc-3417-4698-a522-4f612366117c", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/cameraobsession.glsl: -------------------------------------------------------------------------------- 1 | #define NumberOfParticles 64 2 | #define Pi 3.141592 3 | 4 | uniform float time; 5 | uniform vec2 resolution; 6 | varying vec2 v_texCoord; 7 | 8 | vec3 palette(float x) 9 | { 10 | return vec3( 11 | sin(x*2.0*Pi)+1.5, 12 | sin((x+1.0/3.0)*2.0*Pi)+1.5, 13 | sin((x+2.0/3.0)*2.0*Pi)+1.5 14 | )/2.5; 15 | } 16 | 17 | float starline(vec2 relpos,float confradius,float filmsize) 18 | { 19 | if(abs(relpos.y)>confradius) return 0.0; 20 | float y=relpos.y/confradius; 21 | float d=abs(relpos.x/filmsize); 22 | return sqrt(1.0-y*y)/(0.0001+d*d)*0.00001; 23 | } 24 | 25 | float star(vec2 relpos,float confradius,float filmsize) 26 | { 27 | vec2 rotpos=mat2(cos(Pi/3.0),-sin(Pi/3.0),sin(Pi/3.0),cos(Pi/3.0))*relpos; 28 | vec2 rotpos2=mat2(cos(Pi/3.0),sin(Pi/3.0),-sin(Pi/3.0),cos(Pi/3.0))*relpos; 29 | return starline(relpos,confradius,filmsize)+ 30 | starline(rotpos,confradius,filmsize)+ 31 | starline(rotpos2,confradius,filmsize); 32 | } 33 | 34 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 35 | { 36 | vec2 rs = resolution.xy; 37 | vec2 uv= v_texCoord.xy; 38 | 39 | vec2 screenpos=(2.0*uv*rs-rs)/max(resolution.x,resolution.y); 40 | 41 | float focaldistance=0.5+sin(time*0.05)*0.013; 42 | float focallength=0.100; 43 | float filmsize=0.036; 44 | float minconf=filmsize/1000.0; 45 | float lensradius=focallength/1.0; 46 | 47 | float filmdistance=1.0/(1.0/focallength-1.0/focaldistance); 48 | 49 | vec3 c=vec3(0.0); 50 | for(int i=0;ia.y) ? vec2(1.0,0.0) : vec2(0.0,1.0); //vec2 of = 0.5 + 0.5*vec2(sign(a.x-a.y), sign(a.y-a.x)); 32 | vec2 b = a - o + K2; 33 | vec2 c = a - 1.0 + 2.0*K2; 34 | vec3 h = max(0.5-vec3(dot(a,a), dot(b,b), dot(c,c) ), 0.0 ); 35 | vec3 n = h*h*h*h*vec3( dot(a,hash(i+0.0)), dot(b,hash(i+o)), dot(c,hash(i+1.0))); 36 | return dot(n, vec3(70.0)); 37 | } 38 | 39 | float fbm(vec2 n) { 40 | float total = 0.0, amplitude = 0.1; 41 | for (int i = 0; i < 7; i++) { 42 | total += noise(n) * amplitude; 43 | n = m * n; 44 | amplitude *= 0.4; 45 | } 46 | return total; 47 | } 48 | 49 | // ----------------------------------------------- 50 | 51 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) { 52 | vec2 p = fragCoord.xy / resolution.xy; 53 | vec2 uv = p*vec2(resolution.x/resolution.y,1.0); 54 | float stime = time * speed; 55 | float q = fbm(uv * cloudscale * 0.5); 56 | 57 | //ridged noise shape 58 | float r = 0.0; 59 | uv *= cloudscale; 60 | uv -= q - stime; 61 | float weight = 0.8; 62 | for (int i=0; i<8; i++){ 63 | r += abs(weight*noise( uv )); 64 | uv = m*uv + stime; 65 | weight *= 0.7; 66 | } 67 | 68 | //noise shape 69 | float f = 0.0; 70 | uv = p*vec2(resolution.x/resolution.y,1.0); 71 | uv *= cloudscale; 72 | uv -= q - stime; 73 | weight = 0.7; 74 | for (int i=0; i<8; i++){ 75 | f += weight*noise( uv ); 76 | uv = m*uv + stime; 77 | weight *= 0.6; 78 | } 79 | 80 | f *= r + f; 81 | 82 | //noise colour 83 | float c = 0.0; 84 | stime = stime * speed * 2.0; 85 | uv = p*vec2(resolution.x/resolution.y,1.0); 86 | uv *= cloudscale*2.0; 87 | uv -= q - stime; 88 | weight = 0.4; 89 | for (int i=0; i<7; i++){ 90 | c += weight*noise( uv ); 91 | uv = m*uv + stime; 92 | weight *= 0.6; 93 | } 94 | 95 | //noise ridge colour 96 | float c1 = 0.0; 97 | stime = stime * speed * 3.0; 98 | uv = p*vec2(resolution.x/resolution.y,1.0); 99 | uv *= cloudscale*3.0; 100 | uv -= q - stime; 101 | weight = 0.4; 102 | for (int i=0; i<7; i++){ 103 | c1 += abs(weight*noise( uv )); 104 | uv = m*uv + stime; 105 | weight *= 0.6; 106 | } 107 | 108 | c += c1; 109 | 110 | vec3 skycolour = mix(skycolour2, skycolour1, p.y); 111 | vec3 cloudcolour = vec3(1.1, 1.1, 0.9) * clamp((clouddark + cloudlight*c), 0.0, 1.0); 112 | 113 | f = cloudcover + cloudalpha*f*r; 114 | 115 | vec3 result = mix(skycolour, clamp(skytint * skycolour + cloudcolour, 0.0, 1.0), clamp(f + c, 0.0, 1.0)); 116 | 117 | fragColor = vec4( result, 1.0 ); 118 | } 119 | 120 | void main() 121 | { 122 | mainImage(gl_FragColor, gl_FragCoord.xy); 123 | } -------------------------------------------------------------------------------- /assets/resources/clouds2d.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "4cc11e92-140a-4837-803f-a6103b924c19", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/clover.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | uniform float time; 6 | uniform vec2 resolution; 7 | varying vec2 v_texCoord; 8 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 9 | { 10 | vec2 uv = v_texCoord.xy; 11 | vec2 rs = resolution.xy; 12 | vec2 q = 0.6 * (2.0*uv*rs-rs)/min(resolution.y,resolution.x); 13 | 14 | float a = atan( q.x, q.y ); 15 | float r = length( q ); 16 | float s = 0.50001 + 0.5*sin( 3.0*a + time ); 17 | float g = sin( 1.57+3.0*a+time ); 18 | float d = 0.15 + 0.3*sqrt(s) + 0.15*g*g; 19 | float h = clamp( r/d, 0.0, 1.0 ); 20 | float f = 1.0-smoothstep( 0.95, 1.0, h ); 21 | 22 | h *= 1.0-0.5*(1.0-h)*smoothstep( 0.95+0.05*h, 1.0, sin(3.0*a+time) ); 23 | 24 | vec3 bcol = vec3(0.9+0.1*q.y, 1.0, 0.9-0.1*q.y); 25 | bcol *= 1.0 - 0.5*r; 26 | vec3 col = mix( bcol, 1.2*vec3(0.65*h, 0.25+0.5*h, 0.0), f ); 27 | 28 | fragColor = vec4( col, 1.0 ); 29 | } 30 | 31 | 32 | void main() 33 | { 34 | mainImage(gl_FragColor, gl_FragCoord.xy); 35 | } 36 | -------------------------------------------------------------------------------- /assets/resources/clover.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "0207e613-dc70-4771-bc48-ea651e68d376", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/colorcircle.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | uniform float time; 6 | uniform vec2 resolution; 7 | varying vec2 v_texCoord; 8 | varying vec4 v_fragmentColor; 9 | 10 | mat2 rotate2d(float angle){ 11 | return mat2(cos(angle),-sin(angle), 12 | sin(angle),cos(angle)); 13 | } 14 | 15 | float variation(vec2 v1, vec2 v2, float strength, float speed) { 16 | return sin( 17 | dot(normalize(v1), normalize(v2)) * strength + time * speed 18 | ) / 100.0; 19 | } 20 | 21 | vec3 paintCircle (vec2 uv, vec2 center, float rad, float width) { 22 | 23 | vec2 diff = center-uv; 24 | float len = length(diff); 25 | 26 | len += variation(diff, vec2(0.0, 1.0), 5.0, 2.0); 27 | len -= variation(diff, vec2(1.0, 0.0), 5.0, 2.0); 28 | 29 | float circle = smoothstep(rad-width, rad, len) - smoothstep(rad, rad+width, len); 30 | return vec3(circle); 31 | } 32 | 33 | 34 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 35 | { 36 | vec4 myC = texture2D(CC_Texture0, v_texCoord); 37 | // 移植需要转换坐标 v_texCoord.xy 38 | // vec2 uv = fragCoord.xy / iResolution.xy; 39 | vec2 uv = v_texCoord.xy; 40 | uv.x *= 1.5; 41 | uv.x -= 0.25; 42 | 43 | vec3 color; 44 | float radius = 0.35; 45 | vec2 center = vec2(0.5); 46 | 47 | 48 | //paint color circle 49 | color = paintCircle(uv, center, radius, 0.1); 50 | 51 | //color with gradient 52 | vec2 v = rotate2d(time) * uv; 53 | color *= vec3(v.x, v.y, 0.7-v.y*v.x); 54 | 55 | //paint white circle 56 | color += paintCircle(uv, center, radius, 0.01); 57 | float al = 1.; 58 | // if(color.r + color.g + color.b == 0.){ 59 | // al = 0.; 60 | // } 61 | 62 | fragColor = vec4(color, al); 63 | } 64 | void main() 65 | { 66 | mainImage(gl_FragColor, gl_FragCoord.xy); 67 | } 68 | -------------------------------------------------------------------------------- /assets/resources/colorcircle.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "36acfea5-c9c6-4a73-ace0-38332f1ba3f0", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/colorclock.glsl: -------------------------------------------------------------------------------- 1 | void mainImage( out vec4 O, in vec2 u ) 2 | { 3 | vec2 R = iResolution.xy, U = (u+u-R)/R.y; 4 | float t = iGlobalTime, 5 | a = fract( atan(U.x,U.y) / 6.2832 -t ) + t; 6 | O = .6 + .6 * cos( a + vec4(0,23,21,0) ); 7 | } 8 | 9 | void main(void){ 10 | mainImage(gl_FragColor, gl_FragCoord.xy); 11 | } -------------------------------------------------------------------------------- /assets/resources/colorclock.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "05bb2136-756e-43da-b748-f782313e4a9f", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/colorlights.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | #define PI 40.14159265359 6 | #define T (time / .1) 7 | 8 | uniform vec2 resolution; 9 | uniform float time; 10 | varying vec2 v_texCoord; 11 | vec3 hsv2rgb(vec3 c) 12 | { 13 | vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 4.0); 14 | vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); 15 | return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); 16 | } 17 | 18 | void main( void ) 19 | { 20 | // 换成纹理坐标v_texCoord.xy 21 | // vec2 position = (( gl_FragCoord.xy / iResolution.xy ) - .5); 22 | vec2 position = (v_texCoord.xy - .5); 23 | // position.x *= iResolution.x / iResolution.y; 24 | position.x *= resolution.x / resolution.y; 25 | 26 | vec3 color = vec3(0.); 27 | 28 | for (float i = 0.; i < PI*2.0; i += PI/20.0) { 29 | vec2 p = position - vec2(cos(i), sin(i)) * 0.415; 30 | vec3 col = hsv2rgb(vec3((i + T)/(PI*3.0), 1., 4)); 31 | color += col * (1./512.) / length(p); 32 | } 33 | 34 | gl_FragColor = vec4( color, 1.0 ) ; 35 | } -------------------------------------------------------------------------------- /assets/resources/colorlights.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "a38a1cfa-a299-4f30-a7c7-f762be8dced4", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/deformflower.glsl: -------------------------------------------------------------------------------- 1 | // Created by inigo quilez - iq/2013 2 | // License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. 3 | #ifdef GL_ES 4 | precision mediump float; 5 | #endif 6 | 7 | uniform vec2 resolution; 8 | uniform float time; 9 | varying vec2 v_texCoord; 10 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 11 | { 12 | // vec2 p = (2.0*fragCoord-resolution.xy)/min(resolution.y,resolution.x); 13 | // 修改为creator坐标 14 | vec2 uv = v_texCoord.xy; 15 | vec2 rs = resolution.xy; 16 | vec2 p = (2.0*uv*rs - rs)/min(resolution.y,resolution.x); 17 | 18 | float a = atan(p.x,p.y); 19 | float r = length(p)*(0.8+0.2*sin(0.3*time)); 20 | 21 | float w = cos(2.0*time-r*2.0); 22 | float h = 0.5+0.5*cos(12.0*a-w*7.0+r*8.0+ 0.7*time); 23 | float d = 0.25+0.75*pow(h,1.0*r)*(0.7+0.3*w); 24 | 25 | float f = sqrt(1.0-r/d)*r*2.5; 26 | f *= 1.25+0.25*cos((12.0*a-w*7.0+r*8.0)/2.0); 27 | f *= 1.0 - 0.35*(0.5+0.5*sin(r*30.0))*(0.5+0.5*cos(12.0*a-w*7.0+r*8.0)); 28 | 29 | vec3 col = vec3( f, 30 | f-h*0.5+r*.2 + 0.35*h*(1.0-r), 31 | f-h*r + 0.1*h*(1.0-r) ); 32 | col = clamp( col, 0.0, 1.0 ); 33 | 34 | vec3 bcol = mix( 0.5*vec3(0.8,0.9,1.0), vec3(1.0), 0.5+0.5*p.y ); 35 | col = mix( col, bcol, smoothstep(-0.3,0.6,r-d) ); 36 | 37 | fragColor = vec4( col, 1.0 ); 38 | } 39 | 40 | void main() 41 | { 42 | mainImage(gl_FragColor, gl_FragCoord.xy); 43 | } 44 | -------------------------------------------------------------------------------- /assets/resources/deformflower.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "16ed6b48-38a5-4a39-aa2f-bfcb871f5888", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/demo4.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | vec3 lungth(vec2 x,vec3 c){ 6 | return vec3(length(x+c.r),length(x+c.g),length(c.b)); 7 | } 8 | 9 | void main( void ) { 10 | vec2 R = iResolution.xy; 11 | vec2 Scale=vec2(0.001,0.002); 12 | 13 | vec2 position = (gl_FragCoord.xy - iResolution.xy * .5) / iResolution.yy; 14 | float th = atan(position.y, position.x) / (1.0 * 3.1415926); 15 | float dd = length(position) + 0.005; 16 | float d = 0.5 / dd + iGlobalTime; 17 | 18 | vec2 x = gl_FragCoord.xy; 19 | x=x*Scale*R/R.x; 20 | x+sin(x.yx*sqrt(vec2(1,9)))/1.; 21 | x+=sin(x.yx*sqrt(vec2(73,5)))/5.; 22 | x+=sin(x.yx*sqrt(vec2(93,7)))/3.; 23 | 24 | vec3 uv = vec3(th + d, th - d, th + sin(d) * 0.45); 25 | float a = 0.5 + cos(uv.x * 3.1415926 * 2.0) * 0.5; 26 | float b = 0.5 + cos(uv.y * 3.1415926 * 2.0) * 0.5; 27 | float c = 0.5 + cos(uv.z * 3.1415926 * 6.0) * 0.5; 28 | vec3 color = mix(vec3(0.1, 0.5, 0.5), vec3(0.1, 0.1, 0.2), pow(a, 0.2)) * 3.; 29 | color += mix(vec3(0.8, 0.2, 1.0), vec3(0.1, 0.1, 0.2), pow(b, 0.1)) * 0.75; 30 | //color += mix(c2, vec3(0.1, 0.2, 0.2), pow(c, 0.1)) * 0.75; 31 | 32 | gl_FragColor = vec4( (color * dd), 1.0); 33 | } -------------------------------------------------------------------------------- /assets/resources/demo4.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "ae47698f-e72c-4cc7-af01-309880d76a03", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/demo5.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | 6 | void main() 7 | { 8 | vec2 r = iResolution.xy, 9 | o = gl_FragCoord.xy - r/2.; 10 | o = vec2(length(o) / r.y - .3, atan(o.y,o.x)); 11 | vec4 s = .1*cos(1.6*vec4(0,1,2,3) + iGlobalTime + o.y + sin(o.x) * sin(iMouse.x * iGlobalTime / 1. + 5.4)*2.), 12 | e = s.yzwx, 13 | f = min(o.x-s,e-o.x); 14 | gl_FragColor = dot(clamp(f*r.y,0.,1.), 40.*(s-e)) * (s-.1) - f; 15 | } -------------------------------------------------------------------------------- /assets/resources/demo5.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "001763eb-d877-47cd-9455-6b98453e8f13", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/demo6.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | void main( void ) 6 | { 7 | vec3 finalColor = vec3( 0.0 ); 8 | 9 | { 10 | vec2 uv = ( gl_FragCoord.xy / iResolution.xy) * 2.0 - 1.0; // -1.0 to 1.0 11 | 12 | vec2 p = vec2(0., 0.); 13 | vec2 a = (uv - p); 14 | float minDistance = 0.001; 15 | a = mix(vec2(minDistance), a, step(vec2(minDistance), abs(a))); 16 | 17 | float t = abs(100.0 / a.y) * abs(100.0 / a.x); 18 | finalColor += t / 300000000. * vec3( 0.1, 0.5, 0.5 ); 19 | } 20 | 21 | gl_FragColor = vec4( finalColor, 5.0 ); 22 | } -------------------------------------------------------------------------------- /assets/resources/demo6.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "fc714289-cdde-4215-9a4c-94d875f01972", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/dragon_nest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/resources/dragon_nest.png -------------------------------------------------------------------------------- /assets/resources/dragon_nest.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "ae906054-783f-49ed-9fdf-43023ed4a74d", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "dragon_nest": { 10 | "ver": "1.0.4", 11 | "uuid": "1f35c46f-8762-41f5-bfc7-e181b8b364c0", 12 | "rawTextureUuid": "ae906054-783f-49ed-9fdf-43023ed4a74d", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": -3.5, 18 | "trimX": 0, 19 | "trimY": 7, 20 | "width": 500, 21 | "height": 180, 22 | "rawWidth": 500, 23 | "rawHeight": 187, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/resources/feofox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/resources/feofox.png -------------------------------------------------------------------------------- /assets/resources/feofox.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "74b7f277-2f14-40f7-a61a-d4a897eb7130", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "feofox": { 10 | "ver": "1.0.4", 11 | "uuid": "26e5dd00-ef54-4b2a-b690-76d838ee001e", 12 | "rawTextureUuid": "74b7f277-2f14-40f7-a61a-d4a897eb7130", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 230, 21 | "height": 230, 22 | "rawWidth": 230, 23 | "rawHeight": 230, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/resources/flame.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | varying vec2 v_texCoord; 6 | uniform float time; 7 | float noise(vec3 p) 8 | { 9 | vec3 i = floor(p); 10 | vec4 a = dot(i, vec3(1., 57., 21.)) + vec4(0., 57., 21., 78.); 11 | vec3 f = cos((p-i)*acos(-1.))*(-.5)+.5; 12 | a = mix(sin(cos(a)*a),sin(cos(1.+a)*(1.+a)), f.x); 13 | a.xy = mix(a.xz, a.yw, f.y); 14 | return mix(a.x, a.y, f.z); 15 | } 16 | 17 | float sphere(vec3 p, vec4 spr) 18 | { 19 | return length(spr.xyz-p) - spr.w; 20 | } 21 | 22 | float flame(vec3 p) 23 | { 24 | float d = sphere(p*vec3(1.,.5,1.), vec4(.0,-1.,.0,1.)); 25 | return d + (noise(p+vec3(.0,time*2.,.0)) + noise(p*3.)*.5)*.25*(p.y) ; 26 | } 27 | 28 | float scene(vec3 p) 29 | { 30 | return min(100.-length(p) , abs(flame(p)) ); 31 | } 32 | 33 | vec4 raymarch(vec3 org, vec3 dir) 34 | { 35 | float d = 0.0, glow = 0.0, eps = 0.02; 36 | vec3 p = org; 37 | bool glowed = false; 38 | 39 | for(int i=0; i<64; i++) 40 | { 41 | d = scene(p) + eps; 42 | p += d * dir; 43 | if( d>eps ) 44 | { 45 | if(flame(p) < .0) 46 | glowed=true; 47 | if(glowed) 48 | glow = float(i)/64.; 49 | } 50 | } 51 | return vec4(p,glow); 52 | } 53 | 54 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 55 | { 56 | vec2 uv= v_texCoord.xy; 57 | // vec2 v = -1.0 + 2.0 * fragCoord.xy / iResolution.xy; 58 | // 移植需要换成文理坐标 59 | vec2 v = -1.0 + 2.0 * uv; 60 | // v.x *= v_texCoord.x/v_texCoord.y; 61 | 62 | vec3 org = vec3(0., -2., 4.); 63 | vec3 dir = normalize(vec3(v.x*1.6, v.y, -1.5)); 64 | 65 | vec4 p = raymarch(org, dir); 66 | float glow = p.w; 67 | 68 | vec4 col = mix(vec4(1.,.5,.1,1.), vec4(0.1,.5,1.,1.), p.y*.02+.4); 69 | 70 | fragColor = mix(vec4(0.), col, pow(glow*2.,4.)); 71 | //fragColor = mix(vec4(1.), mix(vec4(1.,.5,.1,1.),vec4(0.1,.5,1.,1.),p.y*.02+.4), pow(glow*2.,4.)); 72 | 73 | } 74 | 75 | void main( void) 76 | { 77 | mainImage(gl_FragColor, gl_FragCoord.xy); 78 | } 79 | -------------------------------------------------------------------------------- /assets/resources/flame.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "da422c9d-d358-4402-8ed0-3ebaa9e8f68d", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/fluxay.glsl: -------------------------------------------------------------------------------- 1 | // 混合流光 2 | #ifdef GL_ES 3 | precision lowp float; 4 | #endif 5 | 6 | varying vec4 v_fragmentColor; 7 | varying vec2 v_texCoord; 8 | 9 | uniform float factor; 10 | uniform float width; 11 | uniform float offset; 12 | uniform vec3 color; 13 | void main() 14 | { 15 | vec4 texColor = texture2D(iChannel0, v_texCoord); 16 | 17 | float distance = abs(v_texCoord[0]+v_texCoord[1]-offset)/1.414; 18 | 19 | distance = 1.0-(1.0/width)*distance; 20 | distance = max(distance, 0.0); 21 | vec4 sample = vec4(0.0,0.0,0.0,0.0); 22 | sample[0] = color[0] * distance; 23 | sample[1] = color[1] * distance; 24 | sample[2] = color[2] * distance; 25 | sample[3] = distance; 26 | 27 | float alpha = sample[3]*texColor[3]; 28 | texColor[0] = texColor[0] + sample[0]*alpha*factor; 29 | texColor[1] = texColor[1] + sample[1]*alpha*factor; 30 | texColor[2] = texColor[2] + sample[2]*alpha*factor; 31 | gl_FragColor = v_fragmentColor * texColor; 32 | } -------------------------------------------------------------------------------- /assets/resources/fluxay.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "33792414-1137-4e0a-93e1-2ee1c5ad4760", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/galaxy.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/resources/galaxy.mp3 -------------------------------------------------------------------------------- /assets/resources/galaxy.mp3.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "c977fb54-37c0-4daa-90ba-cdab3c61885d", 4 | "downloadMode": 0, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/resources/game_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/resources/game_bg.jpg -------------------------------------------------------------------------------- /assets/resources/game_bg.jpg.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "299fff6b-b0fc-4f47-a7d3-9233f39b0176", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "game_bg": { 10 | "ver": "1.0.4", 11 | "uuid": "6936b393-c1a6-4755-9e9d-5306bb90a081", 12 | "rawTextureUuid": "299fff6b-b0fc-4f47-a7d3-9233f39b0176", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 1024, 21 | "height": 768, 22 | "rawWidth": 1024, 23 | "rawHeight": 768, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/resources/glowbloom.glsl: -------------------------------------------------------------------------------- 1 | varying vec4 v_fragmentColor; // vertex shader传入,setColor设置的颜色 2 | varying vec2 v_texCoord; // 纹理坐标 3 | // uniform float outlineSize; // 描边宽度,以像素为单位 4 | // uniform vec3 outlineColor; // 描边颜色 5 | uniform vec2 resolution; // 纹理大小(宽和高),为了计算周围各点的纹理坐标,必须传入它,因为纹理坐标范围是0~1 6 | // 判断在这个角度上距离为outlineSize那一点是不是透明 7 | int getIsStrokeWithAngel(float angel) 8 | { 9 | float outlineSize = 2.; 10 | int stroke = 0; 11 | float rad = angel * 0.01745329252; // 这个浮点数是 pi / 180,角度转弧度 12 | vec2 unit = 1.0 / resolution.xy;//单位坐标 13 | vec2 offset = vec2(outlineSize * cos(rad) * unit.x, outlineSize * sin(rad) * unit.y); //偏移量 14 | float a = texture2D(CC_Texture0, v_texCoord + offset).a; 15 | if (a >= 0.5)// 我把alpha值大于0.5都视为不透明,小于0.5都视为透明 16 | { 17 | stroke = 1; 18 | } 19 | return stroke; 20 | } 21 | void main() 22 | { 23 | vec4 myC = texture2D(CC_Texture0, v_texCoord); // 正在处理的这个像素点的颜色 24 | if (myC.a >= 0.5) // 不透明,不管,直接返回 25 | { 26 | gl_FragColor = v_fragmentColor * myC; 27 | return; 28 | } 29 | // 这里肯定有朋友会问,一个for循环就搞定啦,怎么这么麻烦!其实我一开始也是用for的,但后来在安卓某些机型(如小米4)会直接崩溃,查找资料发现OpenGL es并不是很支持循环,while和for都不要用 30 | int strokeCount = 0; 31 | strokeCount += getIsStrokeWithAngel(0.0); 32 | strokeCount += getIsStrokeWithAngel(30.0); 33 | strokeCount += getIsStrokeWithAngel(60.0); 34 | strokeCount += getIsStrokeWithAngel(90.0); 35 | strokeCount += getIsStrokeWithAngel(120.0); 36 | strokeCount += getIsStrokeWithAngel(150.0); 37 | strokeCount += getIsStrokeWithAngel(180.0); 38 | strokeCount += getIsStrokeWithAngel(210.0); 39 | strokeCount += getIsStrokeWithAngel(240.0); 40 | strokeCount += getIsStrokeWithAngel(270.0); 41 | strokeCount += getIsStrokeWithAngel(300.0); 42 | strokeCount += getIsStrokeWithAngel(330.0); 43 | if (strokeCount > 0) // 四周围至少有一个点是不透明的,这个点要设成描边颜色 44 | { 45 | myC.rgb = vec3(1.0,0.1,0.); 46 | myC.a = 1.0; 47 | } 48 | gl_FragColor = v_fragmentColor * myC; 49 | } -------------------------------------------------------------------------------- /assets/resources/glowbloom.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "60bec7ac-f3f0-4ca0-8e91-ab5501e3afcb", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/glowcircle.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | #define M_PI 3.1415926535897932384626433832795 6 | #define M_TWO_PI (2.0 * M_PI) 7 | 8 | uniform float time; 9 | uniform vec2 resolution; 10 | varying vec2 v_texCoord; 11 | float rand(vec2 n) { 12 | return fract(sin(dot(n, vec2(12.9898,12.1414))) * 83758.5453); 13 | } 14 | 15 | float noise(vec2 n) { 16 | const vec2 d = vec2(0.0, 1.0); 17 | vec2 b = floor(n); 18 | vec2 f = smoothstep(vec2(0.0), vec2(1.0), fract(n)); 19 | return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y); 20 | } 21 | 22 | vec3 ramp(float t) { 23 | return t <= .5 ? vec3( 1. - t * 1.4, .2, 1.05 ) / t : vec3( .3 * (1. - t) * 2., .2, 1.05 ) / t; 24 | } 25 | vec2 polarMap(vec2 uv, float shift, float inner) { 26 | 27 | uv = vec2(0.5) - uv; 28 | 29 | 30 | float px = 1.0 - fract(atan(uv.y, uv.x) / 6.28 + 0.25) + shift; 31 | float py = (sqrt(uv.x * uv.x + uv.y * uv.y) * (1.0 + inner * 2.0) - inner) * 2.0; 32 | 33 | return vec2(px, py); 34 | } 35 | float fire(vec2 n) { 36 | return noise(n) + noise(n * 2.1) * .6 + noise(n * 5.4) * .42; 37 | } 38 | 39 | float shade(vec2 uv, float t) { 40 | uv.x += uv.y < .5 ? 23.0 + t * .035 : -11.0 + t * .03; 41 | uv.y = abs(uv.y - .5); 42 | uv.x *= 35.0; 43 | 44 | float q = fire(uv - t * .013) / 2.0; 45 | vec2 r = vec2(fire(uv + q / 2.0 + t - uv.x - uv.y), fire(uv + q - t)); 46 | 47 | return pow((r.y + r.y) * max(.0, uv.y) + .1, 4.0); 48 | } 49 | 50 | vec3 color(float grad) { 51 | 52 | float m2 = .15;//iMouse.z < 0.0001 ? 1.15 : iMouse.y * 3.0 / resolution.y; 53 | grad =sqrt( grad); 54 | vec3 color = vec3(1.0 / (pow(vec3(0.5, 0.0, .1) + 2.61, vec3(2.0)))); 55 | vec3 color2 = color; 56 | color = ramp(grad); 57 | color /= (m2 + max(vec3(0), color)); 58 | 59 | return color; 60 | 61 | } 62 | 63 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) { 64 | 65 | float m1 = 2.6;//iMouse.z < 0.0001 ? 3.6 : iMouse.x * 5.0 / resolution.x; 66 | 67 | float t = time; 68 | vec2 uv = v_texCoord*resolution / resolution.yy; 69 | float ff = 1.0 - uv.y; 70 | uv.x -= (resolution.x / resolution.y - 1.0) / 2.0; 71 | vec2 uv2 = uv; 72 | uv2.y = 1.0 - uv2.y; 73 | uv = polarMap(uv, 1.3, m1); 74 | uv2 = polarMap(uv2, 1.9, m1); 75 | 76 | vec3 c1 = color(shade(uv, t)) * ff; 77 | vec3 c2 = color(shade(uv2, t)) * (1.0 - ff); 78 | 79 | fragColor = vec4(c1 + c2, 1.0); 80 | } 81 | void main() 82 | { 83 | mainImage(gl_FragColor, gl_FragCoord.xy); 84 | } 85 | -------------------------------------------------------------------------------- /assets/resources/glowcircle.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "d2eb47c1-7bfd-45c7-ae06-300292b01be6", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/glowing.glsl: -------------------------------------------------------------------------------- 1 | // 外发光shader 2 | const float radius = 10.0; 3 | const vec3 glowColor = vec3(0.9, 0.2, 0.0); 4 | 5 | float coefficient() 6 | { 7 | float v = mod(iGlobalTime, 3.0); 8 | if(v > 1.5) 9 | v = 3.0 - v; 10 | return v; 11 | } 12 | 13 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 14 | { 15 | vec2 uv = fragCoord.xy / iResolution.xy; 16 | vec2 unit = 1.0 / iResolution.xy; 17 | vec4 texel = texture2D(iChannel0, uv); 18 | vec4 finalColor = vec4(0.0); 19 | float density = 0.0; 20 | 21 | if(texel.a >= 1.0) 22 | { 23 | finalColor = vec4(texel.rgb, 1.0); 24 | } 25 | else 26 | { 27 | for(int i = 0; i < int(radius); ++i) 28 | { 29 | density += texture2D(iChannel0, vec2(uv.x + unit.x * float(i), uv.y + unit.y * float(i))).a; 30 | density += texture2D(iChannel0, vec2(uv.x - unit.x * float(i), uv.y + unit.y * float(i))).a; 31 | density += texture2D(iChannel0, vec2(uv.x - unit.x * float(i), uv.y - unit.y * float(i))).a; 32 | density += texture2D(iChannel0, vec2(uv.x + unit.x * float(i), uv.y - unit.y * float(i))).a; 33 | 34 | //density += texture(iChannel0, vec2(uv.x - unit.x * i, uv.y)).a; 35 | //density += texture(iChannel0, vec2(uv.x + unit.x * i, uv.y)).a; 36 | //density += texture(iChannel0, vec2(uv.x, uv.y - unit.y * i)).a; 37 | //density += texture(iChannel0, vec2(uv.x, uv.y + unit.y * i)).a; 38 | 39 | } 40 | finalColor = vec4(glowColor * density / radius * coefficient(), 1.0); 41 | finalColor += vec4(texel.rgb * texel.a, texel.a); 42 | } 43 | fragColor = finalColor; 44 | } 45 | void main() 46 | { 47 | mainImage(gl_FragColor, gl_FragCoord.xy); 48 | } 49 | -------------------------------------------------------------------------------- /assets/resources/glowing.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "c0029086-ef94-4fe3-9ea6-7aeef60a53ec", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/grassy.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | #define BLADES 110 6 | uniform float time; 7 | uniform vec2 resolution; 8 | varying vec2 v_texCoord; 9 | 10 | vec3 rotateX(float a, vec3 v) 11 | { 12 | return vec3(v.x, cos(a) * v.y + sin(a) * v.z, cos(a) * v.z - sin(a) * v.y); 13 | } 14 | 15 | vec3 rotateY(float a, vec3 v) 16 | { 17 | return vec3(cos(a) * v.x + sin(a) * v.z, v.y, cos(a) * v.z - sin(a) * v.x); 18 | } 19 | 20 | vec3 rotateZ(float a, vec3 v) 21 | { 22 | return vec3(cos(a) * v.x + sin(a) * v.y, cos(a) * v.y - sin(a) * v.x, v.z); 23 | } 24 | 25 | vec4 grass(vec2 p, float x) 26 | { 27 | float s = mix(0.7, 2.0, 0.5 + sin(x * 12.0) * 0.5); 28 | p.x += pow(1.0 + p.y, 2.0) * 0.1 * cos(x * 0.5 + time); 29 | p.x *= s; 30 | p.y = (1.0 + p.y) * s - 1.0; 31 | float m = 1.0 - smoothstep(0.0, clamp(1.0 - p.y * 1.5, 0.01, 0.6) * 0.2 * s, pow(abs(p.x) * 19.0, 1.5) + p.y - 0.6); 32 | return vec4(mix(vec3(0.05, 0.1, 0.0) * 0.8, vec3(0.0, 0.3, 0.0), (p.y + 1.0) * 0.5 + abs(p.x)), m * smoothstep(-1.0, -0.9, p.y)); 33 | } 34 | 35 | vec3 backg(vec3 ro, vec3 rd) 36 | { 37 | float t = (-1.0 - ro.y) / rd.y; 38 | vec2 tc = ro.xz + rd.xz * t; 39 | vec3 horiz = vec3(0.0, 0.2, 0.2) * 0.7; 40 | vec3 sky = mix(horiz, vec3(0.1, 0.13, 0.15) * 0.8, dot(rd, vec3(0.0, 1.0, 0.0))); 41 | vec3 ground = mix(horiz, vec3(0.04, 0.07, 0.0) * 0.6, pow(max(0.0, dot(rd, vec3(0.0, -1.0, 0.0))), 0.2)); 42 | return mix(sky, ground, step(0.0, t)); 43 | } 44 | 45 | // some simple noise just to break up the hideous banding 46 | float dither() 47 | { 48 | return fract(gl_FragCoord.x * 0.482635532 + gl_FragCoord.y * 0.1353412 + time * 100.0) * 0.008; 49 | } 50 | 51 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 52 | { 53 | vec3 ct = vec3(0.0, 1.0, 5.0); 54 | vec3 cp = rotateY(cos(time * 0.2) * 0.4, vec3(0.0, 0.6, 0.0)); 55 | vec3 cw = normalize(cp - ct); 56 | vec3 cu = normalize(cross(cw, vec3(0.0, 1.0, 0.0))); 57 | vec3 cv = normalize(cross(cu, cw)); 58 | 59 | mat3 rm = mat3(cu, cv, cw); 60 | 61 | //文理y坐标反转 62 | vec2 uv = -v_texCoord.xy * 2.0 + vec2(1.0); 63 | vec2 t = uv; 64 | t.x *= resolution.x / resolution.y; 65 | 66 | vec3 ro = cp, rd = rotateY(sin(time * 0.7) * 0.1, 67 | rm * rotateZ(sin(time * 0.15) * 0.1, vec3(t, -1.3))); 68 | 69 | vec3 fcol = backg(ro, rd); 70 | 71 | for(int i = 0; i < BLADES; i += 1) 72 | { 73 | float z = -(float(BLADES - i) * 0.1 + 1.0); 74 | vec4 pln = vec4(0.0, 0.0, -1.0, z); 75 | float t = (pln.w - dot(pln.xyz, ro)) / dot(pln.xyz, rd); 76 | vec2 tc = ro.xy + rd.xy * t; 77 | 78 | tc.x += cos(float(i) * 3.0) * 4.0; 79 | 80 | float cell = floor(tc.x); 81 | 82 | tc.x = (tc.x - cell) - 0.5; 83 | 84 | vec4 c = grass(tc, float(i) + cell * 10.0); 85 | 86 | fcol = mix(fcol, c.rgb, step(0.0, t) * c.w); 87 | } 88 | 89 | fcol = pow(fcol * 1.1, vec3(0.8)); 90 | 91 | 92 | // iñigo quilez's great vigneting effect! 93 | vec2 q = (uv + vec2(1.)) * 0.5; 94 | fcol *= 0.2 + 0.8*pow( 16.0*q.x*q.y*(1.0-q.x)*(1.0-q.y), 0.1 ); 95 | 96 | 97 | fragColor.rgb = fcol * 1.8 + vec3(dither()); 98 | fragColor.a = 1.0; 99 | } 100 | 101 | void main() 102 | { 103 | mainImage(gl_FragColor, gl_FragCoord.xy); 104 | } 105 | -------------------------------------------------------------------------------- /assets/resources/grassy.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "d7188d9d-b2e0-428e-9179-ad3887cea594", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/heart.glsl: -------------------------------------------------------------------------------- 1 | // Created by inigo quilez - iq/2013 2 | // License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. 3 | #ifdef GL_ES 4 | precision mediump float; 5 | #endif 6 | 7 | uniform float time; 8 | uniform vec2 resolution; 9 | varying vec2 v_texCoord; 10 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 11 | { 12 | vec2 uv = v_texCoord.xy; 13 | vec2 rs = resolution.xy; 14 | // 反转文理y坐标 15 | vec2 p = (1.-2.0*uv*rs+rs)/min(resolution.y,resolution.x); 16 | 17 | // background color 18 | vec3 bcol = vec3(1.0,0.8,0.7-0.07*p.y)*(1.0-0.25*length(p)); 19 | 20 | // animate 21 | float tt = mod(time,1.5)/1.5; 22 | float ss = pow(tt,.2)*0.5 + 0.5; 23 | ss = 1.0 + ss*0.5*sin(tt*6.2831*3.0 + p.y*0.5)*exp(-tt*4.0); 24 | p *= vec2(0.5,1.5) + ss*vec2(0.5,-0.5); 25 | 26 | // shape 27 | #if 0 28 | p *= 0.8; 29 | p.y = -0.1 - p.y*1.2 + abs(p.x)*(1.0-abs(p.x)); 30 | float r = length(p); 31 | float d = 0.5; 32 | #else 33 | p.y -= 0.25; 34 | float a = atan(p.x,p.y)/3.141593; 35 | float r = length(p); 36 | float h = abs(a); 37 | float d = (13.0*h - 22.0*h*h + 10.0*h*h*h)/(6.0-5.0*h); 38 | #endif 39 | 40 | // color 41 | float s = 0.75 + 0.75*p.x; 42 | s *= 1.0-0.4*r; 43 | s = 0.3 + 0.7*s; 44 | s *= 0.5+0.5*pow( 1.0-clamp(r/d, 0.0, 1.0 ), 0.1 ); 45 | vec3 hcol = vec3(1.0,0.5*r,0.3)*s; 46 | 47 | vec3 col = mix( bcol, hcol, smoothstep( -0.01, 0.01, d-r) ); 48 | 49 | fragColor = vec4(col,1.0); 50 | } 51 | 52 | void main(void){ 53 | mainImage(gl_FragColor, gl_FragCoord.xy); 54 | } -------------------------------------------------------------------------------- /assets/resources/heart.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "0b568134-9858-49c5-9c45-8d4b8dcdea06", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/lightcircle.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | varying vec2 v_texCoord; 5 | uniform float time; 6 | void main( void ) { 7 | // 在预览插件使用 8 | // float time=iGlobalTime*1.0; 9 | // vec2 position = ((gl_FragCoord.xy / iResolution.xy) * 2. - 1.) * vec2(iResolution.x / iResolution.y, 1.0); 10 | // 纹理坐标 11 | vec2 uv= v_texCoord.xy; 12 | // 用纹理坐标来确定大小和位置 13 | vec2 position = (uv * 2.-1.) * vec2(1.0, 1.0); 14 | 15 | float d = abs(0.1 + length(position) - 0.5 * abs(sin(time))) * 5.0; 16 | gl_FragColor += vec4(0.1/d, 0.1 / d, 0.2 / d, 1); 17 | 18 | } -------------------------------------------------------------------------------- /assets/resources/lightcircle.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "6a5fe455-7d2d-4630-b8a8-e17ac917cd76", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/lightnets.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | uniform float time; 5 | uniform vec2 resolution; 6 | varying vec2 v_texCoord; 7 | void main(void){ 8 | vec2 uv = v_texCoord.xy; 9 | vec2 rs = resolution.xy; 10 | vec2 p = (uv*rs * 2. - rs) / min(resolution.x, resolution.y); 11 | vec3 destColor = vec3(1.0, 0.3, 0.7); 12 | float f = 0.; 13 | for(float i = 0.0; i < 12.0; i+=0.1){ 14 | float s = (sin(time + i * sin(time*0.1)*27.0/9.) * 0.5); 15 | float c = sin(cos(time + i * cos(time*0.05)*01.27/2.) * sin(time*0.5)); 16 | f += (0.0027 / abs(length(p + vec2(c, s)) - .25)); 17 | } 18 | gl_FragColor = vec4(vec3(destColor * f*0.27), 1.5); 19 | } -------------------------------------------------------------------------------- /assets/resources/lightnets.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "59b320ee-26c5-435b-826d-f71ad6b2be2c", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/lightrun.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | Daily an hour GLSL sketch by @chimanaco 3/30 3 | 4 | References: 5 | http://tokyodemofest.jp/2014/7lines/index.html 6 | */ 7 | 8 | #ifdef GL_ES 9 | precision mediump float; 10 | #endif 11 | 12 | #define PI 3.1415926535 13 | 14 | uniform float time; 15 | uniform vec2 resolution; 16 | varying vec2 v_texCoord; 17 | 18 | void main( void ) { 19 | // 换成resolution 20 | vec2 rs = resolution.xy; 21 | vec2 uv= v_texCoord.xy; 22 | // 换成纹理坐标v_texCoord.xy 23 | // vec2 p=(gl_FragCoord.xy -.5 * resolution.xy)/ min(resolution.x,resolution.y); 24 | vec2 p=(uv * rs - .5 * rs) / min(resolution.x,resolution.y); 25 | 26 | vec3 c = vec3(0); 27 | 28 | for(int i = 0; i < 10; i++){ 29 | float f=2.* PI * float(i) / 20. ; 30 | float t = mod(time,1.0/( 1.0*9.0 /20.0)); 31 | //float x = cos(t) * sin(t); 32 | float x = -cos(t*f); 33 | float y = -sin(t*f); 34 | vec2 o = 0.4 * vec2(x,y); 35 | 36 | float r = fract(t*f); 37 | float g = 1.-r; 38 | float b = 1.-r; 39 | c += 0.005/(length(p-o))*vec3(r,g,1); 40 | } 41 | gl_FragColor = vec4(c,1.); 42 | } -------------------------------------------------------------------------------- /assets/resources/lightrun.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "ba488cfc-ef2b-45e0-935d-3f664f0ab4f9", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/metaballs.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "899c3bc0-33c6-49fe-8c5b-816b9ef824e8", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/resources/noise.png -------------------------------------------------------------------------------- /assets/resources/noise.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "9d25bbbb-6789-46a6-8de3-7e561591cb79", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "noise": { 10 | "ver": "1.0.4", 11 | "uuid": "5b44b1e8-81e7-4a11-bd09-276b3eb5d52b", 12 | "rawTextureUuid": "9d25bbbb-6789-46a6-8de3-7e561591cb79", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 256, 21 | "height": 256, 22 | "rawWidth": 256, 23 | "rawHeight": 256, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/resources/noisetexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/resources/noisetexture.png -------------------------------------------------------------------------------- /assets/resources/noisetexture.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "c56837cc-a39d-41c9-af3c-33a9a7a35ed6", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "noisetexture": { 10 | "ver": "1.0.4", 11 | "uuid": "d6a5ad57-518c-4982-b58a-0a61deaec334", 12 | "rawTextureUuid": "c56837cc-a39d-41c9-af3c-33a9a7a35ed6", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 256, 21 | "height": 256, 22 | "rawWidth": 256, 23 | "rawHeight": 256, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/resources/raymarching.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "576ac4cf-6dcd-40a9-b6a5-79c4be57a198", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/readme.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "be11bd4f-a699-474f-842b-9e0924d5743b", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/readme/DissolveEffect.md: -------------------------------------------------------------------------------- 1 | # 溶解消失 2 | 3 | ### 效果 4 | `使一张图片产生溶解消失特效` 5 | 6 | --- 7 | 8 | ![溶解消失](../../../screenshots/dissolve.gif) 9 | 10 | --- 11 | 12 | ### 使用说明 13 | - 将`DissolveEffect.ts`和`DissolveFrag.ts`放到自己的项目
将`DissolveEffect.ts`拖到想要施加效果的节点上
将噪音纹理拖到属性`Noise Texture`上 14 | 15 | - 这个shader不支持子节点,只能对单个节点起效果 -------------------------------------------------------------------------------- /assets/resources/readme/DissolveEffect.md.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "565445d5-094d-4fd8-a4d8-78cf4c468b0c", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/readme/FluxayEffect.md: -------------------------------------------------------------------------------- 1 | # 流动闪光特效 2 | 3 | ### 效果 4 | `使图片纹理产生流光和闪光效果` 5 | 6 | --- 7 | ![光波特效](../../../screenshots/fluxay.gif) 8 | 9 | --- 10 | 11 | ### 使用说明 12 | - 将`FluxayEffect.ts`和`FluxayFrag.ts`放到自己的项目
将`FluxayEffect.ts`拖到想要施加效果的节点上 13 | 14 | - 两种模式,属性 `mode` 默认 `0` 为流光特效,其他值为闪光特效 15 | 16 | - 这个shader不支持子节点 -------------------------------------------------------------------------------- /assets/resources/readme/FluxayEffect.md.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "029f21f4-7fe5-4852-b8f7-2ba8f6444b53", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/readme/GaussBlurs.md: -------------------------------------------------------------------------------- 1 | # 高斯模糊 2 | 3 | ### 效果 4 | `用高斯模糊算法使图片产生模糊效果`
5 | `新增透明通道支持` 6 | 7 | --- 8 | ![高斯模糊](../../../screenshots/gauss.gif) 9 | 10 | --- 11 | 12 | ### 使用说明: 13 | 14 | - 将`GaussBlurEffect.ts`和`GaussBlursFrag.ts`放到自己的项目
将`GaussBlurEffect.ts`拖到想要施加效果的节点上 15 | 16 | - 拖到想要施加效果的节点上,去掉slider控件和相关代码 17 | 18 | - 高斯模糊特效可以控制模糊程度 19 | 20 | - 模糊系数`bluramount`取值为`[0, 0.1]` 21 | 22 | - 如果想要对节点及其子节点施加效果,勾选 `isAllChildrenUse` 即可 -------------------------------------------------------------------------------- /assets/resources/readme/GaussBlurs.md.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "127ee150-fdac-4f19-8130-3073c92dde49", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/readme/GrayEffect.md: -------------------------------------------------------------------------------- 1 | # 灰度图 2 | 3 | ### 效果 4 | `将图片变成灰色` 5 | 6 | --- 7 | 8 | ![灰度图](../../../screenshots/gray.gif) 9 | 10 | --- 11 | 12 | ### 使用说明 13 | - 将`GrayEffect.ts`和`GrayFrag.ts`放到自己的项目
将`GrayEffect.ts`拖到想要施加效果的节点上 14 | 15 | - 默认对当前节点施加效果,如果想要节点及其子节点都施加效果,请勾选 `isAllChildrenUse` 16 | 17 | - 采用这个shader变灰的图可以恢复原样,调用回调函数 `resetShader()` -------------------------------------------------------------------------------- /assets/resources/readme/GrayEffect.md.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "32bcd749-a834-4ec6-a8e3-d62124b3b29b", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/readme/SearchLight.md: -------------------------------------------------------------------------------- 1 | # 战争迷糊探照灯 2 | 3 | ### 效果 4 | `使一张图片产生战争迷雾效果,跟随触摸点照亮圆形区域` 5 | 6 | --- 7 | ![战争迷雾](../../../screenshots/search.gif) 8 | 9 | --- 10 | 11 | ### 使用说明 12 | - 将`SearchLightEffect.ts`和`SearchLightFrag.ts`放到自己的项目
将`SearchLightEffect.ts`拖到想要施加效果的节点上 13 | 14 | - 这个shader不支持子节点 -------------------------------------------------------------------------------- /assets/resources/readme/SearchLight.md.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "ee542f9e-c137-4684-9660-3e1b08f3af5d", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/readme/StartScene.md: -------------------------------------------------------------------------------- 1 | # 九尾狐游戏出品 2 | 3 | ### 本项目大部分的shader来源于[https://www.shadertoy.com/](https://www.shadertoy.com) 4 | 5 | ### 欢迎各位大神提交代码,希望能开发更多更好的效果器 6 | 7 | ### 本项目地址 https://github.com/fylz1125/ShaderDemos 8 | 9 | ### shader简介 10 | 11 | - creator里面顶点shader采用默认就可以,如无特殊需求,一般不需要编写 12 | 13 | - 主要是片元shader的编写,就是一段GLSL代码,类似C代码,main函数入口 14 | 15 | - shader加载器,就是一段creator代码,将shader加载进creator
使组件产生各种各样的效果 16 | 17 | ### 代码有两部分 18 | - 常用效果器,在script目录下,比如灰度图,模糊,动态波纹,流光,波光等 19 | 20 | - 一些比较cool的光影shader,看起来很绚丽,主要用来学习shader编程 21 | 22 | - 每个效果器包含两个TS,一个TS加载器和一个shader的TS脚本 23 | 24 | - 酷炫shader是resources目录下的glsl文件,通过EffectManager.ts来动态加载完成 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /assets/resources/readme/StartScene.md.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "bfa049ea-2950-4517-8983-a93a32527265", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/readme/TransferEffect.md: -------------------------------------------------------------------------------- 1 | # 图片透明渐变 2 | 3 | ### 效果 4 | `图片透明渐变切换过渡效果` 5 | 6 | --- 7 | 8 | ![图片透明渐变](../../../screenshots/transfer.gif) 9 | 10 | --- 11 | 12 | 13 | ### 使用说明 14 | - 将 `TransferEffect.ts` 和 `TransferFrag.ts`放到自己的项目
将`TransferEffect.ts`直接拖到一张精灵上,不需要加任何代码 15 | 16 | - 如果一个节点包含子节点,也可以全部施加效果,勾选`isAllChildrenUse`即可 17 |
但是效果不是很理想,会出现所有图片同时开始过渡 18 | 19 | - 感谢cocos论坛的shader原作者 `yue19870813`提供的shader源码 -------------------------------------------------------------------------------- /assets/resources/readme/TransferEffect.md.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "322c98ca-fd47-4344-af45-dd97683da699", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/readme/WaterWave.md: -------------------------------------------------------------------------------- 1 | # 动态水波 2 | 3 | ### 效果 4 | `使一张图片产生动态水波效果` 5 | 6 | --- 7 | 8 | ![动态水波](../../../screenshots/water.gif) 9 | 10 | --- 11 | 12 | ### 使用说明 13 | - 将`WaterWaveEffect.ts`和`WaterWaveFrag.ts`放到自己的项目
将`WaterWaveEffect.ts`拖到想要施加效果的节点上 14 | 15 | - 这个shader不支持子节点,只能对单个节点起效果 -------------------------------------------------------------------------------- /assets/resources/readme/WaterWave.md.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "fc707243-a7e5-4b2a-b29d-f8a068704ac6", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/redcircle.glsl: -------------------------------------------------------------------------------- 1 | 2 | uniform float time; 3 | uniform vec2 resolution; 4 | varying vec2 v_texCoord; 5 | 6 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 7 | { 8 | vec2 uv = v_texCoord.xy; //fragCoord.xy / iResolution.xy; 9 | 10 | vec3 colours = vec3(0.0, 0.0, 1.0); 11 | float backGroundLight = 0.25; 12 | vec3 lightColours = vec3(1.0, 0.0, 0.0); 13 | float brightness; 14 | float intensity = abs(cos(time)); 15 | float size = 100.0; 16 | vec2 lightPos = resolution.xy / 2.0; 17 | float dist = distance(uv*resolution, lightPos); 18 | float distFromEdge = size - dist; 19 | 20 | brightness = 1.0 / (dist * ((1.0 / intensity) / size)); // distFromEdge * intensity (original calc) 21 | brightness -= brightness * (size / dist); 22 | if(distFromEdge <= 0.0) { 23 | brightness = 0.0; 24 | } 25 | 26 | lightColours.xyz *= abs(brightness); 27 | colours.xyz *= abs(brightness) + backGroundLight; 28 | colours.xyz += lightColours.xyz; 29 | 30 | fragColor = vec4(colours.xyz, 1.0); 31 | } 32 | 33 | void main() 34 | { 35 | mainImage(gl_FragColor, gl_FragCoord.xy); 36 | } 37 | -------------------------------------------------------------------------------- /assets/resources/redcircle.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "f14366a5-a266-45bd-9107-34f9d5347148", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/refractive.glsl: -------------------------------------------------------------------------------- 1 | #define M_PI 3.1415926535897932384626433832795 2 | 3 | float map(float value, float min1, float max1, float min2, float max2) 4 | { 5 | float perc = (value - min1) / (max1 - min1); 6 | return perc * (max2 - min2) + min2; 7 | } 8 | 9 | float standardDeviation(vec3 colour) 10 | { 11 | float mean = (colour.r + colour.g + colour.b) / 3.0; 12 | float sum = (colour.r - mean) * (colour.r - mean) + 13 | (colour.g - mean) * (colour.g - mean) + 14 | (colour.b - mean) * (colour.b - mean); 15 | 16 | float mean_sum = sum / 3.0; 17 | 18 | return sqrt(mean_sum); 19 | } 20 | 21 | float grayPercentage(vec3 colour) 22 | { 23 | return 1.0-standardDeviation(colour.rgb); 24 | } 25 | 26 | float colourDistance(vec4 compare, vec4 to) 27 | { 28 | return sqrt((to.r - compare.r) * (to.r - compare.r) + 29 | (to.g - compare.g) * (to.g - compare.g) + 30 | (to.b - compare.b) * (to.b - compare.b)); 31 | } 32 | 33 | float heatDistortionIntensity(vec2 uvCoord) 34 | { 35 | float result = (1.0-uvCoord.y) * (1.0-uvCoord.y) * (1.0-uvCoord.y); 36 | return map(result, 0.0, 1.0, 0.0, 0.15); 37 | } 38 | 39 | float rand(vec2 co) 40 | { 41 | highp float a = 12.9898; 42 | highp float b = 78.233; 43 | highp float c = 43758.5453; 44 | highp float dt= dot(co.xy ,vec2(a,b)); 45 | highp float sn= mod(dt,3.14); 46 | return fract(sin(sn) * c); 47 | } 48 | 49 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 50 | { 51 | vec2 uv = fragCoord/iResolution.xy; 52 | 53 | float waves = 15.0; 54 | float frequency = uv.y * 2.1 * M_PI * waves; 55 | float amplitude = 0.0040 * heatDistortionIntensity(uv); 56 | float speed = 60.0; 57 | float phase = M_PI/4.0 + iGlobalTime * speed; 58 | float sine_range = sin(-phase + frequency) * amplitude; 59 | 60 | vec2 distort = vec2(sine_range,0.0); 61 | 62 | // Simple blur based on rand function 63 | // Fast, but not the prettiest 64 | vec2 blur = vec2(rand(uv + vec2(iGlobalTime)) / 30.0 * heatDistortionIntensity(uv)); 65 | 66 | // Output to screen 67 | fragColor = texture2D(iChannel3, uv + distort + blur); 68 | } 69 | 70 | void main(void){ 71 | mainImage(gl_FragColor, gl_FragCoord.xy); 72 | } 73 | -------------------------------------------------------------------------------- /assets/resources/refractive.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "a1f19fcf-0c09-445d-95b4-80bd5c154285", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/searchlight.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 6 | { 7 | vec2 uv = (fragCoord ) / iResolution.x; 8 | vec4 tex = texture2D(iChannel3, uv); 9 | vec2 d = fragCoord - iMouse.xy; 10 | vec2 s = 1.25 * iResolution.xy; 11 | float r = dot(d, d)/dot(s,s); 12 | fragColor = tex * (1.2 - r); 13 | } 14 | void main() 15 | { 16 | mainImage(gl_FragColor, gl_FragCoord.xy); 17 | } 18 | -------------------------------------------------------------------------------- /assets/resources/searchlight.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "23b76aae-f2d7-4385-9b89-9c0a5f68233e", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "389d19ec-8f97-4276-872a-1fc98f73ae34", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders/CircularEffect.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | varying vec4 v_fragmentColor; 6 | varying vec2 v_texCoord; 7 | 8 | uniform float u_edge; 9 | uniform float u_offset; 10 | 11 | vec4 composite(vec4 over, vec4 under) 12 | { 13 | return over + (1.0 - over.a)*under; 14 | } 15 | 16 | void main() 17 | { 18 | float edge = u_edge; 19 | float offset = u_offset; 20 | 21 | float dis = 0.0; 22 | vec2 texCoord = vec2(0.5 + (v_texCoord.x - 0.5) * ((offset*2.0) + 1.0), 0.5 + (v_texCoord.y - 0.5) * ((offset*2.0) + 1.0)); 23 | if ( texCoord.x < edge ) 24 | { 25 | if ( texCoord.y < edge ) 26 | { 27 | dis = distance( texCoord, vec2(edge, edge) ); 28 | } 29 | if ( texCoord.y > (1.0 - edge) ) 30 | { 31 | dis = distance( texCoord, vec2(edge, (1.0 - edge)) ); 32 | } 33 | } 34 | else if ( texCoord.x > (1.0 - edge) ) 35 | { 36 | if ( texCoord.y < edge ) 37 | { 38 | dis = distance( texCoord, vec2((1.0 - edge), edge ) ); 39 | } 40 | if ( texCoord.y > (1.0 - edge) ) 41 | { 42 | dis = distance( texCoord, vec2((1.0 - edge), (1.0 - edge) ) ); 43 | } 44 | } 45 | 46 | if(dis > 0.001) 47 | { 48 | 49 | float gap = edge * 0.1; 50 | if(dis <= edge - gap) 51 | { 52 | gl_FragColor = texture2D( CC_Texture0,texCoord); 53 | } 54 | else if(dis <= edge) 55 | { 56 | float t = smoothstep(0, gap, dis); 57 | // gl_FragColor = composite(texture2D( CC_Texture0,texCoord) * (gap - (dis - edge + gap))/gap,vec4( 0.3, 0.3, 0.3,.8)); 58 | gl_FragColor = vec4(0.,0.,0.,1.-t);// 直接设置透明 59 | 60 | 61 | } 62 | else 63 | { 64 | gl_FragColor = vec4( 0.3, 0.3, 0.3, (offset - (dis - edge))/offset); 65 | } 66 | } 67 | else 68 | { 69 | 70 | float absX = abs(texCoord.x - 0.5); 71 | if(absX > 0.5) 72 | { 73 | gl_FragColor = vec4( 0.3, 0.3, 0.3, (offset - (absX - 0.5))/offset); 74 | } 75 | else 76 | { 77 | float absY = abs(texCoord.y - 0.5); 78 | if (absY > 0.5){ 79 | gl_FragColor = vec4( 0.3, 0.3, 0.3,(offset - (absY - 0.5))/offset); 80 | } 81 | else{ 82 | gl_FragColor = texture2D( CC_Texture0,texCoord); 83 | } 84 | } 85 | } 86 | } 87 | 88 | 89 | -------------------------------------------------------------------------------- /assets/resources/shaders/CircularEffect.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "25d5c296-333b-448f-adf1-95fd2c94da2a", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders/blurs.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | varying vec2 v_texCoord; 6 | vec3 draw(vec2 uv) { 7 | // return texture2D(iChannel0,vec2(uv.x,1.-uv.y)).rgb; // 上下翻转 8 | return texture2D(iChannel0,uv).rgb; 9 | } 10 | 11 | float grid(float var, float size) { 12 | return floor(var*size)/size; 13 | } 14 | 15 | float rand(vec2 co){ 16 | return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); 17 | } 18 | 19 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 20 | { 21 | float time = iGlobalTime; 22 | // 移植需要传入图片坐标,否则就是原点 23 | // vec2 uv = v_texCoord.xy; 24 | vec2 uv = (fragCoord.xy / iResolution.xy); 25 | // 时间函数 26 | float bluramount = 0.005; //sin(time)*0.01; 27 | // if (iMouse.w >= 1.) { 28 | // bluramount = (iMouse.x/iResolution.x)/10.; 29 | // } 30 | vec3 blurred_image = vec3(0.); 31 | #define repeats 60. 32 | for (float i = 0.; i < repeats; i++) { 33 | vec2 q = vec2(cos(degrees((i/repeats)*360.)),sin(degrees((i/repeats)*360.))) * (rand(vec2(i,uv.x+uv.y))+bluramount); 34 | vec2 uv2 = uv+(q*bluramount); 35 | blurred_image += draw(uv2)/2.; 36 | //One more to hide the noise. 37 | q = vec2(cos(degrees((i/repeats)*360.)),sin(degrees((i/repeats)*360.))) * (rand(vec2(i+2.,uv.x+uv.y+24.))+bluramount); 38 | uv2 = uv+(q*bluramount); 39 | blurred_image += draw(uv2)/2.; 40 | } 41 | blurred_image /= repeats; 42 | fragColor = vec4(blurred_image,1.0); 43 | } 44 | 45 | void main() 46 | { 47 | mainImage(gl_FragColor, gl_FragCoord.xy); 48 | } -------------------------------------------------------------------------------- /assets/resources/shaders/blurs.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "f878c398-2f72-4304-a6bc-6e34c3584447", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders/demo.glsl: -------------------------------------------------------------------------------- 1 | void main() 2 | { 3 | float time=iGlobalTime*1.; 4 | vec2 uv = (gl_FragCoord.xy / iResolution.xx-0.5)*8.0; 5 | vec2 uv0=uv; 6 | float i0=1.0; 7 | float i1=1.0; 8 | float i2=1.0; 9 | float i4=0.0; 10 | for(int s=0;s<7;s++) 11 | { 12 | vec2 r; 13 | r=vec2(cos(uv.y*i0-i4+time/i1),sin(uv.x*i0-i4+time/i1))/i2; 14 | r+=vec2(-r.y,r.x)*0.3; 15 | uv.xy+=r; 16 | 17 | i0*=1.93; 18 | i1*=1.15; 19 | i2*=1.7; 20 | i4+=0.05+0.1*time*i1; 21 | } 22 | float r=sin(uv.x-time)*0.5+0.5; 23 | float b=sin(uv.y+time)*0.5+0.5; 24 | float g=sin((uv.x+uv.y+sin(time*0.5))*0.5)*0.5+0.5; 25 | gl_FragColor = vec4(r,g,b,1.0); 26 | } -------------------------------------------------------------------------------- /assets/resources/shaders/demo.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "b7133565-6e03-42c8-905f-e0a32330e251", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders/dissolve.glsl: -------------------------------------------------------------------------------- 1 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 2 | { 3 | // 纹理坐标 4 | vec2 uv = fragCoord.xy / iResolution.xy; 5 | vec4 color = vec4(0.0); 6 | 7 | float height = texture2D(iChannel1,uv.xy).r; 8 | 9 | color = texture2D(iChannel0,uv.xy); 10 | 11 | //remove if for performance 12 | // float condition_if_1 = step(height, sin(iGlobalTime + 0.04)); 13 | // float condition_if_2 = step(height, sin(iGlobalTime)); 14 | 15 | // color = color * (1. - condition_if_1) + vec4(1.,1.,0.,color.a) * condition_if_1; 16 | // color = color * (1. - condition_if_2); 17 | 18 | // if((height) < (sin(iGlobalTime + 0.04))) 19 | // { 20 | // pixel = vec3(1.,1.,0.); 21 | // } 22 | 23 | 24 | 25 | if(height < iGlobalTime) 26 | { 27 | // pixel = vec3(0.,0.,0.); 28 | discard; 29 | } 30 | 31 | if((height) < (iGlobalTime + 0.04)) 32 | { 33 | color = vec4(1.,1.,0.2,color.a); 34 | } 35 | 36 | 37 | fragColor = color; 38 | } 39 | 40 | void main() 41 | { 42 | mainImage(gl_FragColor, gl_FragCoord.xy); 43 | } -------------------------------------------------------------------------------- /assets/resources/shaders/dissolve.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "1068091c-1b7a-4eeb-b010-c11380279914", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders/frozenland.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "49fe432c-c6db-4e24-a384-ec799a6c7dc3", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders/outline.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | 6 | void main() 7 | { 8 | vec2 onePixel = vec2(1.0 / iResolution.x, 1.0 / iResolution.y); 9 | 10 | vec4 color = texture2D(iChannel0, gl_FragCoord.xy); 11 | vec4 colorRight = texture2D(iChannel0, gl_FragCoord.xy + vec2(0,onePixel.t)); 12 | vec4 colorBottom = texture2D(iChannel0, gl_FragCoord.xy + vec2(onePixel.s,0)); 13 | 14 | color.r = 3.0* sqrt( (color.r - colorRight.r) * (color.r - colorRight.r) + (color.r - colorBottom.r) * (color.r - colorBottom.r) ); 15 | color.g = 3.0* sqrt( (color.g - colorRight.g) * (color.g - colorRight.g) + (color.g - colorBottom.g) * (color.g - colorBottom.g) ); 16 | color.b = 3.0* sqrt( (color.b - colorRight.b) * (color.b - colorRight.b) + (color.b - colorBottom.b) * (color.b - colorBottom.b) ); 17 | 18 | color.r >1.0 ? 1.0 : color.r; 19 | color.g >1.0 ? 1.0 : color.g; 20 | color.b >1.0 ? 1.0 : color.b; 21 | gl_FragColor = vec4(color.rgb, 1); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /assets/resources/shaders/outline.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "ae125f98-cf5d-4cb4-a979-9ac22714b87a", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders/pageturning.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "449dfdd1-b98e-411b-8ac3-dae55392ef19", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders/plasma.glsl: -------------------------------------------------------------------------------- 1 | //Plasma Globe by nimitz (twitter: @stormoid) 2 | 3 | //looks best with around 25 rays 4 | #define NUM_RAYS 13. 5 | 6 | #define VOLUMETRIC_STEPS 19 7 | 8 | #define MAX_ITER 35 9 | #define FAR 6. 10 | 11 | #define time iGlobalTime*1.1 12 | 13 | 14 | mat2 mm2(in float a){float c = cos(a), s = sin(a);return mat2(c,-s,s,c);} 15 | float noise( in float x ){return texture2D(iChannel1, vec2(x*.01,1.),0.0).x;} 16 | 17 | float hash( float n ){return fract(sin(n)*43758.5453);} 18 | 19 | //iq's ubiquitous 3d noise 20 | float noise(in vec3 p) 21 | { 22 | vec3 ip = floor(p); 23 | vec3 f = fract(p); 24 | f = f*f*(3.0-2.0*f); 25 | 26 | vec2 uv = (ip.xy+vec2(37.0,17.0)*ip.z) + f.xy; 27 | vec2 rg = texture2D( iChannel1, (uv+ 0.5)/256.0, 0.0 ).yx; 28 | return mix(rg.x, rg.y, f.z); 29 | } 30 | 31 | mat3 m3 = mat3( 0.00, 0.80, 0.60, 32 | -0.80, 0.36, -0.48, 33 | -0.60, -0.48, 0.64 ); 34 | 35 | 36 | //See: https://www.shadertoy.com/view/XdfXRj 37 | float flow(in vec3 p, in float t) 38 | { 39 | float z=2.; 40 | float rz = 0.; 41 | vec3 bp = p; 42 | for (float i= 1.;i < 5.;i++ ) 43 | { 44 | p += time*.1; 45 | rz+= (sin(noise(p+t*0.8)*6.)*0.5+0.5) /z; 46 | p = mix(bp,p,0.6); 47 | z *= 2.; 48 | p *= 2.01; 49 | p*= m3; 50 | } 51 | return rz; 52 | } 53 | 54 | //could be improved 55 | float sins(in float x) 56 | { 57 | float rz = 0.; 58 | float z = 2.; 59 | for (float i= 0.;i < 3.;i++ ) 60 | { 61 | rz += abs(fract(x*1.4)-0.5)/z; 62 | x *= 1.3; 63 | z *= 1.15; 64 | x -= time*.65*z; 65 | } 66 | return rz; 67 | } 68 | 69 | float segm( vec3 p, vec3 a, vec3 b) 70 | { 71 | vec3 pa = p - a; 72 | vec3 ba = b - a; 73 | float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1. ); 74 | return length( pa - ba*h )*.5; 75 | } 76 | 77 | vec3 path(in float i, in float d) 78 | { 79 | vec3 en = vec3(0.,0.,1.); 80 | float sns2 = sins(d+i*0.5)*0.22; 81 | float sns = sins(d+i*.6)*0.21; 82 | en.xz *= mm2((hash(i*10.569)-.5)*6.2+sns2); 83 | en.xy *= mm2((hash(i*4.732)-.5)*6.2+sns); 84 | return en; 85 | } 86 | 87 | vec2 map(vec3 p, float i) 88 | { 89 | float lp = length(p); 90 | vec3 bg = vec3(0.); 91 | vec3 en = path(i,lp); 92 | 93 | float ins = smoothstep(0.11,.46,lp); 94 | float outs = .15+smoothstep(.0,.15,abs(lp-1.)); 95 | p *= ins*outs; 96 | float id = ins*outs; 97 | 98 | float rz = segm(p, bg, en)-0.011; 99 | return vec2(rz,id); 100 | } 101 | 102 | float march(in vec3 ro, in vec3 rd, in float startf, in float maxd, in float j) 103 | { 104 | float precis = 0.001; 105 | float h=0.5; 106 | float d = startf; 107 | for( int i=0; imaxd ) break; 110 | d += h*1.2; 111 | float res = map(ro+rd*d, j).x; 112 | h = res; 113 | } 114 | return d; 115 | } 116 | 117 | //volumetric marching 118 | vec3 vmarch(in vec3 ro, in vec3 rd, in float j, in vec3 orig) 119 | { 120 | vec3 p = ro; 121 | vec2 r = vec2(0.); 122 | vec3 sum = vec3(0); 123 | float w = 0.; 124 | for( int i=0; i= FAR)continue; 178 | vec3 pos = ro+rz*rd; 179 | col = max(col,vmarch(pos,rd,j, bro)); 180 | } 181 | #endif 182 | 183 | ro = bro; 184 | rd = brd; 185 | vec2 sph = iSphere2(ro,rd); 186 | 187 | if (sph.x > 0.) 188 | { 189 | vec3 pos = ro+rd*sph.x; 190 | vec3 pos2 = ro+rd*sph.y; 191 | vec3 rf = reflect( rd, pos ); 192 | vec3 rf2 = reflect( rd, pos2 ); 193 | float nz = (-log(abs(flow(rf*1.2,time)-.01))); 194 | float nz2 = (-log(abs(flow(rf2*1.2,-time)-.01))); 195 | col += (0.1*nz*nz* vec3(0.12,0.12,.5) + 0.05*nz2*nz2*vec3(0.55,0.2,.55))*0.8; 196 | } 197 | 198 | fragColor = vec4(col*1.3, 1.0); 199 | } 200 | 201 | void main() 202 | { 203 | mainImage(gl_FragColor, gl_FragCoord.xy); 204 | } 205 | -------------------------------------------------------------------------------- /assets/resources/shaders/plasma.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "380b666f-d346-4f43-b34b-69cead28585c", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders/raymarching.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "f5e14e27-de69-4cb3-9f57-a0520049e703", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders/starbackground.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | #define M_PI 3.1415926535897932384626433832795 6 | 7 | float rand(vec2 co) 8 | { 9 | return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); 10 | } 11 | 12 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 13 | { 14 | float size = 30.0; 15 | float prob = 0.95; 16 | 17 | vec2 pos = floor(1.0 / size * fragCoord.xy); 18 | 19 | float color = 0.0; 20 | float g = .0; 21 | float b = .0; 22 | float starValue = rand(pos); 23 | 24 | if (starValue > prob) 25 | { 26 | vec2 center = size * pos + vec2(size, size) * 0.5; 27 | 28 | float t = 0.9 + .9*sin(.3*iGlobalTime) * sin(iGlobalTime + (starValue - prob) / (1.0 - prob) * 45.0); 29 | 30 | color = 1.0 - distance(fragCoord.xy, center) / (0.5 * size); 31 | color = color * t/ (abs(fragCoord.y - center.y)) * t / (abs(fragCoord.x - center.x)); 32 | b = color *sin(t)*t; 33 | g = color*t; 34 | } 35 | else if (rand(fragCoord.xy / iResolution.xy) > 0.996) 36 | { 37 | float r = rand(fragCoord.xy); 38 | color = r * (0.35 * sin(iGlobalTime * (r * 5.0) + 720.0 * r) + 0.75); 39 | g = r * (0.35 * sin(iGlobalTime * (r * 5.0) + 720.0 * r) + 0.75); 40 | b = r * (0.35 * sin(iGlobalTime * (r * 5.0) + 720.0 * r) + 0.75); 41 | } 42 | 43 | fragColor = vec4(vec3(color,g,b), 1.0); 44 | } 45 | void main() 46 | { 47 | mainImage(gl_FragColor, gl_FragCoord.xy); 48 | } -------------------------------------------------------------------------------- /assets/resources/shaders/starbackground.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "32502030-a98b-4cb4-af47-2a6623793d4b", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/shaders/supermario.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "f59239cf-4d48-4800-9681-6d301883290c", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/simplicityGalaxy.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | //CBS 6 | //Parallax scrolling fractal galaxy. 7 | //Inspired by JoshP's Simplicity shader: https://www.shadertoy.com/view/lslGWr 8 | 9 | // http://www.fractalforums.com/new-theories-and-research/very-simple-formula-for-fractal-patterns/ 10 | float field(in vec3 p,float s) { 11 | float strength = 7. + .03 * log(1.e-6 + fract(sin(iGlobalTime) * 4373.11)); 12 | float accum = s/4.; 13 | float prev = 0.; 14 | float tw = 0.; 15 | for (int i = 0; i < 26; ++i) { 16 | float mag = dot(p, p); 17 | p = abs(p) / mag + vec3(-.5, -.4, -1.5); 18 | float w = exp(-float(i) / 7.); 19 | accum += w * exp(-strength * pow(abs(mag - prev), 2.2)); 20 | tw += w; 21 | prev = mag; 22 | } 23 | return max(0., 5. * accum / tw - .7); 24 | } 25 | 26 | // Less iterations for second layer 27 | float field2(in vec3 p, float s) { 28 | float strength = 7. + .03 * log(1.e-6 + fract(sin(iGlobalTime) * 4373.11)); 29 | float accum = s/4.; 30 | float prev = 0.; 31 | float tw = 0.; 32 | for (int i = 0; i < 18; ++i) { 33 | float mag = dot(p, p); 34 | p = abs(p) / mag + vec3(-.5, -.4, -1.5); 35 | float w = exp(-float(i) / 7.); 36 | accum += w * exp(-strength * pow(abs(mag - prev), 2.2)); 37 | tw += w; 38 | prev = mag; 39 | } 40 | return max(0., 5. * accum / tw - .7); 41 | } 42 | 43 | vec3 nrand3( vec2 co ) 44 | { 45 | vec3 a = fract( cos( co.x*8.3e-3 + co.y )*vec3(1.3e5, 4.7e5, 2.9e5) ); 46 | vec3 b = fract( sin( co.x*0.3e-3 + co.y )*vec3(8.1e5, 1.0e5, 0.1e5) ); 47 | vec3 c = mix(a, b, 0.5); 48 | return c; 49 | } 50 | 51 | 52 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) { 53 | vec2 uv = 2. * fragCoord.xy / iResolution.xy - 1.; 54 | vec2 uvs = uv * iResolution.xy / max(iResolution.x, iResolution.y); 55 | vec3 p = vec3(uvs / 4., 0) + vec3(1., -1.3, 0.); 56 | p += .2 * vec3(sin(iGlobalTime / 16.), sin(iGlobalTime / 12.), sin(iGlobalTime / 128.)); 57 | 58 | float freqs[4]; 59 | //Sound 60 | freqs[0] = texture2D( iChannel0, vec2( 0.01, 0.25 ) ).x; 61 | freqs[1] = texture2D( iChannel0, vec2( 0.07, 0.25 ) ).x; 62 | freqs[2] = texture2D( iChannel0, vec2( 0.15, 0.25 ) ).x; 63 | freqs[3] = texture2D( iChannel0, vec2( 0.30, 0.25 ) ).x; 64 | 65 | float t = field(p,freqs[2]); 66 | float v = (1. - exp((abs(uv.x) - 1.) * 6.)) * (1. - exp((abs(uv.y) - 1.) * 6.)); 67 | 68 | //Second Layer 69 | vec3 p2 = vec3(uvs / (4.+sin(iGlobalTime*0.11)*0.2+0.2+sin(iGlobalTime*0.15)*0.3+0.4), 1.5) + vec3(2., -1.3, -1.); 70 | p2 += 0.25 * vec3(sin(iGlobalTime / 16.), sin(iGlobalTime / 12.), sin(iGlobalTime / 128.)); 71 | float t2 = field2(p2,freqs[3]); 72 | vec4 c2 = mix(.4, 1., v) * vec4(1.3 * t2 * t2 * t2 ,1.8 * t2 * t2 , t2* freqs[0], t2); 73 | 74 | 75 | //Let's add some stars 76 | //Thanks to http://glsl.heroku.com/e#6904.0 77 | vec2 seed = p.xy * 2.0; 78 | seed = floor(seed * iResolution.x); 79 | vec3 rnd = nrand3( seed ); 80 | vec4 starcolor = vec4(pow(rnd.y,40.0)); 81 | 82 | //Second Layer 83 | vec2 seed2 = p2.xy * 2.0; 84 | seed2 = floor(seed2 * iResolution.x); 85 | vec3 rnd2 = nrand3( seed2 ); 86 | starcolor += vec4(pow(rnd2.y,40.0)); 87 | 88 | fragColor = mix(freqs[3]-.3, 1., v) * vec4(1.5*freqs[2] * t * t* t , 1.2*freqs[1] * t * t, freqs[3]*t, 1.0)+c2+starcolor; 89 | } 90 | 91 | void main(void){ 92 | mainImage(gl_FragColor, gl_FragCoord.xy); 93 | } -------------------------------------------------------------------------------- /assets/resources/simplicityGalaxy.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "09db377f-26c1-4512-a2aa-d262e4c8e8c7", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/spectrum.glsl: -------------------------------------------------------------------------------- 1 | const float PI = 3.14159; 2 | 3 | vec3 hsv(float h,float s,float v) { 4 | return mix(vec3(1.),clamp((abs(fract(h+vec3(3.,2.,1.)/3.)*6.-3.)-1.),0.,1.),s)*v; 5 | } 6 | 7 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 8 | { 9 | // create pixel coordinates 10 | vec2 uv = fragCoord.xy / iResolution.xy; 11 | 12 | // quantize coordinates 13 | const float bands = 40.0; 14 | vec2 p; 15 | p.x = floor(uv.x*bands)/bands; 16 | p.y = uv.y; 17 | 18 | // read frequency data from first row of texture 19 | float fft = texture2D( iChannel2, vec2(p.x,0.0) ).x; 20 | 21 | // led color 22 | vec3 color = hsv(p.x, 1.0 - p.y, 1.0); 23 | 24 | // led shape 25 | float dx = fract( (uv.x - p.x) * bands) - 0.5; 26 | //float led = smoothstep(0.5, 0.3, abs(d.x)) * 27 | // smoothstep(0.5, 0.3, abs(d.y)); 28 | 29 | float led = smoothstep(0.5, 0.3, abs(dx)); 30 | 31 | // output final color 32 | //fragColor = vec4(vec3(fft),1.0); 33 | 34 | //fragColor = vec4(d, 0.0, 1.0); 35 | 36 | //fragColor = vec4(vec3(led), 1.0); 37 | 38 | // mask for bar graph 39 | float mask = (p.y < fft) ? 1.0 : 0.0; 40 | fragColor = vec4(color*mask*led, 1.0); 41 | } 42 | void main() 43 | { 44 | mainImage(gl_FragColor, gl_FragCoord.xy); 45 | } 46 | -------------------------------------------------------------------------------- /assets/resources/spectrum.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "efa8b911-1901-4a57-ae61-6244c84a317e", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/starbackground.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | uniform float time; 6 | uniform vec2 resolution; 7 | varying vec2 v_texCoord; 8 | 9 | #define M_PI 3.1415926535897932384626433832795 10 | 11 | float rand(vec2 co) 12 | { 13 | return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); 14 | } 15 | 16 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 17 | { 18 | float size = 30.0; 19 | float prob = 0.95; 20 | 21 | vec2 rs = resolution.xy; 22 | vec2 uv= v_texCoord.xy; 23 | 24 | vec2 pos = floor(1.0 / size * rs*uv); 25 | 26 | float color = 0.0; 27 | float g = .0; 28 | float b = .0; 29 | float starValue = rand(pos); 30 | 31 | if (starValue > prob) 32 | { 33 | vec2 center = size * pos + vec2(size, size) * 0.5; 34 | 35 | float t = 0.9 + .9*sin(.3*time) * sin(time + (starValue - prob) / (1.0 - prob) * 45.0); 36 | 37 | color = 1.0 - distance(rs*uv, center) / (0.5 * size); 38 | color = color * t/ (abs(rs.y*uv.y - center.y)) * t / (abs(rs.x*uv.x - center.x)); 39 | b = color *sin(t)*t; 40 | g = color*t; 41 | } 42 | else if (rand(rs*uv / resolution.xy) > 0.996) 43 | { 44 | float r = rand(rs*uv); 45 | color = r * (0.35 * sin(time * (r * 5.0) + 720.0 * r) + 0.75); 46 | g = r * (0.35 * sin(time * (r * 5.0) + 720.0 * r) + 0.75); 47 | b = r * (0.35 * sin(time * (r * 5.0) + 720.0 * r) + 0.75); 48 | } 49 | 50 | fragColor = vec4(vec3(color,g,b), 1.0); 51 | } 52 | void main() 53 | { 54 | mainImage(gl_FragColor, gl_FragCoord.xy); 55 | } -------------------------------------------------------------------------------- /assets/resources/starbackground.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "7065e0d8-644c-4e69-88d4-1513585d9f3d", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/startbg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/assets/resources/startbg.jpg -------------------------------------------------------------------------------- /assets/resources/startbg.jpg.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.2.0", 3 | "uuid": "79ab5082-69dd-4179-b8f6-8691c5a179c3", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "subMetas": { 9 | "startbg": { 10 | "ver": "1.0.4", 11 | "uuid": "661bac32-0b48-454c-8c57-be81f0d576bb", 12 | "rawTextureUuid": "79ab5082-69dd-4179-b8f6-8691c5a179c3", 13 | "trimType": "auto", 14 | "trimThreshold": 1, 15 | "rotated": false, 16 | "offsetX": 0, 17 | "offsetY": 0, 18 | "trimX": 0, 19 | "trimY": 0, 20 | "width": 1024, 21 | "height": 768, 22 | "rawWidth": 1024, 23 | "rawHeight": 768, 24 | "borderTop": 0, 25 | "borderBottom": 0, 26 | "borderLeft": 0, 27 | "borderRight": 0, 28 | "subMetas": {} 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /assets/resources/supermario.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "d145005d-e511-4891-b2d0-9fb4efa1a408", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/swirlingdots.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | uniform float time; 5 | uniform vec2 resolution; 6 | varying vec2 v_texCoord; 7 | void mainImage(out vec4 fragColor, in vec2 fragCoord) 8 | { 9 | // 转换坐标 10 | // vec2 uv = ( fragCoord - resolution.xy * 0.5) / resolution.y; 11 | vec2 rs = resolution.xy; 12 | vec2 luv= v_texCoord.xy; 13 | vec2 uv = ( rs*luv - rs * 0.5) / resolution.y; 14 | vec3 c = vec3 (0.); 15 | for(float i = 0.0; i <= 1.0; i += 1.0) { 16 | for(float x = -0.8; x <= 0.8; x += 1.6 / 32.0){ 17 | float v = 0.0025 / length(uv - vec2(x, sin(i * 2.0 + x * 5.0 + time)* 0.4)); 18 | c += v * vec3 (1.0 - i * 0.5, i -x, i + x * 2.0); 19 | } 20 | } 21 | fragColor = vec4(c, 1.); 22 | } 23 | void main() 24 | { 25 | mainImage(gl_FragColor, gl_FragCoord.xy); 26 | } 27 | -------------------------------------------------------------------------------- /assets/resources/swirlingdots.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "8f9d7cb7-565d-4868-bce8-6781d9f45702", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/turbulence.glsl: -------------------------------------------------------------------------------- 1 | // Found this on GLSL sandbox. I really liked it, changed a few things and made it tileable. 2 | // :) 3 | // by David Hoskins. 4 | 5 | 6 | // Water turbulence effect by joltz0r 2013-07-04, improved 2013-07-07 7 | 8 | 9 | // Redefine below to see the tiling... 10 | 11 | 12 | #define TAU 6.120470874064187 13 | #define MAX_ITER 5 14 | 15 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 16 | { 17 | float time = iGlobalTime * .5+5.; 18 | // uv should be the 0-1 uv of texture... 19 | vec2 uv = fragCoord.xy / iResolution.xy; 20 | 21 | 22 | vec2 p = mod(uv*TAU, TAU)-250.0; 23 | 24 | vec2 i = vec2(p); 25 | float c = 1.0; 26 | float inten = .0045; 27 | 28 | for (int n = 0; n < MAX_ITER; n++) 29 | { 30 | float t = time * (1.0 - (3.5 / float(n+1))); 31 | i = p + vec2(cos(t - i.x) + sin(t + i.y), sin(t - i.y) + cos(1.5*t + i.x)); 32 | c += 1.0/length(vec2(p.x / (cos(i.x+t)/inten),p.y / (cos(i.y+t)/inten))); 33 | } 34 | c /= float(MAX_ITER); 35 | c = 1.17-pow(c, 1.4); 36 | vec4 tex = texture2D(iChannel0,uv); 37 | vec3 colour = vec3(pow(abs(c), 20.0)); 38 | colour = clamp(colour + vec3(.0, .0, .0), 0.0, tex.a); 39 | 40 | fragColor = tex + vec4(colour, 1.0); 41 | } 42 | void main() 43 | { 44 | mainImage(gl_FragColor, gl_FragCoord.xy); 45 | } -------------------------------------------------------------------------------- /assets/resources/turbulence.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "1422bf2d-e7d7-48df-82e3-52213253c209", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/turnpage.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "3ede595a-ea84-4d16-86e4-f06487d82172", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/tweaked.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | //tweaked by psyreco 5 | 6 | 7 | uniform float time; 8 | uniform vec2 resolution; 9 | varying vec2 v_texCoord; 10 | void main( void ) { 11 | 12 | vec2 rs = resolution.xy; 13 | vec2 uv= v_texCoord.xy; 14 | vec2 position = abs( uv*rs * 2.0 - rs) / min(resolution.x, resolution.y); 15 | vec3 destColor = vec3(.70, 0.0, .75 ); 16 | float f = 0.45; 17 | 18 | for(float i = 0.5; i < 21.0; i++){ 19 | 20 | float s = tan(sin(time/3.0 - i )) ; 21 | float c = atan(cos(time/7.0 - i )); 22 | f +=abs(0.0047 / abs(length(5.0* position *f - vec2(c, s) ) -0.84)); 23 | } 24 | 25 | gl_FragColor = vec4(vec3(destColor * f) + vec3(destColor.yzx * f/2.0), 1.0); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /assets/resources/tweaked.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "69589637-1735-4f9d-9d51-81e101f4380d", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/water.glsl: -------------------------------------------------------------------------------- 1 | #define F cos(x-y)*cos(y),sin(x+y)*sin(y) 2 | 3 | vec2 s(vec2 p) 4 | { 5 | float d=iGlobalTime*0.2,x=8.*(p.x+d),y=8.*(p.y+d); 6 | return vec2(F); 7 | } 8 | void mainImage( out vec4 fragColor, in vec2 fragCoord ) 9 | { 10 | // 换成resolution 11 | vec2 rs = iResolution.xy; 12 | // 换成纹理坐标v_texCoord.xy 13 | vec2 uv = fragCoord/rs; 14 | vec2 q = uv+2./iResolution.x*(s(uv)-s(uv+rs)); 15 | //反转y 16 | //q.y=1.-q.y; 17 | fragColor = texture2D(iChannel3,q); 18 | } 19 | void main() 20 | { 21 | mainImage(gl_FragColor, gl_FragCoord.xy); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /assets/resources/water.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "eb32557e-aaef-4355-9d48-c639c1e8fdc6", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/wave.glsl: -------------------------------------------------------------------------------- 1 | #ifdef GL_ES 2 | precision mediump float; 3 | #endif 4 | 5 | void main( void ) { 6 | vec2 uv = (gl_FragCoord.xy / iResolution.xy); 7 | uv.y += .01* sin(iGlobalTime + uv.x * 2.2); 8 | uv.x += .01 * sin(iGlobalTime + uv.y * 2.2); 9 | vec4 color = texture2D(iChannel3, uv); 10 | color = 1.05 * color; 11 | gl_FragColor = color; 12 | } -------------------------------------------------------------------------------- /assets/resources/wave.glsl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "f55afb78-2ac4-4952-9f77-3f417a78889e", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "experimentalDecorators": true 6 | }, 7 | "exclude": [ 8 | "node_modules", 9 | ".vscode", 10 | "library", 11 | "local", 12 | "settings", 13 | "temp" 14 | ] 15 | 16 | } -------------------------------------------------------------------------------- /project.json: -------------------------------------------------------------------------------- 1 | { 2 | "engine": "cocos2d-html5", 3 | 4 | "packages": "packages" 5 | } -------------------------------------------------------------------------------- /screenshots/amcolors.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/amcolors.gif -------------------------------------------------------------------------------- /screenshots/clouds.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/clouds.gif -------------------------------------------------------------------------------- /screenshots/clover.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/clover.gif -------------------------------------------------------------------------------- /screenshots/colorcircle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/colorcircle.gif -------------------------------------------------------------------------------- /screenshots/colorlights.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/colorlights.gif -------------------------------------------------------------------------------- /screenshots/cover.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/cover.gif -------------------------------------------------------------------------------- /screenshots/deformflower.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/deformflower.gif -------------------------------------------------------------------------------- /screenshots/dissolve.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/dissolve.gif -------------------------------------------------------------------------------- /screenshots/fish.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/fish.gif -------------------------------------------------------------------------------- /screenshots/flame.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/flame.gif -------------------------------------------------------------------------------- /screenshots/fluxay.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/fluxay.gif -------------------------------------------------------------------------------- /screenshots/gauss.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/gauss.gif -------------------------------------------------------------------------------- /screenshots/glowcircle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/glowcircle.gif -------------------------------------------------------------------------------- /screenshots/grassy.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/grassy.gif -------------------------------------------------------------------------------- /screenshots/gray.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/gray.gif -------------------------------------------------------------------------------- /screenshots/heart.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/heart.gif -------------------------------------------------------------------------------- /screenshots/lightcircle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/lightcircle.gif -------------------------------------------------------------------------------- /screenshots/lightnets.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/lightnets.gif -------------------------------------------------------------------------------- /screenshots/lightrun.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/lightrun.gif -------------------------------------------------------------------------------- /screenshots/obsession.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/obsession.gif -------------------------------------------------------------------------------- /screenshots/qqgroup.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/qqgroup.JPG -------------------------------------------------------------------------------- /screenshots/redcircle.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/redcircle.gif -------------------------------------------------------------------------------- /screenshots/search.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/search.gif -------------------------------------------------------------------------------- /screenshots/starbackground.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/starbackground.gif -------------------------------------------------------------------------------- /screenshots/supermario.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/supermario.gif -------------------------------------------------------------------------------- /screenshots/swirlingdots.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/swirlingdots.gif -------------------------------------------------------------------------------- /screenshots/transfer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/transfer.gif -------------------------------------------------------------------------------- /screenshots/tweaked.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/tweaked.gif -------------------------------------------------------------------------------- /screenshots/valentineday.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/valentineday.gif -------------------------------------------------------------------------------- /screenshots/water.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fylz1125/ShaderDemos/f91bd2fd2df7fdf7e192880b4b0fdb2235d87222/screenshots/water.gif -------------------------------------------------------------------------------- /settings/builder.json: -------------------------------------------------------------------------------- 1 | { 2 | "appKey": "", 3 | "appSecret": "", 4 | "encryptJs": true, 5 | "excludeScenes": [], 6 | "includeAnySDK": false, 7 | "includeSDKBox": false, 8 | "inlineSpriteFrames": true, 9 | "inlineSpriteFrames_native": true, 10 | "jailbreakPlatform": false, 11 | "md5Cache": true, 12 | "mergeStartScene": false, 13 | "oauthLoginServer": "", 14 | "optimizeHotUpdate": false, 15 | "orientation": { 16 | "landscapeLeft": true, 17 | "landscapeRight": true, 18 | "portrait": false, 19 | "upsideDown": false 20 | }, 21 | "packageName": "org.cocos2d.helloworld", 22 | "privateKey": "", 23 | "renderMode": "0", 24 | "startScene": "a0adad71-2d3c-4fff-93bf-a2a5baeeca9e", 25 | "title": "shader", 26 | "webOrientation": "auto", 27 | "wechatgame": { 28 | "appid": "wx6ac3f5090a6b99c5", 29 | "orientation": "landscape" 30 | }, 31 | "xxteaKey": "ff323956-9da9-41", 32 | "zipCompressJs": true 33 | } -------------------------------------------------------------------------------- /settings/builder.panel.json: -------------------------------------------------------------------------------- 1 | { 2 | "excludeScenes": [], 3 | "packageName": "org.cocos2d.helloworld", 4 | "platform": "web-mobile", 5 | "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", 6 | "title": "HelloWorld" 7 | } -------------------------------------------------------------------------------- /settings/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "collision-matrix": [ 3 | [ 4 | true 5 | ] 6 | ], 7 | "design-resolution-height": 640, 8 | "design-resolution-width": 960, 9 | "excluded-modules": [], 10 | "fit-height": true, 11 | "fit-width": false, 12 | "group-list": [ 13 | "default" 14 | ], 15 | "simulator-orientation": false, 16 | "simulator-resolution": { 17 | "height": 640, 18 | "width": 960 19 | }, 20 | "use-customize-simulator": false, 21 | "use-project-simulator-setting": false, 22 | "start-scene": "current", 23 | "last-module-event-record-time": 0, 24 | "facebook": { 25 | "enable": false, 26 | "appID": "", 27 | "live": { 28 | "enable": false 29 | }, 30 | "audience": { 31 | "enable": false 32 | } 33 | }, 34 | "assets-sort-type": "name" 35 | } -------------------------------------------------------------------------------- /template.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TEMPLATES.helloworld-ts.name", 3 | 4 | "desc": "TEMPLATES.helloworld-ts.desc", 5 | 6 | "banner": "template-banner.png" 7 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": [ "dom", "es5","es2015.promise" ], 5 | "target": "es5", 6 | "experimentalDecorators": true, 7 | "skipLibCheck": true 8 | }, 9 | "exclude": [ 10 | "node_modules", 11 | "library", 12 | "local", 13 | "temp", 14 | "build", 15 | "settings" 16 | ] 17 | } --------------------------------------------------------------------------------