Skip to content

LoadLEV() Texture and Animated Texture loading#39

Open
Blounard wants to merge 2 commits intomateusfavarin:mainfrom
Blounard:LoadLEV-Textures
Open

LoadLEV() Texture and Animated Texture loading#39
Blounard wants to merge 2 commits intomateusfavarin:mainfrom
Blounard:LoadLEV-Textures

Conversation

@Blounard
Copy link
Copy Markdown
Contributor

@Blounard Blounard commented Mar 2, 2026

Modify LoadLEV() to implement the loading of textures and animated textures.

What should work : Loading a .lev file, with a .vrm file of the same name in the same folder will create the required .png files and .obj file for textures and animated textures.
Those textures can be edited, and the track can be re-saved afterward.
Work for the renderer, and work for re saving .lev files.
Create 1 material per texture file used, it allow for some quick modifications of some quadblocks attribute if they share the same texture file.
The extracted texture should always be cropped accordingly to all the quadblock UVs, so it should always be possible to regenerate the .vrm file afterward without hitting the VRAM size limit.

What does not work : Some custom tracks created with some older version of CTE won't be correctly extracted. 1 example is Drive Thru Danger, saphi edition, some quadblocks have raw UV stored in the .lev that goes outside of the actual texture range (by 1 pixel). I believe it's because older version of CTE had a different code in Texture::Serialize, with a "hack" to fix a "off by 1" pixel issue. Therefore, the texture extracted are bigger than the original, because the code try to extract from a wider range in the VRAM page. This can prevent the VRAM to be re generated, because the re created textures are bigger than the originals.
I haven't found a fix to that, but it's probably only an issue for track created with CTE 0.26 or older.
I confirmed with Boxic that DTD .lev and .vrm files re created with CTE v0.30 with the same presets are correctly opened, without UV issues.

What can't be implemented without some massive rework : Vanilla track are poorly loaded with this function because all 4 faces of each quadblock can point to different textures files (from different VRAM pages). It means vanilla quadblocks need several material, or material needs several textures to be correctly represented. Currently CTE has 1 material per quad, and 1 texture per material, so this isn't possible. (Currently, if you load a vanilla track with this PR, the texture of 1 of the face will be used for all 4, so it's messy)

Blounard added 2 commits March 2, 2026 23:06
Modify LoadLEV() to implement the loading of textures and animated textures
Improved the texture parsing to try to be closer to what CTR does.

It no longer assumes that textures and animTextures are all in order after MeshInfo and before Quadblocks.

Instead it parses quadblock exclusively, and determines if a texture is animated or not with PointerMap, and only header.offAnimText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant