From 5e0d0a3d6db7174ce300cd4664430e73b81498d6 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Fri, 13 Dec 2024 16:47:42 -0600 Subject: [PATCH] fix: remove extreme jpeg compression --- .../src/core/blitz/readTexture/index.ts | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/packages/scripts/src/core/blitz/readTexture/index.ts b/packages/scripts/src/core/blitz/readTexture/index.ts index 4e0b954b9..ce3ff9e88 100644 --- a/packages/scripts/src/core/blitz/readTexture/index.ts +++ b/packages/scripts/src/core/blitz/readTexture/index.ts @@ -1,14 +1,9 @@ import { DdsReadStream, PvrReadStream } from '@blitzkit/core'; import { existsSync } from 'fs'; -import sharp, { JpegOptions } from 'sharp'; +import sharp from 'sharp'; import { readDVPLFile } from '../readDVPLFile'; import { TextureMutation } from './constants'; -const jpegOptions: JpegOptions = { - quality: 20, - mozjpeg: true, -}; - export async function readTexture(path: string, mutation?: TextureMutation) { const ddsTexturePath = path.replace('.tex', '.dx11.dds.dvpl'); const isDds = existsSync(ddsTexturePath); @@ -40,7 +35,7 @@ export async function readTexture(path: string, mutation?: TextureMutation) { raw.data[index + 3] = 255; } - return await sharp(raw.data, { raw }).jpeg(jpegOptions).toBuffer(); + return await sharp(raw.data, { raw }).jpeg().toBuffer(); } case TextureMutation.RoughnessMetallicness: { @@ -49,16 +44,16 @@ export async function readTexture(path: string, mutation?: TextureMutation) { }); const metallicness = sharp(raw.data, { raw }) .extractChannel('green') - .jpeg(jpegOptions) + .jpeg() .toBuffer(); const roughness = sharp(raw.data, { raw }) .extractChannel('alpha') - .jpeg(jpegOptions) + .jpeg() .toBuffer(); return await newImage .joinChannel(await Promise.all([roughness, metallicness])) - .jpeg(jpegOptions) + .jpeg() .toBuffer(); } @@ -69,18 +64,15 @@ export async function readTexture(path: string, mutation?: TextureMutation) { */ return await sharp(raw.data, { raw }) .extractChannel('alpha') - .jpeg(jpegOptions) + .jpeg() .toBuffer(); } case TextureMutation.Albedo: { - return await sharp(raw.data, { raw }) - .removeAlpha() - .jpeg(jpegOptions) - .toBuffer(); + return await sharp(raw.data, { raw }).removeAlpha().jpeg().toBuffer(); } default: - return await sharp(raw.data, { raw }).jpeg(jpegOptions).toBuffer(); + return await sharp(raw.data, { raw }).jpeg().toBuffer(); } }