I develop and maintain open-source software in my spare time.
- LinkedIn: @tim-van-scherpenzeel
CLI tool for texture compression using ASTC, ETC, PVRTC and S3TC in a KTX container.
License: MIT License
I develop and maintain open-source software in my spare time.
https://timvanscherpenzeel.github.io/texture-compressor/
Error in console:
Uncaught TypeError: Class constructors cannot be invoked without 'new'
at new THREE.KTXLoader
HI,
Thanks for the tool.
Is any options to enable vertical flip and disable MIPMaps?
Thanks,
Sabari.
In the light of a new project called texture-handler
I would like to create loaders for the textures outputted by texture-compressor
. During the initial steps I already ran into limitations of the current output of the tool.
This unfortunately means that I will have to introduce many breaking changes that have the goal of simplifying both compressing and loading textures.
Remove (Astcenc
PVRTexTool
requires Astcenc
to be in the users path, I would rather keep the current setup and make sure it exports to a PVR container).
Remove Etc2comp
.
Remove .crn
support for Crunch
as I do not plan to provide a Crunch
decoder in texture-handler
.
Export ASTC
in PVR
container using Astcenc
.
Export ETC1
and ETC2
in PVR
containers using PVRTexTool
.
Export DXT1
, DXT3
, DXT5
in DDS
containers using Crunch
.
Export PVRTC1
in PVR
containers using PVRTexTool
.
The reason why I am packing the formats other than S3TC
into PVR
containers is because it will enable conditional loading of a DDS loader on desktop and exclude it from mobile. One major downside of using PVRTexTool over the current compressors is that it is much slower to compress.
Texture-handler
will offer both loaders for PVR
and DDS
hopefully in the near future.
If you have any suggestions, questions feel free to open an issue or a pull request.
Related PR: #2
Quality 9 and 10 do not work with ETC because the mapping is off. It results in an out of bound error in the quality string array.
There is only 4 items in the quality settings array and quality 10 / 2.1 will give id 4 which is out of bounds.
Another way to handle this could be to map quality numbers directly to a quality setting string with a switch. Something like that (only 3 levels).
// Quality flag
const qualityOptions = ['etcfast', 'etcslow', 'etcfastperceptual', 'etcslowperceptual'];
var qualityFlag;
switch(quality) {
case 1:
qualityFlag = qualityOptions[0];
break;
case 2:
qualityFlag = qualityOptions[2];
break;
case 3:
default:
qualityFlag = qualityOptions[3];
break;
}
Hi !
I would like to compress normal maps in S3TC, i saw that should use some flags like cCRNCompFlagPerceptual, but i cant pass it as flag like -f [cCRNCompFlagPerceptual false]
Do you know wich flag i should use for normal maps ?
I run npm install and npm install texture-compressor
then got the error as follow:
any idea?
thx
Error: Cannot find module '../dist/cli/lib/index.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (D:\Job\EGS\texture-compressor\bin\texture-compressor.
js:3:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
First, thank you very much!
The code is very useful for me. While I have found a problem about the mipmap. when the image is not a square, we have to generate the min level to 1X1. But I find that you check the level only by image width and ignore the importance of height, resulting in the min mipmap of 1X2, the appearance of warning in WebGL , and some invalid texture.
Hi.
I compress needed texture to DXT1 and 5 using following:
pack({ type: 's3tc', input: 'input/example.jpg', output: 'output/DXT1.ktx', compression: 'DXT1', quality: 'normal', verbose: true }).then(() => console.log('done!'));
and then load them in threejs using following piece of code:
var boxMaterial = getMaterial('standard'); var loader = new THREE.KTXLoader(); var texture = loader.load('/assets/textures/DXT1.ktx'); boxMaterial.map = texture; var box = getGeometry('box', 3, boxMaterial); scene.add(box);
but when i try to run it in browser i get this warning:
GL_INVALID_OPERATION: Invalid compressed image size
and texture doesnt get rendered.
the same process works perfectly fine on pvrtc and ETC1.
also with astc, i get RGB and there is no alpha channel ... is it how its supposed to be?
ps: my OS is win10
Hi, I'm having a weird issue where I get some colored dots added to some mipmap levels of my dxt textures. It appears to be pretty random: those textures were converted automatically by our scripts on a server, but if I try to convert them locally on my computer with the same parameters, I don't have the issue. Additionnaly, some textures have the problem and some don't (for example, the floor has been treated the same way and is fine)
I posted an issue on Crunch, because it's likely a problem on their end, but just in case, I'm posting it here as well.
texture-compressor/lib/compressWithASTC.js
Lines 177 to 189 in 2187443
fs.exists() is an anachronism and exists only for historical reasons. There should almost never be a reason to use it in your own code.
In particular, checking if a file exists before opening it is an anti-pattern that leaves you vulnerable to race conditions: another process may remove the file between the calls to fs.exists() and fs.open(). Just open the file and handle the error when it's not there.
fs.exists() will be deprecated.
I will need to find a way to ensure the file exists completely before passing it as an input to the Astcenc tool.
Add mipmapping support both to the compressor as well as the demo.
Related PR: #6
I have a warning when using the quality parameter -q 1 with s3tc files.
Warning: No files found: /mnt/c/projects/pioneer-assets/superfast.superfast
I think the '-dxtQuality', flag is missing in the flag mapping array in lib/compressWithS3TC.js
// Flag mapping
const flagMapping = [
'-file',
input,
'-out',
output,
'-fileformat',
'ktx',
`${compressionFlag}`,
+ '-dxtQuality',
`${DXTQualityFlag}`,
'-helperThreads',
os.cpus().length,
'-mipMode',
`${mipmap ? 'Generate' : 'None'}`,
'-maxmips',
`${mipmap ? getMipChainLevels(width) : 16}`,
];
As part of asset-pipeline I've ran into issues when trying to use texture compressor as a library.
Hi !
What is the default encoding output for S3TC file, is it RGB ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.