Skip to content

Support user-made textures #241

Description

@schlangz

Support user-made textures.

Initial release could support the replacement of 64x64 tiles by texture id in a subfolder and follow up release could support higher resolutions.

Important to keep in mind that texture ids are per-track slot numbers, not globally unique: a flat tex{tex_idx}_{tile}.png naming scheme would apply to whichever track happens to be loaded when that slot is populated, not to one specific track - we need to key the overrides by track filename too, not just (tex_idx, tile).

Car-related banks (1–16, 18) are car-persistent rather than track-specific, but the track/building banks - which is what tile references like "idx=23" or "idx=123" address - are explicitly track-relative and reloaded fresh on every track change.

Each track's data file specifies its own atlas filename via a T: line (and optionally BLD: for buildings, defaulting to building.drh). Loading a track overwrites the fixed bank slots - tex_idx=0 (TEXTURE_BANK_TRACK) and tex_idx=17 (TEXTURE_BANK_BUILDING) - with that track's own pixel data (loadtrak.c -> graphics.c -> scene_render_load_texture). So (tex_idx=0, tile=23) on one track and the same (tex_idx=0, tile=23) on a different track are almost always completely different textures - same slot number, different loaded content per track.

building.drh is the default building/sign texture atlas file — the fallback used when a track's data doesn't specify its own.

Concretely (graphics.c:41-43, loadtrak.c:1378-1419):

  • texture.drh is the default track atlas filename (tex_idx=0, TEXTURE_BANK_TRACK)
  • building.drh is the default building atlas filename (tex_idx=17, TEXTURE_BANK_BUILDING)
  • gentex.drh is a car-generation texture default

Each track's data can supply a T: line to override the track atlas, and optionally a BLD: line to override the building atlas - but read_bldmap (loadtrak.c:1419) falls back to "building.drh" if no BLD: entry is present in the track data.

The .drh files themselves are loaded via getcompactedfilelength/loadcompactedfile (graphics.c:703-733) — a compressed format that decompresses into raw indexed-color 4096-byte tile blocks (64x64 or 32x32 depending on gfx_size), then gets sorted/mapped into the atlas layout via sort_texture/setmapsel.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    • Status
      Open

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions