Giter VIP home page Giter VIP logo

texture-compressor's Introduction

Hi ๐Ÿ‘‹

I develop and maintain open-source software in my spare time.

Get in touch

texture-compressor's People

Contributors

aidinabedi avatar osman-turan avatar timvanscherpenzeel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

texture-compressor's Issues

Enable Vertical flip

HI,

Thanks for the tool.

Is any options to enable vertical flip and disable MIPMaps?

Thanks,
Sabari.

Getting random polka dots on some mipmap levels

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.

image

S3TC quality tag not passed to crunch

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}`,
		];

can not find module

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)

about the compress texture mipmap.

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.

error when using compressed textures in threejs

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

S3TC Normal Map - Crunch Flag

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 ?

Simplify setup, remove DDS and PVR and use KTX container instead

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

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;
		}

Implementation to fix non-existing file is problematic

// Check if the file exists
fsExtra.exists(`${tempDirectory}/${tempFilename}`, (exists) => {
if (exists) {
// Compress flipped instead of the direct input
runCompression(`${tempDirectory}/${tempFilename}`)
// Ensure final file has been written before removing the temporary file (this may be unnecessary)
.then(() => {
// Clean up the temporary directory and the temporary image
fsExtra.remove(`${tempDirectory}/${tempFilename}`);
fsExtra.remove(tempDirectory);
});
}
});

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.

See https://stackoverflow.com/questions/31799274/node-js-fs-exists-will-be-deprecated-what-to-use-instead

I will need to find a way to ensure the file exists completely before passing it as an input to the Astcenc tool.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.