Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable ETC2 compressed textures and add tool to generate them from ra…
…w assets
- Loading branch information
1 parent
91d4710
commit 77ae356
Showing
52 changed files
with
148 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,6 @@ oculussig_* | |
third_party | ||
|
||
user.properties* | ||
|
||
# Node modules | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ Ke 0.000000 0.000000 0.000000 | |
Ni 1.000000 | ||
d 1.000000 | ||
illum 2 | ||
map_Kd spinners_v3.jpg | ||
map_Kd spinners_v3.ktx |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule vrb
updated
5 files
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const gulp = require('gulp'); | ||
const sharp = require('sharp'); | ||
const tmp = require('tmp'); | ||
const execSync = require('child_process').execSync; | ||
const readdirp = require('readdirp'); | ||
|
||
const assetsPath = '../../app/src/main/uncompressed_assets'; | ||
const assetFilter = ['*.jpg', '*.jpeg', '*.png']; | ||
|
||
function compressAsset(source, target, rgba, done) { | ||
if (fs.existsSync(target)) { | ||
console.log("Already compressed: " + target); | ||
done(); | ||
return; | ||
} | ||
|
||
const extension = path.extname(source); | ||
if (extension !== ".png") { | ||
// Etc2Tool requires png format | ||
const tempImage = tmp.tmpNameSync() + ".png"; | ||
sharp(source) | ||
.toFile(tempImage) | ||
.then(data => { | ||
compressAsset(tempImage, target, false, done); | ||
}) | ||
.catch(err => { | ||
console.log("PNG conversion failed for " + source + ": " + err); | ||
done(err); | ||
}); | ||
return; | ||
} | ||
|
||
try { | ||
console.log("About to compress: " + target); | ||
var format = rgba ? "RGBA8" : "RGB8"; | ||
var out = execSync(`EtcTool ${source} -output ${target} -format ${format} -effort 100 -v`).toString(); | ||
console.log(out); | ||
done(); | ||
} catch (err) { | ||
console.error(err.message); | ||
done(err); | ||
} | ||
} | ||
|
||
gulp.task('compress', function(done) { | ||
let pending = 0; | ||
let finished = false; | ||
const settings = { | ||
root: assetsPath, | ||
fileFilter: assetFilter | ||
}; | ||
readdirp(settings) | ||
.on('data', function (entry) { | ||
pending++; | ||
const name = entry.fullPath; | ||
const extension = path.extname(name); | ||
let target = name.slice(0, -extension.length) + ".ktx"; | ||
target = target.replace("uncompressed_assets", "assets"); | ||
compressAsset(name, target, true, function() { | ||
pending--; | ||
if (finished && !pending) { | ||
done(); | ||
} | ||
}); | ||
}) | ||
.on('warn', function(warn){ | ||
console.log("Warn: ", warn); | ||
}) | ||
.on('error', function(err){ | ||
console.log("Error: ", err); | ||
}) | ||
.on('end', function(){ | ||
finished = true; | ||
if (!pending) { | ||
done(); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "fxr-compressor", | ||
"version": "1.0.0", | ||
"description": "FxR asset compressor", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [ | ||
"fxr", | ||
"asset", | ||
"compressor" | ||
], | ||
"author": "Mozilla", | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"gulp": "^4.0.0" | ||
}, | ||
"dependencies": { | ||
"readdirp": "^2.2.1", | ||
"sharp": "^0.21.1", | ||
"tmp": "0.0.33" | ||
} | ||
} |