Page 1 of 1

[DOC] Xbox360 texture basics, swizzling, endian

Posted: Thu Oct 10, 2013 9:57 am
by Dageron
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 :) .

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

Posted: Thu Oct 10, 2013 1:53 pm
by deepshit
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

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

Posted: Sat Oct 19, 2013 6:41 am
by cra0
Nice Documentation +1

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

Posted: Sat Oct 19, 2013 7:05 pm
by Bastien
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.

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

Posted: Mon Oct 21, 2013 5:20 pm
by Dageron
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).

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

Posted: Mon Jun 24, 2019 10:22 pm
by Beedy
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?

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

Posted: Wed Jul 10, 2019 12:54 am
by GHFear
yeah, if anyone got these docs, i would love to have em too.