Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrectly decoding textures #135

Open
KirillAldashkin opened this issue Jun 20, 2024 · 1 comment
Open

Incorrectly decoding textures #135

KirillAldashkin opened this issue Jun 20, 2024 · 1 comment

Comments

@KirillAldashkin
Copy link

KirillAldashkin commented Jun 20, 2024

Hello! I'm trying to export some textures from an AssetBundle file using AssetsTools.NET.Texture and SixLabors.ImageSharp, but it produces incorrect texture (I also got the correct one using random asset browser program).

Code (minimal reproduction):

using AssetsTools.NET.Extra;
using AssetsTools.NET.Texture;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

var manager = new AssetsManager("commonassets.ab");
var bundle = manager.LoadBundleFile(path);
var assetFile = manager.LoadAssetsFileFromBundle(bundle, "CAB-580061e156ea5e60815bbe6b768da65c");
var asset = assetFile.file.GetAssetInfo(-9143244479974055439);

var field = manager.GetBaseField(assetFile, asset);
var texture = TextureFile.ReadTextureFile(field);
var bgraRaw = texture.GetTextureData(null, bundle.file);

var image = Image.LoadPixelData<Bgra32>(bgraRaw, texture.m_Width, texture.m_Height);
image.SaveAsPng($"texture.png");

Assets bundle file

commonassets.zip

What this program produces:

What this program produces

Actual texture:

Actual texture

@nesrak1
Copy link
Owner

nesrak1 commented Jun 20, 2024

That method seems broken and probably never worked. I'll remove it next update. You should be passing it just the assets file: texture.GetTextureData(assetsFile);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants