Important information: this site is currently scheduled to go offline indefinitely by end of the year.

[DOC] Xbox360 texture basics, swizzling, endian

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

[DOC] Xbox360 texture basics, swizzling, endian

Post 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 :) .
deepshit
advanced
Posts: 76
Joined: Tue Jan 31, 2012 9:43 pm
Has thanked: 41 times
Been thanked: 30 times

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

Post 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
User avatar
cra0
ultra-veteran
ultra-veteran
Posts: 438
Joined: Fri Apr 27, 2012 9:37 am
Has thanked: 29 times
Been thanked: 189 times
Contact:

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

Post by cra0 »

Nice Documentation +1
User avatar
Bastien
advanced
Posts: 70
Joined: Sun Apr 15, 2012 1:08 am
Has thanked: 27 times
Been thanked: 13 times

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

Post 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.
Dageron
advanced
Posts: 56
Joined: Mon May 25, 2009 8:22 am
Has thanked: 11 times
Been thanked: 58 times

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

Post 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).
Beedy
advanced
Posts: 47
Joined: Mon Dec 05, 2016 11:12 am
Has thanked: 8 times
Been thanked: 14 times

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

Post 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?
GHFear
advanced
Posts: 50
Joined: Tue Dec 04, 2018 9:29 am
Has thanked: 7 times
Been thanked: 9 times

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

Post by GHFear »

yeah, if anyone got these docs, i would love to have em too.
If you appreciate my work and want to donate:
Paypal: [email protected]
Post Reply