From 67ec766af2a5161c9ffd9ec7af8291cf84342b98 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 11 Apr 2018 10:24:01 -0700 Subject: [PATCH 1/3] saving work. --- libraries/image/src/image/Image.cpp | 2 +- tools/bake-tools/bake.py | 16 ++++++++++++---- tools/bake-tools/convertToRelativePaths.py | 9 +++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libraries/image/src/image/Image.cpp b/libraries/image/src/image/Image.cpp index 696e311495..0b4acb29c4 100644 --- a/libraries/image/src/image/Image.cpp +++ b/libraries/image/src/image/Image.cpp @@ -37,7 +37,7 @@ bool DEV_DECIMATE_TEXTURES = false; std::atomic DECIMATED_TEXTURE_COUNT{ 0 }; std::atomic RECTIFIED_TEXTURE_COUNT{ 0 }; -static const auto HDR_FORMAT = gpu::Element::COLOR_R11G11B10; +static const auto& HDR_FORMAT = gpu::Element::COLOR_R11G11B10; static std::atomic compressColorTextures { false }; static std::atomic compressNormalTextures { false }; diff --git a/tools/bake-tools/bake.py b/tools/bake-tools/bake.py index cad638c911..4051b7a7ca 100644 --- a/tools/bake-tools/bake.py +++ b/tools/bake-tools/bake.py @@ -44,26 +44,34 @@ def groupKTXFiles(directory, filePath): originalFilePath.strip() shutil.move(originalFilePath, newFilePath) -def bakeFile(filePath, outputDirectory): +def bakeFile(filePath, outputDirectory, fileType): createDirectory(outputDirectory) - cmd = EXE + ' -i ' + filePath + ' -o ' + outputDirectory + ' -t fbx' + cmd = EXE + ' -i ' + filePath + ' -o ' + outputDirectory + ' -t ' + fileType args = shlex.split(cmd) process = subprocess.Popen(cmd, stdout=False, stderr=False) process.wait() bakedFile = os.path.splitext(filePath)[0] - groupKTXFiles(outputDirectory, bakedFile) + if fileType == 'fbx': + groupKTXFiles(outputDirectory, bakedFile) def bakeFilesInDirectory(directory, outputDirectory): rootDirectory = os.path.basename(os.path.normpath(directory)) for root, subFolders, filenames in os.walk(directory): for filename in filenames: appendPath = getRelativePath(directory, root, rootDirectory); + name, ext = os.path.splitext('file.txt') if filename.endswith('.fbx'): filePath = os.sep.join([root, filename]) absFilePath = os.path.abspath(filePath) outputFolder = os.path.join(outputDirectory, appendPath) print "Baking file: " + filename - bakeFile(absFilePath, outputFolder) + bakeFile(absFilePath, outputFolder, 'fbx') + elif os.path.basename(root) == 'skyboxes': + filePath = os.sep.join([root, filename]) + absFilePath = os.path.abspath(filePath) + outputFolder = os.path.join(outputDirectory, appendPath) + print "Baking file: " + filename + bakeFile(absFilePath, outputFolder, 'png') else: filePath = os.sep.join([root, filename]) absFilePath = os.path.abspath(filePath) diff --git a/tools/bake-tools/convertToRelativePaths.py b/tools/bake-tools/convertToRelativePaths.py index 27a7b7ac02..2798e2849f 100644 --- a/tools/bake-tools/convertToRelativePaths.py +++ b/tools/bake-tools/convertToRelativePaths.py @@ -65,6 +65,15 @@ def main(): except: value = handleURL(value) + + if prop == "ambientLight": + for index in value: + value[index] = handleURL(value[index]) + + if prop == "skybox": + for index in value: + value[index] = handleURL(value[index]) + if prop == "serverScripts": value = handleURL(value) From 5fdcd12375db918aa0a5146fca9e05fc1b2ab2ff Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 12 Apr 2018 09:20:46 -0700 Subject: [PATCH 2/3] add baking of skyboxes --- tools/bake-tools/bake.py | 3 ++- tools/bake-tools/convertToRelativePaths.py | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/bake-tools/bake.py b/tools/bake-tools/bake.py index 4051b7a7ca..edbfdf9e9f 100644 --- a/tools/bake-tools/bake.py +++ b/tools/bake-tools/bake.py @@ -71,7 +71,8 @@ def bakeFilesInDirectory(directory, outputDirectory): absFilePath = os.path.abspath(filePath) outputFolder = os.path.join(outputDirectory, appendPath) print "Baking file: " + filename - bakeFile(absFilePath, outputFolder, 'png') + bakeType = os.path.splitext(filename)[1][1:] + bakeFile(absFilePath, outputFolder, bakeType) else: filePath = os.sep.join([root, filename]) absFilePath = os.path.abspath(filePath) diff --git a/tools/bake-tools/convertToRelativePaths.py b/tools/bake-tools/convertToRelativePaths.py index 2798e2849f..70a6a30cfb 100644 --- a/tools/bake-tools/convertToRelativePaths.py +++ b/tools/bake-tools/convertToRelativePaths.py @@ -6,7 +6,7 @@ def createAssetMapping(assetDirectory): baseDirectory = os.path.basename(os.path.normpath(assetDirectory)) for root, subfolder, filenames in os.walk(assetDirectory): for filename in filenames: - if not filename.endswith('.ktx'): + if not filename.endswith('.ktx') or os.path.basename(root) == 'skyboxes': substring = os.path.commonprefix([assetDirectory, root]) newPath = root.replace(substring, ''); filePath = os.sep.join([newPath, filename]) @@ -30,7 +30,7 @@ def handleURL(url): baseFilename = os.path.basename(url) filename = os.path.splitext(baseFilename)[0] newUrl = MAP[filename] - print newUrl + print url + ' -> ' + newUrl return newUrl def handleOptions(): @@ -43,8 +43,12 @@ def main(): argsLength = len(sys.argv) if argsLength == 3: jsonFile = sys.argv[1] - gzipFile = jsonFile + '.gz' assetDirectory = sys.argv[2] + inputFilename = os.path.basename(jsonFile); + absPath = os.path.abspath(assetDirectory) + finalPath = absPath.replace('\\', '/'); + gzipFile = finalPath + '/' + inputFilename + '.gz' + print gzipFile createAssetMapping(assetDirectory) f = open(jsonFile) data = json.load(f) From 74f7a33a74f6ec8d65ac28808f0c89048ef7f246 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 12 Apr 2018 09:24:32 -0700 Subject: [PATCH 3/3] undo some changes --- libraries/image/src/image/Image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/image/src/image/Image.cpp b/libraries/image/src/image/Image.cpp index 0b4acb29c4..696e311495 100644 --- a/libraries/image/src/image/Image.cpp +++ b/libraries/image/src/image/Image.cpp @@ -37,7 +37,7 @@ bool DEV_DECIMATE_TEXTURES = false; std::atomic DECIMATED_TEXTURE_COUNT{ 0 }; std::atomic RECTIFIED_TEXTURE_COUNT{ 0 }; -static const auto& HDR_FORMAT = gpu::Element::COLOR_R11G11B10; +static const auto HDR_FORMAT = gpu::Element::COLOR_R11G11B10; static std::atomic compressColorTextures { false }; static std::atomic compressNormalTextures { false };