Gildor's Forums

Author Topic: Splinter Cell Chaos Theory - StaticMesh  (Read 500 times)
VendorX
Jr. Member
**
Posts: 60



View Profile
Splinter Cell Chaos Theory - StaticMesh
« on: July 18, 2023, 21:48 »

I manage to RE static mesh format, but still have problem with UVs.

UStaticMesh serialization starts with:

LegacyVertexBuffer
LegacyIndexBuffer
LegacyWireframeIndexBuffer

Sections
BoundingBox
etc.

Only place it could be is LegacyVertexBuffer, because after FVector Position there is 16 bite of data I'm not sure what to do with it.
Normally, it should be Normal (4 byte), UVs (2*4 byte) and Color (4 byte), but none of the known algorithm doesn't work.

Q: Any idea on this topic?
Logged
spiritovod
Global Moderator
Hero Member
*****
Posts: 1852


View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #1 on: July 19, 2023, 01:08 »

UVs can be packed to half floats (2*2 bytes), in umodel it's FMeshUVHalf. If that 16bit data is an array of appropriate size, this may be it.
Logged
VendorX
Jr. Member
**
Posts: 60



View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #2 on: July 19, 2023, 22:33 »

All of the known algorithm doesn't work - including half floats.

Gildor?
Logged
spiritovod
Global Moderator
Hero Member
*****
Posts: 1852


View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #3 on: July 20, 2023, 00:02 »

@VendorX: I'm not sure what do you expect from this topic, since you didn't provide any samples, data layout and such, while the game is using highly customized map packages with embedded meshes. Like, someone will do the same reversing you did on raw data (because parsing something like this in umodel is hardly possible) or magically guess the answer or something? Considering that the format was not reversed, at least for public, for decades and Gildor dropped it because of overall package complexity back then (which was also years ago), it's not hard to guess that there is no simple solution, especially without explanations and samples. 
Logged
VendorX
Jr. Member
**
Posts: 60



View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #4 on: July 20, 2023, 04:27 »

Umodel has support for Skel and anim so is obvious that Gildor did some research on SM also.
But if you want some sample, here you go - it's a model of cube embedded in Editor.u

Code:

TexPropCube
    00 00 FF 7F 7F FF 80 00 00 7F 80 00 80 80 80 00
    FF 7F FF 7F 7F FF 80 00 00 80 80 00 80 80 80 00
    FF 7F 00 00 7F FF 80 00 00 7F 80 00 80 80 80 00
    00 00 00 00 80 80 FF 00 80 00 7F 00 80 80 80 00
    01 00 FF 7F 80 7F FF 00 80 00 7F 00 80 80 80 00
    FF 7F FF 7F 80 80 FF 00 80 00 7F 00 80 80 80 00
    00 00 FF 7F 80 7F 00 00 80 00 80 00 80 80 80 00
    FF 7F FF 7F 80 7F 00 00 80 00 7F 00 80 80 80 00
    FF 7F 00 00 80 7F 00 00 80 00 80 00 80 80 80 00
    01 00 01 00 80 80 00 00 80 00 80 00 80 80 80 00
    00 00 FF 7F 7F 80 00 00 00 80 80 00 80 80 80 00
    FF 7F FF 7F 7F 80 00 00 00 80 7F 00 80 80 80 00
    FF 7F 00 00 7F 80 00 00 00 80 80 00 80 80 80 00
    01 00 01 00 80 80 00 00 00 80 80 00 80 80 80 00
    FF 7F 01 00 80 80 FF 00 80 00 80 00 80 80 80 00
    01 00 01 00 80 FF 80 00 00 7F 80 00 80 80 80 00
    00 00 FF 7F 7F 80 FF 00 00 80 7F 00 80 80 80 00
    FF 7F FF 7F 7F 80 FF 00 00 80 80 00 80 80 80 00
    FF 7F 00 00 7F 80 FF 00 00 80 7F 00 80 80 80 00
    01 00 01 00 80 80 FF 00 00 80 7F 00 80 80 80 00
    00 00 FF 7F 7F 00 80 00 00 80 80 00 80 80 80 00
    FF 7F FF 7F 7F 00 80 00 00 7F 80 00 80 80 80 00
    FF 7F 00 00 7F 00 80 00 00 80 80 00 80 80 80 00
    01 00 01 00 80 00 80 00 00 80 80 00 80 80 80 00

or:
Code:
TexPropCube
    0        32767     -129      128    32512     128    -32640    128
    32767    32767     -129      128    -32768    128    -32640    128
    32767    0         -129      128    32512     128    -32640    128
    0        0         -32640    255    128       127    -32640    128
    1        32767     32640     255    128       127    -32640    128
    32767    32767     -32640    255    128       127    -32640    128
    0        32767     32640     0      128       128    -32640    128
    32767    32767     32640     0      128       127    -32640    128
    32767    0         32640     0      128       128    -32640    128
    1        1        -32640     0      128       128    -32640    128
    0        32767    -32641     0      -32768    128    -32640    128
    32767    32767    -32641     0      -32768    127    -32640    128
    32767    0        -32641     0      -32768    128    -32640    128
    1        1        -32640     0      -32768    128    -32640    128
    32767    1        -32640     255    128       128    -32640    128
    1        1        -128       128    32512     128    -32640    128
    0        32767    -32641     255    -32768    127    -32640    128
    32767    32767    -32641     255    -32768    128    -32640    128
    32767    0        -32641     255    -32768    127    -32640    128
    1        1        -32640     255    -32768    127    -32640    128
    0        32767    127        128    -32768    128    -32640    128
    32767    32767    127        128    32512     128    -32640    128
    32767    0        127        128    -32768    128    -32640    128
    1        1        128        128    -32768    128    -32640    128

... or there is the file

* Editor.u (169.34 KB - downloaded 17 times.)
« Last Edit: July 20, 2023, 05:11 by VendorX » Logged
spiritovod
Global Moderator
Hero Member
*****
Posts: 1852


View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #5 on: July 20, 2023, 11:00 »

@VendorX: According to existing topics and compatibility table, nothing is supported for Chaos Theory, and I also failed to load anything from steam version with an existing overrides.
https://www.gildor.org/smf/index.php/topic,539.0.html
https://www.gildor.org/smf/index.php/topic,6553.0.html

As for the data, it looks like combination of FVector (12 bytes, apparently positions), one UV as signed shorts (4 bytes total) and three packed vectors, probably for normal ( 3 * 4 = 12 bytes total). At least such layout would make some sense in actual data. You can take a look at FPacked structs in umodel, also in third-party apps like Advanced Mesh Reaper it looks more or less legit.


* Clipboard01.jpg (230.47 KB, 1772x1002 - viewed 41 times.)
« Last Edit: July 20, 2023, 20:48 by spiritovod » Logged
VendorX
Jr. Member
**
Posts: 60



View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #6 on: July 20, 2023, 17:19 »

I choose Editor.u because TexPropCube and TexPropSphere are exactly the same across all UE2 versions - indexing could be different, but position and UVs are the same.

Below are correct values for each triangle.
Code:
           Vertex 0 128.000000 -128.000000 -128.000000 0.999500 0.999500
            Vertex 1 128.000000 128.000000 -128.000000 0.999500 0.000500
            Vertex 2 -128.000000 128.000000 -128.000000 0.000500 0.000500

            Vertex 0 -128.000000 128.000000 -128.000000 0.000500 0.000500
            Vertex 1 -128.000000 -128.000000 -128.000000 0.000500 0.999500
            Vertex 2 128.000000 -128.000000 -128.000000 0.999500 0.999500

            Vertex 0 128.000000 -128.000000 128.000000 0.000500 0.999500
            Vertex 1 -128.000000 -128.000000 128.000000 0.999500 0.999500
            Vertex 2 -128.000000 128.000000 128.000000 0.999500 0.000500

            Vertex 0 -128.000000 128.000000 128.000000 0.999500 0.000500
            Vertex 1 128.000000 128.000000 128.000000 0.000500 0.000500
            Vertex 2 128.000000 -128.000000 128.000000 0.000500 0.999500

            Vertex 0 128.000000 -128.000000 -128.000000 0.000500 0.999500
            Vertex 1 -128.000000 -128.000000 -128.000000 0.999500 0.999500
            Vertex 2 -128.000000 -128.000000 128.000000 0.999500 0.000500

            Vertex 0 -128.000000 -128.000000 128.000000 0.999500 0.000500
            Vertex 1 128.000000 -128.000000 128.000000 0.000500 0.000500
            Vertex 2 128.000000 -128.000000 -128.000000 0.000500 0.999500

            Vertex 0 -128.000000 -128.000000 -128.000000 0.000500 0.999500
            Vertex 1 -128.000000 128.000000 -128.000000 0.999500 0.999500
            Vertex 2 -128.000000 128.000000 128.000000 0.999500 0.000500

            Vertex 0 -128.000000 128.000000 128.000000 0.999500 0.000500
            Vertex 1 -128.000000 -128.000000 128.000000 0.000500 0.000500
            Vertex 2 -128.000000 -128.000000 -128.000000 0.000500 0.999500

            Vertex 0 -128.000000 128.000000 -128.000000 0.000500 0.999500
            Vertex 1 128.000000 128.000000 -128.000000 0.999500 0.999500
            Vertex 2 128.000000 128.000000 128.000000 0.999500 0.000500

            Vertex 0 128.000000 128.000000 128.000000 0.999500 0.000500
            Vertex 1 -128.000000 128.000000 128.000000 0.000500 0.000500
            Vertex 2 -128.000000 128.000000 -128.000000 0.000500 0.999500

            Vertex 0 128.000000 128.000000 -128.000000 0.000500 0.999500
            Vertex 1 128.000000 -128.000000 -128.000000 0.999500 0.999500
            Vertex 2 128.000000 -128.000000 128.000000 0.999500 0.000500

            Vertex 0 128.000000 -128.000000 128.000000 0.999500 0.000500
            Vertex 1 128.000000 128.000000 128.000000 0.000500 0.000500
            Vertex 2 128.000000 128.000000 -128.000000 0.000500 0.999500
So as you see, it's not a 'guess work' if it comes to the correct values, but still I cannot make it work.

BTW: SkeletalMesh I can export without errors, but MeshAnimation uses probably the same algorithm for each bone Position and Orientation. I can provide its format ...
« Last Edit: July 20, 2023, 17:47 by VendorX » Logged
spiritovod
Global Moderator
Hero Member
*****
Posts: 1852


View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #7 on: July 20, 2023, 22:37 »

@VendorX: Oh, so those are positions. I've edited my post above, it should be valid for overall layout - for example, first string (Vertex 0) from your example is entry at 0x0282CF or 0x02835B offset (they have different normals but positions and UV are the same). If you concerned about values, in your first sample you're using direct casting (0x7FFF short -> 32767 float) while if properly converted from signed short, it would be 0.9999 float, which is also visible at the screenshot.

Though I can't help much beyond that point, as some things are hardly reversible from data itself, for example if some values are stored in rare packed formats or using bounds/ranges/etc for scaling packed values to expected ones, or if some old engine specifics are used.
Logged
VendorX
Jr. Member
**
Posts: 60



View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #8 on: July 20, 2023, 23:35 »

... Oh, so those are positions

Position is OK so it wasn't include in the Hex dump.
It goes like:
12 byte for Position followed by 16 byte in question

half2float implementation doesn't work - Thank you anyway.
« Last Edit: July 20, 2023, 23:50 by VendorX » Logged
spiritovod
Global Moderator
Hero Member
*****
Posts: 1852


View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #9 on: July 21, 2023, 01:23 »

@VendorX: half2float is for unsigned short, for signed short it's different and depends on particular usage. For example, you can use "value / 32767.0f", but it's hard to tell if it will work for all values properly.
« Last Edit: July 21, 2023, 01:25 by spiritovod » Logged
VendorX
Jr. Member
**
Posts: 60



View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #10 on: July 21, 2023, 03:55 »

Yeah I know ... there is quite few different algorithms used in UE - tried everything, include signed and unsigned. It seams, the used something entirely different. That's why I hopped that Gildor / someone manage to reverse this algorithm - I couldn't find it.
Ask him if you can.
Logged
VendorX
Jr. Member
**
Posts: 60



View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #11 on: July 23, 2023, 10:07 »

This:
ushort * (1 / 32768.0f)

... is closest solution so far - it works for TexPropCube but not for TexPropSphere.
As you can see on the photo:

- upper right part is OK - except image scaling (should be twice as much)
- upper left V need scaling, but U is messed up
- lower right U need scaling, but V is messed up
- lower left both U and V is messed up

Any idea ..?


* Untitled.jpg (13.84 KB, 364x351 - viewed 22 times.)
Logged
spiritovod
Global Moderator
Hero Member
*****
Posts: 1852


View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #12 on: July 23, 2023, 12:20 »

@VendorX: You really shouldn't do things like this, because they're causing undefined behavior and if you got some valid results from them, it's just coincidence. I'll try to explain the idea for simplified case when no complex calculations are used:

For the cube you have only 0 and 1 values for UV (rounding aside). And in actual data it's 0 and 0x7FFF.  0x7FFF = 32767 and it's maximum positive value for signed short, which means we have this type here. While for UV maximum positive value should be 1. That means we should convert 0x7FFF -> 1.0f somehow, and dividing by 32767.0f works (not only for this value, but for all positive signed shorts). Such approach is actually used in some modern games for compressing positions, but you're getting deformed results because of reduced precision and stripped scaling and correct geometry is restored by scaling and in some cases by additional aligning to bounds.

In comparison, for normals such conversion is more complex because you need to consider vector's orientation and normalization  - that's why approaches from FPacked structs are not good for direct usage, since they're aimed for vectors. Moreover, in some modern games there are negative UV values, because UV layer is a tiled image there, like unwrapped from cube sides, with size of (0,2 / -1,1). I have no idea about UE5 UVs, for virtual textures it can be like x*y tiled image. By tile I mean usual single UV layer of (0,1 / 0,1) size. But all this is most likely not related to such old game.    

It's just a guess, but maybe you're trying to interpret packed vectors (for normal) as UVs as well? In my original post I made false assumption of 2 UV per vertex, while it's only one and the rest is apparently normal. I've already edited it to avoid confusion in case of someone else will read the topic.
« Last Edit: July 23, 2023, 12:22 by spiritovod » Logged
VendorX
Jr. Member
**
Posts: 60



View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #13 on: July 23, 2023, 17:49 »

@VendorX: You really shouldn't do things like this, because they're causing undefined behavior and if you got some valid results from them, it's just coincidence...

Funny ... It's not like I'm sticking to the first 4 bits - I've tried every known algorithm on each of those 16 bits. Moreover, first 4/6 bits cannot be Normal.

I guess back to IDA - just to bad, Gildor decide to not participate in this discussion.
Thank you anyway.
« Last Edit: July 23, 2023, 20:59 by VendorX » Logged
Joshhhuaaa
Newbie
*
Posts: 20


View Profile
Re: Splinter Cell Chaos Theory - StaticMesh
« Reply #14 on: September 13, 2023, 07:41 »

Sorry to go off topic a little, but has anyone been available to export the StaticMeshes for the original Splinter Cell? The latest versions of UModel only support Textures and Animations/SkeletalMeshes. StaticMesh packages can be loaded via UModel but show 0 polys.

I was wondering if it's lost knowledge as I've seen videos from years ago of someone having Splinter Cell 1 StaticMeshes imported to other games. I assume it wouldn't be as difficult as Splinter Cell 1 isn't nearly as modified as SCCT/SCDA.

I'm currently working on a project on porting some SC levels to a different engine myself, and it'd be a big help to have access to the StaticMeshes.

Logged
Jump to:  

Powered by SMF | SMF © 2006-2009, Simple Machines LLC
Leviathan design by Bloc | XHTML | CSS