Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. Gameplay
      2. Missions
      3. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Arena War
      2. After Hours
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA Next

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
Blitz091

Unswizzle Tool

Recommended Posts

Blitz091

A group of emembers at my site have created an unswizzle tool for San Andreas on the Xbox. Skinning characers was before impossible, but soon it will be a reality. Members at another board have requested this tool be implemented into TXD workshop to make it more xbox compatible. I will post a link to the downlaod when it is doen, if the author of workshop wants to add it, great, if he gives proper credit and does it fair great, i will link to the source if he is interested.

Share this post


Link to post
Share on other sites
JernejL

hi, i'm the author of txd workshop (gtatools.com), this is great news! now i need some xbox txds and the unswizzle algorythms, contact me by PM or post files / details in this topic about it.

 

Share this post


Link to post
Share on other sites
fuckindumass

Hey Delfi, love TXDWorkshop thanks so much...I see a common problem with users involvng .bmp, most people think it's not possible to use photoshop/.bmp with TXDWorkshop, check my post here

Share this post


Link to post
Share on other sites
Blitz091
hi, i'm the author of txd workshop (gtatools.com), this is great news! now i need some xbox txds and the unswizzle algorythms, contact me by PM or post files / details in this topic about it.

www.therockerscabin.com/soulxplorer/

 

go tehre, i will let you into a coding section. You will get all the info there.

Share this post


Link to post
Share on other sites
aru

If you need generic XBOX Swizzle/Unswizzle functions, here's something I wrote a while ago. It's in VB, I hope its understandable for you Delphi guys smile.gif UnswizBlock and SwizBlock are just helpers... Swizzle and Unswizzle are the real thing... CTpkTexture is just a custom class to encapsulate a texture object... the properties used from it should be enough to show what information is required.

 

 

Private Function SwizBlock(ByRef OutData() As Byte, ByRef InData() As Byte, ByRef OffsOut As Long, ByVal Offs As Long, ByVal BlWidth As Long, ByVal BlHeight As Long, ByVal Stride As Long)   If (Offs > UBound(InData)) Then Exit Function   If BlWidth < 2 Or BlHeight < 2 Then       ' just copy data here       CopyMemory OutData(Offs), InData(OffsOut), BlWidth * BlHeight       OffsOut = OffsOut + BlWidth * BlHeight   ElseIf BlWidth = 2 And BlHeight = 2 Then       ' swizzle block       OutData(OffsOut) = InData(Offs)       OutData(OffsOut + 1) = InData(Offs + 1)       OutData(OffsOut + 2) = InData(Offs + Stride)       OutData(OffsOut + 3) = InData(Offs + Stride + 1)       OffsOut = OffsOut + 4   Else       ' break into 4 blocks and reprocess       SwizBlock OutData, InData, OffsOut, Offs, BlWidth / 2, BlHeight / 2, Stride       SwizBlock OutData, InData, OffsOut, Offs + (BlWidth / 2), BlWidth / 2, BlHeight / 2, Stride       SwizBlock OutData, InData, OffsOut, Offs + (Stride * (BlHeight / 2)), BlWidth / 2, BlHeight / 2, Stride       SwizBlock OutData, InData, OffsOut, Offs + (Stride * (BlHeight / 2)) + (BlWidth / 2), BlWidth / 2, BlHeight / 2, Stride   End IfEnd FunctionPublic Function Swizzle(InTex As CTpkTexture, Data() As Byte) As Byte()   Dim bytData() As Byte, bytDataOut() As Byte   Dim lOffs As Long, i As Long, Width As Long, Height As Long   Dim MinMax As Long, MipLevels As Long, DataLen As Long   MinMax = IIf(InTex.TexHeight > InTex.TexWidth, InTex.TexHeight, InTex.TexWidth)   MipLevels = Log(MinMax) / Log(2) + 1      lOffs = 0   bytData = Data   ReDim bytDataOut(UBound(bytData))      Width = InTex.TexWidth   Height = InTex.TexHeight      For i = 1 To MipLevels       SwizBlock bytDataOut, bytData, lOffs, lOffs, Width, Height, Width       Width = Width / 2       Height = Height / 2       If lOffs > UBound(bytData) Then Exit For   Next      Swizzle = bytDataOut   End FunctionPrivate Function UnswizBlock(ByRef InData() As Byte, ByRef OutData() As Byte, ByRef Offs As Long, ByVal OffsOut As Long, ByVal BlWidth As Long, ByVal BlHeight As Long, ByVal Stride As Long)   If (Offs > UBound(InData)) Then Exit Function   If BlWidth < 2 Or BlHeight < 2 Then       ' just copy data here       CopyMemory OutData(OffsOut), InData(Offs), BlWidth * BlHeight       OffsOut = OffsOut + BlWidth * BlHeight   ElseIf BlWidth = 2 And BlHeight = 2 Then       ' unswizzle block       OutData(OffsOut) = InData(Offs)       OutData(OffsOut + 1) = InData(Offs + 1)       OutData(OffsOut + Stride) = InData(Offs + 2)       OutData(OffsOut + Stride + 1) = InData(Offs + 3)       Offs = Offs + 4   Else       ' break into 4 blocks and reprocess       UnswizBlock InData, OutData, Offs, OffsOut, BlWidth / 2, BlHeight / 2, Stride       UnswizBlock InData, OutData, Offs, OffsOut + (BlWidth / 2), BlWidth / 2, BlHeight / 2, Stride       UnswizBlock InData, OutData, Offs, OffsOut + (Stride * (BlHeight / 2)), BlWidth / 2, BlHeight / 2, Stride       UnswizBlock InData, OutData, Offs, OffsOut + (Stride * (BlHeight / 2)) + (BlWidth / 2), BlWidth / 2, BlHeight / 2, Stride   End IfEnd FunctionPublic Function Unswizzle(InTex As CTpkTexture) As Byte()   Dim bytData() As Byte, bytDataOut() As Byte   Dim lOffs As Long, i As Long, Width As Long, Height As Long   Dim MinMax As Long, MipLevels As Long   MinMax = IIf(InTex.TexHeight > InTex.TexWidth, InTex.TexHeight, InTex.TexWidth)   MipLevels = Log(MinMax) / Log(2) + 1      lOffs = 0   bytData = InTex.GetData(True)   ReDim bytDataOut(UBound(bytData))      Width = InTex.TexWidth   Height = InTex.TexHeight      For i = 1 To MipLevels       UnswizBlock bytData, bytDataOut, lOffs, lOffs, Width, Height, Width       Width = Width / 2       Height = Height / 2       If lOffs > UBound(bytData) Then Exit For   Next      Unswizzle = bytDataOutEnd Function

 

Share this post


Link to post
Share on other sites
JernejL

Can you please try to explain how the swizzling works, because that vb code looks to me like a bunch of swear words wow.gif

 

Share this post


Link to post
Share on other sites
aru

 

Can you please try to explain how the swizzling works, because that vb code looks to me like a bunch of swear words wow.gif

lol okay, umm lets see.

 

In simple words, swizzling means to store the data in a form such that the tU and tV coordinates' addressing indices are interleaved.

 

To explain that VB code, first the Swizzle() function:

 

Calculate # of MipMaps:

 

  MinMax = IIf(InTex.TexHeight > InTex.TexWidth, InTex.TexHeight, InTex.TexWidth)  MipLevels = Log(MinMax) / Log(2) + 1

 

 

For each mipmap level, call SwizBlock() and then half the width and height (since the next mipmap level should be half the size of the previous one). If you know exactly know many mipmaps you have and are sure you have enough data, you may remove the "Exit For" line since that just breaks out of the loop incase we overflow the # of mipmaps.

 

  For i = 1 To MipLevels      SwizBlock bytDataOut, bytData, lOffs, lOffs, Width, Height, Width      Width = Width / 2      Height = Height / 2      If lOffs > UBound(bytData) Then Exit For  Next

 

 

Now in SwizBlock, this is just a don't process if we don't have enough data:

 

   If (Offs > UBound(InData)) Then Exit Function

 

 

If the Block Width is less than 2 or the Block Height is less than 2, i.e. we have a 2x1 block, 1x2 block or a 4x1 block, etc, we just copy the pixels. There might be a bug here.. I'm not sure... and I have no idea why I used CopyMemory/RtlMoveMemory.. seems like a waste of an API call.

 

  If BlWidth < 2 Or BlHeight < 2 Then      ' just copy data here      CopyMemory OutData(Offs), InData(OffsOut), BlWidth * BlHeight      OffsOut = OffsOut + BlWidth * BlHeight

 

 

If it is exactly a 2x2 block, then we perform the swizzle. This pretty much takes a 2x2 block of data and converts it to a 4x1 block. The Stride tells the length of one line of pixel data (this is not the block width!):

 

   ElseIf BlWidth = 2 And BlHeight = 2 Then      ' swizzle block      OutData(OffsOut) = InData(Offs)      OutData(OffsOut + 1) = InData(Offs + 1)      OutData(OffsOut + 2) = InData(Offs + Stride)      OutData(OffsOut + 3) = InData(Offs + Stride + 1)      OffsOut = OffsOut + 4

 

 

Otherwise, we need to break up the block into 4 equally sized smaller blocks and perform SwizBlock on them again. The first SwizBlock does the upper-left corner, the second one does the upper-right corner, etc. This is probabbly the most confusing part... draw out the pixels on a peice of paper and figure out the algorithm tounge.gif

 

   Else      ' break into 4 blocks and reprocess      SwizBlock OutData, InData, OffsOut, Offs, BlWidth / 2, BlHeight / 2, Stride      SwizBlock OutData, InData, OffsOut, Offs + (BlWidth / 2), BlWidth / 2, BlHeight / 2, Stride      SwizBlock OutData, InData, OffsOut, Offs + (Stride * (BlHeight / 2)), BlWidth / 2, BlHeight / 2, Stride      SwizBlock OutData, InData, OffsOut, Offs + (Stride * (BlHeight / 2)) + (BlWidth / 2), BlWidth / 2, BlHeight / 2, Stride  End If

 

 

If you notice.. SwizBlock is a recursive function with a O(log2(min(width,height)))... so it's not so bad and won't overflow the call stack. I believe I have only tested this with equal Width/Height sized textures. Not sure how well it works with different sized ones.

 

Unswizzle is similar to the process above.

Edited by aru

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.