Texture code marker to opt meshes into custom shaders #1024

Open
opened 2026-10-24 08:02:00 +00:00 by sky_line · 0 comments
Owner

Creators opt a mesh into a custom shader (fur, skin, wet, …) by placing a tiny code marker in any unused gap of their texture's UV layout. The rest of the texture is untouched, so the same texture keeps working everywhere else, including as a Bakes on Mesh skin layer.

Marker

  • A short start pattern (like a QR code's corner squares) followed by about 3×3 to 4×4 data cells, each cell around 4×4 px, so roughly 12–16 px total (about 0.02% of a 1024 texture).
  • Each cell uses only four very different values per channel (0/85/170/255), so it survives lossy texture compression. That's 6 bits per cell, 54–96 bits total: magic number, shader ID, a few parameters, checksum.
  • It can go anywhere in the texture: we find it by scanning for the start pattern, and the scan tolerates scaling (a 512 skin layer baked into a 1024 bake).
  • Guidance for creators: keep a few px of padding from UV islands so the texture's lower-resolution versions don't blend marker colour into visible areas; a near-neutral palette makes it look like noise in a gap nobody sees.

Reading it

  • Scan once on a background thread when a texture first decodes at full resolution. Custom shaders only matter up close, where full resolution is loaded anyway; distant avatars use the normal shader.
  • Remember the tag per texture UUID on disk, so later loads know it immediately, before full resolution arrives.
  • The per-texture tag goes into the face's instance flags, so shader selection is a GPU-side material bin with no per-face CPU work.
  • Custom shaders need a cost cap, since anyone can tag anything.

First step: test how small the marker can be

Upload a test skin with markers at 2, 3, 4 and 6 px per cell, wear it through a server bake, and read back the baked texture. The smallest cell size that still decodes after compression and baking sets the format.

Then

  • Write the marker spec, plus a generator for creators (PNG output) and a wiki page.
  • Add an automatic fallback (e.g. pony bodies → fur) for content without a marker; the marker is the precise opt-in on top.
  • Check whether glTF material assets keep extra custom fields server-side, which would give PBR content another place for the tag. The pixel marker stays the route that survives a bake.

Blocks #1021 and #1022.

Creators opt a mesh into a custom shader (fur, skin, wet, …) by placing a tiny code marker in any unused gap of their texture's UV layout. The rest of the texture is untouched, so the same texture keeps working everywhere else, including as a Bakes on Mesh skin layer. ## Marker - A short start pattern (like a QR code's corner squares) followed by about 3×3 to 4×4 data cells, each cell around 4×4 px, so roughly 12–16 px total (about 0.02% of a 1024 texture). - Each cell uses only four very different values per channel (0/85/170/255), so it survives lossy texture compression. That's 6 bits per cell, 54–96 bits total: magic number, shader ID, a few parameters, checksum. - It can go anywhere in the texture: we find it by scanning for the start pattern, and the scan tolerates scaling (a 512 skin layer baked into a 1024 bake). - Guidance for creators: keep a few px of padding from UV islands so the texture's lower-resolution versions don't blend marker colour into visible areas; a near-neutral palette makes it look like noise in a gap nobody sees. ## Reading it - Scan once on a background thread when a texture first decodes at full resolution. Custom shaders only matter up close, where full resolution is loaded anyway; distant avatars use the normal shader. - Remember the tag per texture UUID on disk, so later loads know it immediately, before full resolution arrives. - The per-texture tag goes into the face's instance flags, so shader selection is a GPU-side material bin with no per-face CPU work. - Custom shaders need a cost cap, since anyone can tag anything. ## First step: test how small the marker can be Upload a test skin with markers at 2, 3, 4 and 6 px per cell, wear it through a server bake, and read back the baked texture. The smallest cell size that still decodes after compression and baking sets the format. ## Then - Write the marker spec, plus a generator for creators (PNG output) and a wiki page. - Add an automatic fallback (e.g. pony bodies → fur) for content without a marker; the marker is the precise opt-in on top. - Check whether glTF material assets keep extra custom fields server-side, which would give PBR content another place for the tag. The pixel marker stays the route that survives a bake. Blocks #1021 and #1022.
sky_line added this to the Slipstream project 2026-10-24 08:02:00 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
sky_line/Slipstream#1024
No description provided.