Page 1 of 1

How to edit .TEX files from 50 Cent Bulletproof PS2

Posted: Sat Jan 20, 2018 2:58 am
by TjVatio
So, basically i want to convert this format to any image to modify and re convert to .TEX

tried some tools around the web and only texture finder give me some result.

TextureFinder preview.
Image

TEX file samples
http://www.mediafire.com/file/cb86158u7 ... GAL_EN.TEX
http://www.mediafire.com/file/nro1nafpt ... GRBRDR.TEX
http://www.mediafire.com/file/q6lbrgofajblh4f/FAIL.TEX

Thankies!! :] :]

Re: How to edit .TEX files from 50 Cent Bulletproof PS2

Posted: Sat Jan 20, 2018 6:18 am
by Acewell
LEGAL_EN.png
all 3 samples use the same settings
i've never done a Noesis python script for ps2 images but i may give it a try later. :D

Re: How to edit .TEX files from 50 Cent Bulletproof PS2

Posted: Sat Jan 20, 2018 7:14 pm
by TjVatio
AceWell wrote:
LEGAL_EN.png
all 3 samples use the same settings
i've never done a Noesis python script for ps2 images but i may give it a try later. :D
OMG!!! thank you so much, that program works like a charm :D, actually ive downloaded noesis and loaded some scripts from forum but none of them working in this .TEX, maybe was only for a specific game that already posted :P

edit: i got lost to convert back my edited image to .TEX, i have to use the same program?

once again thank you for helping me!!!

Re: How to edit .TEX files from 50 Cent Bulletproof PS2

Posted: Sun Jan 21, 2018 2:49 am
by Acewell
TjVatio wrote:so, i got lost to convert back my edited image to .TEX, i have to use the same program?
no, you have to break it back down to paletted data and retwiddle to rebuild it, i can't help with this.
i tried making a Noesis python script to open the TEX files but i can't get the result like the one in "Console Texture Explorer". :(

Re: How to edit .TEX files from 50 Cent Bulletproof PS2

Posted: Sun Jan 21, 2018 7:48 pm
by episoder
AceWell wrote:
TjVatio wrote:so, i got lost to convert back my edited image to .TEX, i have to use the same program?
no, you have to break it back down to paletted data and retwiddle to rebuild it, i can't help with this.
i tried making a Noesis python script to open the TEX files but i can't get the result like the one in "Console Texture Explorer". :(
i don't like sad pals. you forgot something. ;) i borrowed some code from there and unshuffled this bitch, ps2 style. :] you gotta do the pointer dance. :D

Code: Select all

from inc_noesis import *
import noesis
import rapi

def registerNoesisTypes():
	handle = noesis.register("50cent Bulletproof TEX Textures", ".tex")
	noesis.setHandlerTypeCheck(handle, TEXCheckType)
	noesis.setHandlerLoadRGBA(handle, TEXLoadRGBA)
	#noesis.logPopup()
	return 1

def TEXCheckType(data):
	return 1

def TEXLoadRGBA(data, texList):
	bs = NoeBitStream(data)
	filename = bs.read("32B")
	hash = bs.readInt()
	width = bs.readUShort()
	height = bs.readUShort()
	#dummy1 = bs.readUByte()
	size_bmapdata = width * height #bs.readUInt()
	#print(str(size_bmapdata))
	#dummy2 = bs.readUByte()
	#ofs_palette = bs.readUInt()
	bs.seek(0x40, NOESEEK_ABS)
	texData = bs.readBytes(size_bmapdata)
	#bs.seek(ofs_palette + 0x40, NOESEEK_ABS)
	palData = []
	for x in range(8):
		for p in range(32):
			read = bs.readUByte()
			palData.append(read)
		bs.seek(32, NOESEEK_REL)
		for p in range(32):
			read = bs.readUByte()
			palData.append(read)
		bs.seek(-64, NOESEEK_REL)
		for p in range(32):
			read = bs.readUByte()
			palData.append(read)
		bs.seek(32, NOESEEK_REL)
		for p in range(32):
			read = bs.readUByte()
			palData.append(read)

	palData = bytearray(palData)
	pic = rapi.imageUntwiddlePS2(texData, width, height, 8)
	pic = rapi.imageDecodeRawPal(pic, palData, width, height, 8, "r8g8b8a8")
	texList.append(NoeTexture(str(filename), width, height, pic, noesis.NOESISTEX_RGBA32))

	return 1
butchered and commented out are data pointer safeguards. assuming the layout is always aligning the image followed by the pallette without padding.

reversing is not possible like that. you'd need to explicit export a indexed bitmap with a palette. tga does that. and you gotta reshuffle the palette the same way. the twiddlePS2 should work as it is tho.

Re: How to edit .TEX files from 50 Cent Bulletproof PS2

Posted: Mon Jan 22, 2018 5:31 am
by Acewell
episoder wrote: and unshuffled this bitch, ps2 style. :] you gotta do the pointer dance.
ah yes that works great! thanks :D
it seems i didn't do that palette unshuffle thing and was getting some pixelated areas,
is that a standard procedure in parsing PS2 textures? :)

Re: How to edit .TEX files from 50 Cent Bulletproof PS2

Posted: Mon Jan 22, 2018 6:02 am
by episoder
AceWell wrote:
episoder wrote: and unshuffled this bitch, ps2 style. :] you gotta do the pointer dance.
ah yes that works great! thanks :D
it seems i didn't do that palette unshuffle thing and was getting some pixelated areas,
is that a standard procedure in parsing PS2 textures? :)
i assume yes. and it's only on 8-bit textures. the texture finder seems to always do it. those i scripted, needed it. gits, resident evil dead aim, onimusha3. all of them shuffled. i could check dmc too, but this got more block size fuckery in some of it's files. later maybe. :)

Re: How to edit .TEX files from 50 Cent Bulletproof PS2

Posted: Tue Jan 23, 2018 5:28 am
by TjVatio
episoder wrote:
AceWell wrote:
episoder wrote: and unshuffled this bitch, ps2 style. :] you gotta do the pointer dance.
ah yes that works great! thanks :D
it seems i didn't do that palette unshuffle thing and was getting some pixelated areas,
is that a standard procedure in parsing PS2 textures? :)
i assume yes. and it's only on 8-bit textures. the texture finder seems to always do it. those i scripted, needed it. gits, resident evil dead aim, onimusha3. all of them shuffled. i could check dmc too, but this got more block size fuckery in some of it's files. later maybe. :)
Wow!!! you guys rock!!!! 8) 8) now noesis work fine loading this .TEX file
also when i export from preview and i choose tga or png, it save with transparency by default, there's a way to change this?

and with ConsoleTextureExplorer i followed your advices AceWell and the only way that program import the edited texture succesfully into the .TEX, is doing with .TM2 format image, this gives an almost none support, the only Proprietary software that let me save it in that format is one calling OPTPiX iMageStudio. :shame:

Edit: digging more, i found one program calls Rainbow that support saving .tm2 and does the trick :] the against on this. is too much work around to get this working, AceWell will you plain to do some changes in noesis to fully support this? saving maybe into tm2? or back to .TEX? im being too much greedy? :D :D

many many thanks @AceWell and @episoder!!!!!