mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
fix: little endian pvr
This commit is contained in:
1 parent
fa625dc887
commit
21daf9f3bb
5 files changed
+15
-6
No files matched your search
@@ -533,6 +533,10 @@ if (allTargets || targets?.includes('tankModels')) {
|
||||
baseColor,
|
||||
);
|
||||
|
||||
// writeFile(
|
||||
// `dist/assets/models/${id}.glb`,
|
||||
// await nodeIO.writeBinary(model),
|
||||
// );
|
||||
await mkdir(`dist/assets/models/${id}`, { recursive: true });
|
||||
nodeIO.write(`dist/assets/models/${id}/index.gltf`, model);
|
||||
}
|
||||
|
||||
@@ -199,6 +199,7 @@ export async function extractModel(
|
||||
}
|
||||
|
||||
let minLODDistance = Infinity;
|
||||
let isFirstMaxFloat = true;
|
||||
|
||||
range(component['rc.renderObj']['ro.batchCount']).forEach(
|
||||
(id) => {
|
||||
@@ -209,8 +210,10 @@ export async function extractModel(
|
||||
|
||||
if (
|
||||
lodDistance <= minLODDistance ||
|
||||
// (lodDistance === MAX_FLOAT32 && isFirstMaxFloat)
|
||||
lodDistance === MAX_FLOAT32
|
||||
) {
|
||||
if (lodDistance === MAX_FLOAT32) isFirstMaxFloat = false;
|
||||
minLODDistance = lodDistance;
|
||||
minLODDistanceBatchId = id;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ export async function readTexture(path: string, options?: ReadTextureOptions) {
|
||||
? ddsTexturePath
|
||||
: ddsTexturePath.replace('.dds', '.pvr');
|
||||
const decompressedDvpl = await readDVPLFile(resolvedTexturePath);
|
||||
|
||||
const raw = isDds
|
||||
? await new DdsStream(decompressedDvpl).dds()
|
||||
: new PvrStream(decompressedDvpl).pvr();
|
||||
@@ -82,6 +83,9 @@ export async function readTexture(path: string, options?: ReadTextureOptions) {
|
||||
const g = raw.data[index + 1] / 255;
|
||||
const b = raw.data[index + 2] / 255;
|
||||
const a = raw.data[index + 3] / 255;
|
||||
|
||||
if (a === 0) continue;
|
||||
|
||||
const invA = 1 - a;
|
||||
const rPrime = r + invA * options.baseColor[0];
|
||||
const gPrime = g + invA * options.baseColor[1];
|
||||
|
||||
@@ -177,8 +177,6 @@ export class DdsStream extends WindowsStream {
|
||||
const header = this.header();
|
||||
const dxgiFormat = this.resolveDxgiFormat(header);
|
||||
|
||||
console.log(DxgiFormat[dxgiFormat]);
|
||||
|
||||
switch (dxgiFormat) {
|
||||
case DxgiFormat.BC1_TYPELESS:
|
||||
case DxgiFormat.BC1_UNORM:
|
||||
|
||||
@@ -119,10 +119,10 @@ export class PvrStream extends BufferStream {
|
||||
times(pixelCount, (index) => {
|
||||
const buffer = this.consume(2);
|
||||
const bufferIndex = index * 4;
|
||||
const r = ((buffer[0] & 0b11110000) >>> 4) / 15;
|
||||
const g = (buffer[0] & 0b1111) / 15;
|
||||
const b = ((buffer[1] & 0b11110000) >>> 4) / 15;
|
||||
const a = (buffer[1] & 0b1111) / 15;
|
||||
const r = ((buffer[1] & 0b11110000) >>> 4) / 15;
|
||||
const g = (buffer[1] & 0b1111) / 15;
|
||||
const b = ((buffer[0] & 0b11110000) >>> 4) / 15;
|
||||
const a = (buffer[0] & 0b1111) / 15;
|
||||
|
||||
data[bufferIndex] = Math.round(clamp(r * 255, 0, 255));
|
||||
data[bufferIndex + 1] = Math.round(clamp(g * 255, 0, 255));
|
||||
|
||||
Reference in new issue
Block a user