Page 2 of 5

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Tue Feb 02, 2016 7:35 pm
by Wobble
[out]

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Tue Feb 02, 2016 10:37 pm
by Acewell
That was a valiant effort Wobble, thanks! :gulp:
maybe MrAdults could step in and offer some advice on this or a quick solution.

edit
should there be anything in the code about Endianess?
The fmt_star_wars_kinect_tga.py plugin for Kinect Star Wars textures might hold the key

viewtopic.php?f=16&t=8714

Code: Select all

...
	#DXT1
	if imgFmt == 0x28:
		data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), imgWidth, imgHeight, 8)
		texFmt = noesis.NOESISTEX_DXT1
	#DXT5
	elif imgFmt == 0x33:
		data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), imgWidth, imgHeight, 16)
		texFmt = noesis.NOESISTEX_DXT5
	#DXT5 packed normal map
	elif imgFmt == 0x1C:
		data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), imgWidth, imgHeight, 16)
		data = rapi.imageDecodeDXT(data, imgWidth, imgHeight, noesis.FOURCC_ATI2)
		texFmt = noesis.NOESISTEX_RGBA32
	#DXT5 packed normal map2
	elif imgFmt == 0x36:
		data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), imgWidth, imgHeight, 16)
		data = rapi.imageDecodeDXT(data, imgWidth, imgHeight, noesis.FOURCC_ATI1)
		texFmt = noesis.NOESISTEX_RGBA32
	#DXT1 packed normal map
	elif imgFmt == 0x16:
		data = rapi.imageUntile360DXT(rapi.swapEndianArray(data, 2), imgWidth, imgHeight, 8)
		data = rapi.imageDecodeDXT(data, imgWidth, imgHeight, noesis.FOURCC_DXT1NORMAL)
		texFmt = noesis.NOESISTEX_RGBA32
	#raw
	elif imgFmt == 0x1B:
		data = rapi.imageUntile360Raw(rapi.swapEndianArray(data, 4), imgWidth, imgHeight, 4)
		texFmt = noesis.NOESISTEX_RGBA32
	#unknown, not handled
...

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Wed Feb 03, 2016 3:31 am
by Wobble
[out]

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Wed Feb 03, 2016 4:08 am
by JakeGreen
Wobble wrote:Woohoo, you got it!
62e82b02_solo_face_1024.JPG
The data needs to be endian swapped before passing it to unswizzle functions.

But, it's not perfect. The pixels are still very jagged. I don't know if this is how the original texture is supposed to look like on the XBox 360,
or if the unswizzle function is not unswizzling the entire image.
It seems like maybe it's pixelated like that cause the head is maybe 512x512 and not 1024x1024.

But great job this is really amazing now we just need a proper importer for noesis for the models.

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Wed Feb 03, 2016 9:19 am
by Wobble
[out]

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Wed Feb 03, 2016 4:48 pm
by Wobble
[out]

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Wed Feb 03, 2016 7:29 pm
by Wobble
[out]

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Wed Feb 03, 2016 10:02 pm
by JakeGreen
Wobble wrote:Last one:
- Added filename argument scanning for zero headers. Arguments must be separated by spaces.
x2t_image.zip

Code: Select all

<filename> <width> <height> <bpp> <format>.x2t
This is really amazing it's just sad they didn't extract with the proper file names cause going down through noesis to find textures you want is pretty hard since there are so many.

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Wed Feb 03, 2016 10:37 pm
by Acewell
The textures were extracted with the names that were stored in the str file, and these same names are referenced in the rax files, the names are correct for this build.

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Wed Feb 03, 2016 11:08 pm
by JakeGreen
AceWell wrote:The textures were extracted with the names that were stored in the str file, and these same names are referenced in the rax files, the names are correct for this build.
Ah okay,

Well i found something that isn't right compared to one of the textures i already had to one i just exported.

The one i have here is 2048x2048 and the one i converted is 1024x1024.

Now i know the plugin isn't fully finished but i thought i'd point this out to help you fix it.

Pre-alpha 1024x1024
Image

Final 2048x2048
Image

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Thu Feb 04, 2016 3:20 am
by Wobble
[out]

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Fri Feb 05, 2016 7:17 am
by Acewell
I was just comparing the Kinect Star Wars tga python script with your x2t_image.cpp and was wondering if image_bpp/8 should be image_bpp/4 instead for untile raw

Code: Select all

 // Uncompressed

 if(image_format == 3) {

    //                                   BYTE *dst,    BYTE *src, int dstSize,   int imgW,     int imgH, int bytesPerPix
    rapi->Noesis_UntileImageRAW( unswizzled_buffer, image_buffer, image_size, image_width, image_height, (image_bpp/8) );
 }

fmt_star_wars_kinect_tga.py

Code: Select all

#raw
	elif imgFmt == 0x1B:
		data = rapi.imageUntile360Raw(rapi.swapEndianArray(data, 4), imgWidth, imgHeight, 4)
		texFmt = noesis.NOESISTEX_RGBA32

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Sat Feb 06, 2016 4:22 am
by Wobble
[out]

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Sat Feb 06, 2016 4:43 am
by Wobble
[out]

Re: [X360] Star Wars Battlefront III pre-alpha (*.x2t)

Posted: Sun Feb 07, 2016 1:18 am
by Acewell
this is what MrAdults says here viewtopic.php?p=115576#p115576
There are lots of image processing scripts of this nature to use as examples over on the old Google Code depot.
The Gamebryo NIF script shows how to do all kinds of untiling including 360-style and straight up Morton order. Use rapi.swapEndianArray to quickly endian-swap DXT blocks as commonly needed on the 360, this is demonstrated in the BulletWitch script in cprLoadTexture.
Wobble wrote:The problem is with the imageUntile360Raw() function. It doesn't seem work for these textures.
Can't do nothing about it, because we don't know how it works. It is based on Morton order or something else?
maybe it does have something to do with Morton order. :scaredy:

this is a snip from the fmt_gamebryo_nif.py script that i think MrAdults was talking about, morton untile is near the end

Code: Select all

#run through and convert texture data
		pixObject = nif.objects[texObject.pixLinkID]
		noeFmt = noesis.NOESISTEX_UNKNOWN
		pixelFormatObj = noeSafeGet(pixObject, "pixelFormat")
		if pixelFormatObj is None:
			print("WARNING: Object", texObject.pixLinkID, "type", pixObject.typeName, "should have contained a pixel format, but didn't.")
			continue
		pixelFormat = pixelFormatObj.format
		imageData = pixObject.imageData
		
		pixelImageInfo = [pixObject.numFaces, pixObject.mipLevels, pixObject.mipsTotalSize, pixObject.mipInfo]
		
		if pixelFormat == NIFTEX_RGB:
			noeFmt = noesis.NOESISTEX_RGBA32
			imageData = noeProcessImage(imageData, pixelImageInfo, rapi.imageDecodeRaw, "r8g8b8")
		elif pixelFormat == NIFTEX_RGBA:
			noeFmt = noesis.NOESISTEX_RGBA32
			if pixObject.platform == NIF_PLATFORM_PS3: #alpha first on ps3 (or so we not always correctly assume)
				imageData = noeProcessImage(imageData, pixelImageInfo, rapi.imageDecodeRaw, "a8r8g8b8")
			elif pixObject.platform == NIF_PLATFORM_XBOX360: #another potentially-faulty assumption - bgra for 360
				imageData = noeProcessImage(imageData, pixelImageInfo, rapi.imageDecodeRaw, "b8g8r8a8")
		elif pixelFormat == NIFTEX_DXT1:
			noeFmt = noesis.NOESISTEX_DXT1
		elif pixelFormat == NIFTEX_DXT3:
			noeFmt = noesis.NOESISTEX_DXT3
		elif pixelFormat == NIFTEX_DXT5:
			noeFmt = noesis.NOESISTEX_DXT5
		elif pixelFormat == NIFTEX_MONO:
			#expand out to rgba32
			noeFmt = noesis.NOESISTEX_RGBA32
			imageData = noeProcessImage(imageData, pixelImageInfo, rapi.imageDecodeRaw, "r8")
			imageData = noeProcessImage(imageData, pixelImageInfo, rapi.imageKernelProcess, 4, nifImageExpandMonoColorKernel)
		else:
			print("WARNING: Unsupported texture format", pixelFormat)

		if noeFmt != noesis.NOESISTEX_UNKNOWN:
			if pixelFormatObj.tiling != 0:
				#lots of games seem to have bad mip offsets when using tiling/swizzling modes,
				#which don't take into account necessary platform-specific padding. so, sadly,
				#we'll have to skip the mips.
				pixelImageInfo[1] = 1
			
			if pixelFormatObj.tiling == 1:
				#360 untile
				if noeFmt == noesis.NOESISTEX_RGBA32:
					imageData = noeProcessImage(imageData, pixelImageInfo, rapi.imageUntile360Raw, 4)
				else: #dxt
					imageData = noeProcessImage(imageData, pixelImageInfo, rapi.imageUntile360DXT, 8 if noeFmt == noesis.NOESISTEX_DXT1 else 16)
			elif pixelFormatObj.tiling == 3:
				#morton untile
				if noeFmt == noesis.NOESISTEX_RGBA32:
					imageData = noeProcessImage(imageData, pixelImageInfo, rapi.imageFromMortonOrder, 4, 2 if pixObject.platform == NIF_PLATFORM_VITA else 0)
				else: #dxt
					dxtBlockBytes = 4 if noeFmt == noesis.NOESISTEX_DXT1 else 8
					imageData = rapi.imageFromMortonOrder(imageData, pixObject.width>>1, pixObject.height>>2, dxtBlockBytes)
					#possible todo - support untiling dxt blocks with multiple mips/faces
					pixelImageInfo[0] = 1
					pixelImageInfo[1] = 1