READ THE RULES: Click here

Follow us on Facebook: https://www.facebook.com/xentax/ :)

[DOC] Xbox360 texture basics, swizzling, endian

Get your graphics formats figures out here! Got details for others? Post here!
Post Reply
User avatar
Dageron
advanced
Posts: 56
Joined: Mon May 25, 2009 8:22 am
Location: Russian Empire
Has thanked: 11 times
Been thanked: 58 times
Contact:

[DOC] Xbox360 texture basics, swizzling, endian

Post by Dageron » Thu Oct 10, 2013 9:57 am

I have written a large article about Xbox360 graphics storage methodology:
http://dageron.com/?page_id=5238&lang=en

It has all info about swizzling (tiling), endiannes and other related things (D3DBaseTexture specification also).
Everything this I used in my GTA V Console Texture Editor.
Necessary parts of source code are provided.

Hope that will be helpful for developers interested in Xbox360 graphics research.
Improvements are welcome :) .
News about game research: http://dageron.com
Twitter: @DageronStudio

deepshit
advanced
Posts: 76
Joined: Tue Jan 31, 2012 9:43 pm
Has thanked: 41 times
Been thanked: 27 times

Re: [DOC] Xbox360 texture basics, swizzling, endian

Post by deepshit » Thu Oct 10, 2013 1:53 pm

Hi Dageron
Nice article.
I have implemented Xbox360 Untiling and it works but only on base mipmap. Other mipmaps are kinda strange.
I think they're 256 byte aligned.
Do you have any info on untiling mipmaps? especially the mipTail that is the most strange.
Thanks

User avatar
cra0
ultra-veteran
ultra-veteran
Posts: 432
Joined: Fri Apr 27, 2012 9:37 am
Has thanked: 29 times
Been thanked: 183 times
Contact:

Re: [DOC] Xbox360 texture basics, swizzling, endian

Post by cra0 » Sat Oct 19, 2013 6:41 am

Nice Documentation +1

User avatar
Bastien
advanced
Posts: 69
Joined: Sun Apr 15, 2012 1:08 am
Has thanked: 26 times
Been thanked: 12 times

Re: [DOC] Xbox360 texture basics, swizzling, endian

Post by Bastien » Sat Oct 19, 2013 7:05 pm

Really nice docs and website, bookmarked!

Could you please do some documentation/examples on image swizzling in normal textures (DXT5) for pc?
Usually the image looks fine but channels are inverted + something else, making them not suitable for 3d apps.
MrAdults wrote:Just swap the red and alpha channels of the image, scale and bias into vector space (0-255 to -1.0-1.0), then determine blue's contribution by subtracting the length of r+g from 1. (since you know the end result is a unit vector) Sometimes games will also store r+g biased, such that when you set blue to 1.0 and normalize you will end up with the correct normal. (this is common because the normal is in tangent space which means it will always revolve around z and can easily be clamped)

I Know how to decode DXT5, but I'd like to know the process and theory behind why they do that to import-export textures for diifferent game engines.

User avatar
Dageron
advanced
Posts: 56
Joined: Mon May 25, 2009 8:22 am
Location: Russian Empire
Has thanked: 11 times
Been thanked: 58 times
Contact:

Re: [DOC] Xbox360 texture basics, swizzling, endian

Post by Dageron » Mon Oct 21, 2013 5:20 pm

Hadn't worked with normal textures yet.
But figured out everything with mipmaps :) .

Here it is my code for mipmap alignment, if someone is interested in:

Code: Select all

function GetMipOffsetXbox360(dwTextureType: DWORD; var dwWidth: DWORD; var dwHeight: DWORD; dwMipMaps, dwOffset: DWORD): DWORD;
var
  i: integer;
  dwSize: DWORD;
  h, w: DWORD;
begin
 for i := 1 to dwMipMaps-1 do
 begin
    if  GetGPUTEXTUREFORMAT(dwTextureType)='GPUTEXTUREFORMAT_DXT1' then
    begin
      W:=dwWidth;
      H:=dwHeight;
      if (W mod 128 <> 0) then W := W + (128 - W mod 128);
      if (H mod 128 <> 0) then H := H + (128 - H mod 128);
      dwSize:=W*H div 2;
    end;
  if GetGPUTEXTUREFORMAT(dwTextureType)='GPUTEXTUREFORMAT_DXT2_3' then
    begin
      W:=dwWidth;
      H:=dwHeight;
      if (W mod 128 <> 0) then W := W + (128 - W mod 128);
      if (H mod 128 <> 0) then H := H + (128 - H mod 128);
      dwSize:=W*H;
    end;
  if GetGPUTEXTUREFORMAT(dwTextureType)='GPUTEXTUREFORMAT_DXT4_5' then
    begin
      W:=dwWidth;
      H:=dwHeight;
      if (W mod 128 <> 0) then W := W + (128 - W mod 128);
      if (H mod 128 <> 0) then H := H + (128 - H mod 128);
      dwSize:=W*H;
    end;
  if  GetGPUTEXTUREFORMAT(dwTextureType)='GPUTEXTUREFORMAT_8_8_8_8' then
    begin
      W:=dwWidth;
      H:=dwHeight;
      if (W mod 128 <> 0) then W := W + (128 - W mod 128);
      if (H mod 128 <> 0) then H := H + (128 - H mod 128);
      dwSize:=W*H*4;
    end;
  dwWidth:=dwWidth div 2;
  dwHeight:=dwHeight div 2;
  dwOffset:=dwOffset+dwSize;
 end;
 result:=dwOffset;
end;
Calculates offset of the mimpap level you need.
Next you should work with it in the same way, as with usual texture (don't forget that Width and Height had been changed).
News about game research: http://dageron.com
Twitter: @DageronStudio

Beedy
beginner
Posts: 36
Joined: Mon Dec 05, 2016 11:12 am
Has thanked: 4 times
Been thanked: 8 times

Re: [DOC] Xbox360 texture basics, swizzling, endian

Post by Beedy » Mon Jun 24, 2019 10:22 pm

Dageron wrote:
Thu Oct 10, 2013 9:57 am
I have written a large article about Xbox360 graphics storage methodology:
http://dageron.com/?page_id=5238&lang=en

It has all info about swizzling (tiling), endiannes and other related things (D3DBaseTexture specification also).
Everything this I used in my GTA V Console Texture Editor.
Necessary parts of source code are provided.

Hope that will be helpful for developers interested in Xbox360 graphics research.
Improvements are welcome :) .
This article has been lost on the internet. There are many snapshots from dageron.com on the wayback machine but not this article. Has anyone saved it?

GHFear
advanced
Posts: 48
Joined: Tue Dec 04, 2018 9:29 am
Has thanked: 6 times
Been thanked: 8 times

Re: [DOC] Xbox360 texture basics, swizzling, endian

Post by GHFear » Wed Jul 10, 2019 12:54 am

yeah, if anyone got these docs, i would love to have em too.
AES Key and UE4 Modding commissions:
https://bit.ly/31PFc3i


If you appreciate my work and want to donate:
Paypal: ghfear@hotmail.com

Post Reply