Comments (3)
I believe the swizzle of these textures is based on the TIM2
format. You can find more information here: https://openkh.dev/common/tm2.html
This page didn't exist when I was working on this. Hopefully this helps.
from sh3redux.
I believe the swizzle of these textures is based on the
TIM2
format. You can find more information here: https://openkh.dev/common/tm2.htmlThis page didn't exist when I was working on this. Hopefully this helps.
yes i have managed to unswizzle 8bpp textures friend thank you, now i'm struggling with 4 bpp. also i have looked at your palette data code and while it worked maybe 50% of the time, i am having issues with sometimes incorrect palette. If you have any information, I would appreciate it
from sh3redux.
If you have any information, I would appreciate it
Sure. This guys has some pseudocode related to unswizzling TM2 stuff, he took it from the (now defunct) Xentax wiki. I believe this is where the original implementation of this came from when it was submitted to sh3redux
, however this was approaching 8 years old now.
Maybe @muddle12 can himself comment on this further.
https://github.com/muddle12/DCExtractor/blob/main/Specifications/Images/TM2.md
//Convert the TIM2Picture's palette to linear 32-bit True Color.
Color[] ConvertPicturePaletteToRGBA(TIM2Picture tPicture)
{
//If there is no palette, return an empty palette.
if (tPicture.paletteBytes == null || tPicture.paletteBytes.Length == 0)
return null;
//Otherwise, we're going to have to figure out which palette we're using based on the paletteColorSize.
Color[] tPalette;
if (tPicture.bitsPerPixel <= 8)
{
//We'll infer which palette type we're using based on the size of each individual palette entry.
switch (tPicture.colorSize)
{
case 2://16 BIT LE_ABGR_1555?
{
tPalette = FromBufferABGR1555(tPicture.paletteBytes, tPicture.paletteSize);
}
break;
case 3://24 BIT RGB?
{
tPalette = FromBufferRGB24Bit(tPicture.paletteBytes, tPicture.paletteSize);
}
break;
case 4://32 BIT RGBA?
{
tPalette = FromBufferRGBA32Bit(tPicture.paletteBytes, tPicture.paletteSize);
}
break;
default://Invalid data.
return null;
}
//If the palette is interleaved, we need to unpack that into something linear.
if (tPicture.isLinearPalette == false)
{
//The TIM2 palettes always have these fixed values.
const int nBlockCount = 2;
const int nStripeCount = 2;
const int nColorCount = 8;
//Some calculations for unpacking the palette.
int nPartCount = tPalette.Length / 32;
int nPartStride = nColorCount * nStripeCount * nBlockCount;
int nStripeStride = nStripeCount * nColorCount;
//This next part was ripped wholesale from the xentax references. I couldn't tell you exactly what's going on, but it appears to work.
//If I had to guess, TIM2 has a very particular kind of interleave using blocks instead of straight stripes.
int i = 0;
Color[] tUnpackedColors = new Color[tPalette.Length];
for (int part = 0; part < nPartCount; part++)
{
for (int block = 0; block < nBlockCount; block++)
{
for (int stripe = 0; stripe < nStripeCount; stripe++)
{
for (int color = 0; color < nColorCount; color++)
{
tUnpackedColors[i++] = tPalette[(part * nPartStride) + (block * nColorCount) + (stripe * nStripeStride) + color];
}
}
}
}
//overwrite the original palette, as we don't need it anymore.
tPalette = tUnpackedColors;
}
}
return tPalette;
}
from sh3redux.
Related Issues (20)
- Useless warnings from gcc -Weffc++ HOT 4
- Provide default constructors and move constructors to source (*.cpp) files.
- overly careful numeric casts HOT 2
- Consider libfmt for Log HOT 5
- Create bugs folder to outline found compiler bugs HOT 4
- Reverse Engineering file formats HOT 15
- CMake include_directories Error HOT 17
- file format about silent hill2 HOT 3
- Problems with building( Cmake and Sdl2) HOT 29
- Include required libraries in repository HOT 4
- Switch from `cmake` to `premake5` HOT 7
- Game logic hardcoding HOT 3
- Is this project still active? HOT 1
- Could you talk about konami's skeletal animation format by Reverse Engineering?
- Random questions to the developers HOT 2
- Weird input into vfile HOT 3
- Arc extraction produces wong output HOT 2
- CMakesLists.txt problems HOT 2
- Generic resource loading HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sh3redux.