From a93425ef0df57c78f4efd665278180dfedd49bb2 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 16 Feb 2023 16:13:22 +0000 Subject: [PATCH] Bundle Shaders now produces an index.js --- scripts/bundle-shaders.js | 52 ++++++++++++++++++++++++++++- src/renderer/webgl/shaders/index.js | 48 ++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 src/renderer/webgl/shaders/index.js diff --git a/scripts/bundle-shaders.js b/scripts/bundle-shaders.js index 917886083..cc5742968 100644 --- a/scripts/bundle-shaders.js +++ b/scripts/bundle-shaders.js @@ -5,7 +5,21 @@ let destdir = './src/renderer/webgl/shaders/'; let files = fs.readdirSync(srcdir); -files.forEach(function (file) { +let index = `/** + * @author Richard Davey + * @copyright 2013-2023 Photon Storm Ltd. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Renderer.WebGL.Shaders + */ + +module.exports = { + +`; + +files.forEach(function (file, c) { let shaderSource = fs.readFileSync(srcdir + file, 'utf8'); let type = file.substr(-4); @@ -49,4 +63,40 @@ files.forEach(function (file) { }); + let inc = file.substr(0, file.lastIndexOf('.')); + + if (file.substr(-4) === 'frag') + { + inc = inc.concat('Frag'); + } + else + { + inc = inc.concat('Vert'); + } + + index = index.concat(` ${inc}: require('./${shaderFilename}')`); + + if (c < files.length - 1) + { + index = index.concat(',\n'); + } + +}); + +index = index.concat(` + +}; +`); + +fs.writeFile(destdir + 'index.js', index, function (error) { + + if (error) + { + throw error; + } + else + { + console.log('Index Saved'); + } + }); diff --git a/src/renderer/webgl/shaders/index.js b/src/renderer/webgl/shaders/index.js new file mode 100644 index 000000000..04668b462 --- /dev/null +++ b/src/renderer/webgl/shaders/index.js @@ -0,0 +1,48 @@ +/** + * @author Richard Davey + * @copyright 2013-2023 Photon Storm Ltd. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * @namespace Phaser.Renderer.WebGL.Shaders + */ + +module.exports = { + + AddBlendFrag: require('./AddBlend-frag.js'), + BitmapMaskFrag: require('./BitmapMask-frag.js'), + BitmapMaskVert: require('./BitmapMask-vert.js'), + ColorMatrixFrag: require('./ColorMatrix-frag.js'), + CopyFrag: require('./Copy-frag.js'), + FXBarrelFrag: require('./FXBarrel-frag.js'), + FXBloomFrag: require('./FXBloom-frag.js'), + FXBlurHighFrag: require('./FXBlurHigh-frag.js'), + FXBlurLowFrag: require('./FXBlurLow-frag.js'), + FXBlurMedFrag: require('./FXBlurMed-frag.js'), + FXBokehFrag: require('./FXBokeh-frag.js'), + FXCircleFrag: require('./FXCircle-frag.js'), + FXDisplacementFrag: require('./FXDisplacement-frag.js'), + FXGlowFrag: require('./FXGlow-frag.js'), + FXGradientFrag: require('./FXGradient-frag.js'), + FXPixelateFrag: require('./FXPixelate-frag.js'), + FXShadowFrag: require('./FXShadow-frag.js'), + FXShineFrag: require('./FXShine-frag.js'), + FXVignetteFrag: require('./FXVignette-frag.js'), + FXWipeFrag: require('./FXWipe-frag.js'), + LightFrag: require('./Light-frag.js'), + LinearBlendFrag: require('./LinearBlend-frag.js'), + MeshFrag: require('./Mesh-frag.js'), + MeshVert: require('./Mesh-vert.js'), + MobileFrag: require('./Mobile-frag.js'), + MobileVert: require('./Mobile-vert.js'), + MultiFrag: require('./Multi-frag.js'), + MultiVert: require('./Multi-vert.js'), + PointLightFrag: require('./PointLight-frag.js'), + PointLightVert: require('./PointLight-vert.js'), + PostFXFrag: require('./PostFX-frag.js'), + QuadVert: require('./Quad-vert.js'), + SingleFrag: require('./Single-frag.js'), + SingleVert: require('./Single-vert.js') + +};