g3_bitmap_common() (Bitmap.c) used the same bm_w/bm_h for both the on-screen quad size and its texture-coordinate bounds. The former should use patch 04's native-size override for a modded/upscaled bitmap; the latter must always use the bitmap's own real dimensions, since that's still what's actually being sampled. OpenGL never hit this (opengl_bitmap() ignores these bounds and always maps the whole real texture), but the software renderer's h_map() takes them as literal pixel coordinates to interpolate, so the override capped how much of a larger bitmap it ever read - cropping anything past the original sprite's bounds, such as an upscaled critter's limbs. Split into a separate tex_w/tex_h pair, always the bitmap's real size, used for every texture-coordinate computation. README.md: document this, and the previously-undocumented engine-debug-tools RSD8 decode tracing patch (02).
This commit is contained in:
@@ -200,7 +200,15 @@
|
||||
_g3d_bitmap_clut = (p->i & 0x00ff00) + grd_screen->ltab;
|
||||
_g3d_bitmap_poly = vpl;
|
||||
return (g3_bitmap_common(bm, p));
|
||||
@@ -185,6 +196,15 @@
|
||||
@@ -176,6 +187,7 @@
|
||||
grs_vertex *tempG1, *tempG2;
|
||||
fix tempResult;
|
||||
int32_t bm_w, bm_h;
|
||||
+ int32_t tex_w, tex_h;
|
||||
fix dx, dy;
|
||||
|
||||
// MLA- these were globals, I made them locals for PPC speed, they aren't
|
||||
@@ -185,6 +197,15 @@
|
||||
long rm2;
|
||||
long rm3;
|
||||
|
||||
@@ -216,7 +224,7 @@
|
||||
#ifdef stereo_on
|
||||
if (_g3d_stereo & 1) {
|
||||
|
||||
@@ -209,9 +229,11 @@
|
||||
@@ -209,9 +230,23 @@
|
||||
if ((p->codes & CC_CLIP_OVERFLOW) != 0)
|
||||
return (0L);
|
||||
|
||||
@@ -225,12 +233,71 @@
|
||||
- bm_h = bm->h;
|
||||
+ // copy a few things into locals - w_override/h_override, if set (see
|
||||
+ // _g3d_bitmap_w_override's own comment), take the place of the bitmap's
|
||||
+ // own pixel dimensions here.
|
||||
+ // own pixel dimensions here, for the on-screen quad's world-space size
|
||||
+ // only. tex_w/tex_h stay the bitmap's own real dimensions always: the
|
||||
+ // quad's u/v bounds (below) are pixel coordinates into bm's own actual
|
||||
+ // pixel data - the software renderer's scanline texture mapper
|
||||
+ // (h_map(), gentm.c) interpolates and samples them literally, so
|
||||
+ // overriding them to a smaller size here would make it only ever read
|
||||
+ // part of a bitmap bigger than that override (such as an upscaled mod's
|
||||
+ // replacement art), cropping the rest. OpenGL doesn't read u/v from here
|
||||
+ // at all (opengl_bitmap() always maps the whole real texture over the
|
||||
+ // quad), which is why this only ever showed up in the software
|
||||
+ // renderer.
|
||||
+ bm_w = w_override ? w_override : bm->w;
|
||||
+ bm_h = h_override ? h_override : bm->h;
|
||||
+ tex_w = bm->w;
|
||||
+ tex_h = bm->h;
|
||||
|
||||
tempL = p->gZ; // mov eax,[edi].z
|
||||
tempL <<= 8; // sal eax,8 ;should be
|
||||
@@ -299,7 +334,7 @@
|
||||
tempG1->y = tempL2;
|
||||
|
||||
// vpl[1][2] = bitmap.w-1
|
||||
- tempG1->u = (bm_w - 1) << 16;
|
||||
+ tempG1->u = (tex_w - 1) << 16;
|
||||
|
||||
// vpl[1][3] = 0
|
||||
tempG1->v = 0;
|
||||
@@ -326,10 +361,10 @@
|
||||
tempG1->y = tempL2;
|
||||
|
||||
// vpl[2][2] = bitmap.w-1
|
||||
- tempG1->u = (bm_w - 1) << 16;
|
||||
+ tempG1->u = (tex_w - 1) << 16;
|
||||
|
||||
// vpl[2][3] = bitmap.h-1
|
||||
- tempG1->v = (bm_h - 1) << 16;
|
||||
+ tempG1->v = (tex_h - 1) << 16;
|
||||
|
||||
// vpl[2][4] undefined
|
||||
|
||||
@@ -356,7 +391,7 @@
|
||||
tempG1->u = 0;
|
||||
|
||||
// vpl[3][3] = bitmap.h
|
||||
- tempG1->v = bm_h << 16;
|
||||
+ tempG1->v = tex_h << 16;
|
||||
|
||||
// vpl[3][4] undefined
|
||||
|
||||
@@ -380,11 +415,13 @@
|
||||
if (dy > dx)
|
||||
dx = dy; // get max value in dx
|
||||
|
||||
- // shift down because bm_w isn't fixed, and we only double when twice the size
|
||||
+ // shift down because tex_w isn't fixed, and we only double when twice the size
|
||||
dx >>= 0x11;
|
||||
|
||||
// make sure doubled bitmap won't overflow unpack buffer (that's roughly 1/5 of 64k)
|
||||
- if ((bm_w <= dx) && (bm_w * bm_h <= 12000)) {
|
||||
+ // - against the bitmap's own real size (tex_w/tex_h), same as the u/v this doubles
|
||||
+ // just below: both operate on bm's actual pixel data, not the on-screen override.
|
||||
+ if ((tex_w <= dx) && (tex_w * tex_h <= 12000)) {
|
||||
// first fix all u's and v's
|
||||
for (tempL = 0; tempL < 4; tempL++) {
|
||||
_g3d_bitmap_poly[tempL]->u <<= 1;
|
||||
--- a/src/Libraries/3D/Source/3d.h
|
||||
+++ b/src/Libraries/3D/Source/3d.h
|
||||
@@ -720,7 +720,8 @@
|
||||
|
||||
Reference in New Issue
Block a user