mirror of
https://github.com/photonstorm/phaser
synced 2024-11-21 20:23:19 +00:00
New shader bundler script
This commit is contained in:
parent
bf17d061f7
commit
8c3226dc91
3 changed files with 101 additions and 0 deletions
|
@ -43,6 +43,7 @@
|
|||
"lintfix": "eslint --config .eslintrc.json \"src/**/*.js\" --fix",
|
||||
"sloc": "node-sloc \"./src\" --include-extensions \"js\"",
|
||||
"bundleshaders": "node scripts/bundle-shaders.js",
|
||||
"bundle3dshaders": "node scripts/bundle-layer3d-shaders.js",
|
||||
"build-tsgen": "cd scripts/tsgen && tsc",
|
||||
"tsgen": "cd scripts/tsgen && jsdoc -c jsdoc-tsd.conf.json",
|
||||
"test-ts": "cd scripts/tsgen/test && tsc --build tsconfig.json > output.txt",
|
||||
|
|
46
scripts/bundle-layer3d-shaders.js
Normal file
46
scripts/bundle-layer3d-shaders.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
let fs = require('fs-extra');
|
||||
|
||||
let srcdir = './src/layer3d/shaders/chunks/glsl/';
|
||||
let destdir = './src/layer3d/shaders/chunks/';
|
||||
|
||||
let files = fs.readdirSync(srcdir);
|
||||
|
||||
files.forEach(function (file) {
|
||||
|
||||
let shaderSource = fs.readFileSync(srcdir + file, 'utf8');
|
||||
let shaderFilename = file.substr(0, file.lastIndexOf('.')) + '.js';
|
||||
|
||||
let outputSource = 'module.exports = [\n';
|
||||
|
||||
let lines = shaderSource.split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i++)
|
||||
{
|
||||
let line = lines[i].trimRight();
|
||||
|
||||
if (i < lines.length - 1)
|
||||
{
|
||||
outputSource = outputSource.concat(" '" + line + "',\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
outputSource = outputSource.concat(" '" + line + "'\n");
|
||||
}
|
||||
}
|
||||
|
||||
outputSource = outputSource.concat('].join(\'\\n\');\n');
|
||||
|
||||
fs.writeFile(destdir + shaderFilename, outputSource, function (error) {
|
||||
|
||||
if (error)
|
||||
{
|
||||
throw error;
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log('Saved', shaderFilename);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
54
src/layer3d/shaders/libs/Basic.js
Normal file
54
src/layer3d/shaders/libs/Basic.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
var ShaderChunk = require('../ShaderChunk');
|
||||
|
||||
var Basic = {
|
||||
|
||||
frag: [
|
||||
|
||||
ShaderChunk.commonFrag,
|
||||
ShaderChunk.uvParsFrag,
|
||||
ShaderChunk.colorParsFrag,
|
||||
ShaderChunk.diffuseMapParsFrag,
|
||||
ShaderChunk.alphamapParsFrag,
|
||||
ShaderChunk.envMapParsFrag,
|
||||
ShaderChunk.aoMapParsFrag,
|
||||
ShaderChunk.fogParsFrag,
|
||||
|
||||
ShaderChunk.main,
|
||||
|
||||
ShaderChunk.beginFrag,
|
||||
ShaderChunk.colorFrag,
|
||||
ShaderChunk.diffuseMapFrag,
|
||||
ShaderChunk.alphamapFrag,
|
||||
ShaderChunk.alphaTestFrag,
|
||||
ShaderChunk.envMapFrag,
|
||||
ShaderChunk.endFrag,
|
||||
ShaderChunk.encodingsFrag,
|
||||
ShaderChunk.premultipliedAlphaFrag,
|
||||
ShaderChunk.fogFrag
|
||||
|
||||
],
|
||||
|
||||
vert: [
|
||||
|
||||
ShaderChunk.commonVert,
|
||||
ShaderChunk.uvParsVert,
|
||||
ShaderChunk.colorParsVert,
|
||||
ShaderChunk.envMapParsVert,
|
||||
ShaderChunk.morphtargetParsVert,
|
||||
ShaderChunk.skinningParsVert,
|
||||
|
||||
ShaderChunk.main,
|
||||
|
||||
ShaderChunk.beginVert,
|
||||
ShaderChunk.morphtargetVert,
|
||||
ShaderChunk.skinningVert,
|
||||
ShaderChunk.pvmVert,
|
||||
ShaderChunk.uvVert,
|
||||
ShaderChunk.colorVert,
|
||||
ShaderChunk.envMapVert
|
||||
|
||||
]
|
||||
|
||||
};
|
||||
|
||||
module.exports = Basic;
|
Loading…
Reference in a new issue