1.1.0 • Published 6 years ago

babylonjs-texture-generator v1.1.0

Weekly downloads
11
License
Apache 2.0
Repository
github
Last release
6 years ago

Babylonjs texture generator

About

This is a tool that generates PVRTC, ETC1, ETC2, ASTC, DXT textures from png and jpg files. It can run on node or as a gulp task.

It is meant to work with Babylon.js. The tool is a port of two .bat files.

Installation

In order to use the tool, you need to have installed:

  • PVRTexToolCLI (download)
  • ASTC Evaluation Codec (download)
  • Add ASTC Evaluation Codec to your path, a process which depends on your OS. (documentation at page 5)
  • Run npm run build in terminal

Usage

Import/require the exposed function generateTextures to your script. It accepts one argument as an object with the following attributes:

  • PVRTexToolCLI - string: The absolute path to the PVRTexToolCLI tool.
  • inputDir - string: The directory where the image files are located. It will be read recursively and all the images will be used in order to generate the new textures.
  • quality - string (optional), (options "low"/"high", default: "high"): The quality of the exported textures.
  • exportFormats - string (options "PVRTC"/"ETC1"/"ETC2"/"ASTC"/"DXT", default: "PVRTC", "ETC1", "ETC2", "ASTC", "DXT"): The format of the exported textures.
  • async - boolean (optional, default: false): Whether the task should run asynchronously.

Example usage:

import generateTextures from "babylonjs-texture-generator";
// Alternatively
// const generateTextures = require("babylonjs-texture-generator");

createGpuTexture({
    PVRTexToolCLI: "/Applications/Imagination/PowerVR_Graphics/PowerVR_Tools/PVRTexTool/CLI/OSX_x86/PVRTexToolCLI",
    inputDir: "/src",
    quality: "high",
    async: false,
    exportFormats: ["PVRTC", "ETC1", "ETC2", "ASTC", "DXT"]
});

Limitations

Currently DXT files can not be exported on MacOS.