@ -49,7 +49,7 @@ bool process_textures(const world_t* world, std::vector<ps1bsp_texture_t>& outTe
if ( strcmp ( miptex - > name , " clip " ) & & strcmp ( miptex - > name , " trigger " ) )
rectangles . emplace_back ( rectpack2D : : rect_xywh ( 0 , 0 , miptex - > width > > ps1mip , miptex - > height > > ps1mip ) ) ;
else
rectangles . emplace_back ( rectpack2D : : rect_xywh ( 0 , 0 , 0 , 0 ) ) ;
rectangles . emplace_back ( rectpack2D : : rect_xywh ( 0 , 0 , miptex - > width > > 3 , miptex - > width > > 3 ) ) ; // Add the lowest mip level so that it at least gets included in the final texture list, and we don't mess up the texture IDs
}
// Automatic atlas packing. Nice but it tries to make a square atlas which is not what we want. (This is solved by hacking the header itself)
@ -110,27 +110,29 @@ bool process_textures(const world_t* world, std::vector<ps1bsp_texture_t>& outTe
}
ps1bsp_texture_t ps1tex = { 0 } ;
ps1tex . w = ( u_char ) miptex - > width ;
ps1tex . h = ( u_char ) miptex - > height ;
u_short x = rectangle . x + 512 ;
u_short y = rectangle . y + 256 ;
ps1tex . w = ( u_char ) rectangle . w ;
ps1tex . h = ( u_char ) rectangle . h ;
// prect is derived from the texture's position inside the atlas (rectangle.x/y) and the planned position of the atlas in VRAM (512, 256)
// mode is always 1 (8-bit palletized)
//texture->uoffs = (texture->prect.x % 64) << (2 - (texture->mode & 0x3));
//texture->voffs = (texture->prect.y & 0xFF);
u_short x = ( rectangle . x / 2 ) + 512 ; // Divide by 2 to get the coordinate in 16-bit pixel units
u_short y = rectangle . y + 256 ;
/*
tp specifies the color depth for the texture page in the range of 0 to 2 ( 0 : 4 - bit , 1 : 8 - bit , 2 : 16 - bit ) .
abr specifies the blend operator for both non - textured and textured semi - transparent primitives which can be ignored for now and lastly ,
x , y specifies the X , Y coordinates of the VRAM in 16 - bit pixel units .
Keep in mind that the coordinates will be rounded down to the next lowest texture page . */
ps1tex . tpage = getTPage ( 1 , 0 , x , y ) ;
ps1tex . uoffs = ( u_char ) ( ( x % 64 ) < < 1 ) ;
const int mode = 1 ; // 8-bit per pixel, all Quake textures use this
ps1tex . tpage = getTPage ( mode , 0 , x , y ) ;
ps1tex . uoffs = ( u_char ) ( ( x % 64 ) < < ( 2 - mode ) ) ;
ps1tex . voffs = ( u_char ) ( y & 0xFF ) ;
// TODO: animated textures
outTextures . push_back ( ps1tex ) ;
}
}