Skip to content

Commit

Permalink
Fix GTA in WebGPU
Browse files Browse the repository at this point in the history
Fixes #728
  • Loading branch information
magcius committed Feb 2, 2025
1 parent 8d80483 commit b3657e8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/GrandTheftAuto3/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,21 @@ export function rwTexture(texture: rw.Texture, txdName: string, useDXT = true):
const image = texture.raster.toImage();
image.unindex();
const { width, height } = image;
const levels = [image.pixels!.slice()];
const pixelFormat = (image.depth === 32) ? GfxFormat.U8_RGBA_NORM : GfxFormat.U8_RGB_NORM;
const levels: Uint8Array[] = [];
if (image.depth === 24) {
const in24 = image.pixels!;
const out = new Uint8Array(width * height * 4);
for (let i = 0; i < width * height; i++) {
out[i*4+0] = in24[i*3+0];
out[i*4+1] = in24[i*3+1];
out[i*4+2] = in24[i*3+2];
out[i*4+3] = 0xFF;
}
levels.push(out);
} else if (image.depth === 32) {
levels.push(image.pixels!.slice());
}
const pixelFormat = GfxFormat.U8_RGBA_NORM;
const transparent = image.hasAlpha();
image.delete();
return { name, width, height, levels, pixelFormat, transparent };
Expand Down

0 comments on commit b3657e8

Please sign in to comment.