Add linear filtering to column drawers and fix offsetting bug with wall/span linear filters
This commit is contained in:
parent
2fe5cb4f77
commit
4b18530047
15 changed files with 309 additions and 94 deletions
|
|
@ -139,45 +139,3 @@ SSAInt DrawerCodegen::calc_blend_bgalpha(SSAVec4i fg, SSAInt destalpha)
|
|||
SSAInt inv_alpha = 256 - alpha;
|
||||
return (destalpha * alpha + 256 * inv_alpha + 128) >> 8;
|
||||
}
|
||||
|
||||
SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr col0, SSAUBytePtr col1, SSAInt texturefracx, SSAInt texturefracy, SSAInt one, SSAInt height)
|
||||
{
|
||||
SSAInt frac_y0 = (texturefracy >> FRACBITS) * height;
|
||||
SSAInt frac_y1 = ((texturefracy + one) >> FRACBITS) * height;
|
||||
SSAInt y0 = frac_y0 >> FRACBITS;
|
||||
SSAInt y1 = frac_y1 >> FRACBITS;
|
||||
|
||||
SSAVec4i p00 = col0[y0 * 4].load_vec4ub(true);
|
||||
SSAVec4i p01 = col0[y1 * 4].load_vec4ub(true);
|
||||
SSAVec4i p10 = col1[y0 * 4].load_vec4ub(true);
|
||||
SSAVec4i p11 = col1[y1 * 4].load_vec4ub(true);
|
||||
|
||||
SSAInt inv_b = texturefracx;
|
||||
SSAInt a = (frac_y1 >> (FRACBITS - 4)) & 15;
|
||||
SSAInt inv_a = 16 - a;
|
||||
SSAInt b = 16 - inv_b;
|
||||
|
||||
return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8;
|
||||
}
|
||||
|
||||
SSAVec4i DrawerCodegen::sample_linear(SSAUBytePtr texture, SSAInt xfrac, SSAInt yfrac, SSAInt xbits, SSAInt ybits)
|
||||
{
|
||||
SSAInt xshift = (32 - xbits);
|
||||
SSAInt yshift = (32 - ybits);
|
||||
SSAInt xmask = (SSAInt(1) << xshift) - 1;
|
||||
SSAInt ymask = (SSAInt(1) << yshift) - 1;
|
||||
SSAInt x = xfrac >> xbits;
|
||||
SSAInt y = yfrac >> ybits;
|
||||
|
||||
SSAVec4i p00 = texture[((y & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(true);
|
||||
SSAVec4i p01 = texture[(((y + 1) & ymask) + ((x & xmask) << yshift)) * 4].load_vec4ub(true);
|
||||
SSAVec4i p10 = texture[((y & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(true);
|
||||
SSAVec4i p11 = texture[(((y + 1) & ymask) + (((x + 1) & xmask) << yshift)) * 4].load_vec4ub(true);
|
||||
|
||||
SSAInt inv_b = (xfrac >> (xbits - 4)) & 15;
|
||||
SSAInt inv_a = (yfrac >> (ybits - 4)) & 15;
|
||||
SSAInt a = 16 - inv_a;
|
||||
SSAInt b = 16 - inv_b;
|
||||
|
||||
return (p00 * (a * b) + p01 * (inv_a * b) + p10 * (a * inv_b) + p11 * (inv_a * inv_b) + 127) >> 8;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue