Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld 07158574-5…

material_remap

Canonical property/texture-role dictionary used when a material **swaps shaders**. The new shader exposes a different vocabulary than the old one — one shader's `MAIN_TEX` is another's `albedo` is a third's `base_color_texture` — so values would be lost on a naive swap. This modu…

byzero-proxy @ DESKTOP-DB3UJOJ·posted 2mo ago
What it does

material_remap

Canonical property/texture-role dictionary used when a material swaps shaders. The new shader exposes a different vocabulary than the old one — one shader's MAIN_TEX is another's albedo is a third's base_color_texture — so values would be lost on a naive swap. This module maps any known alias onto a canonical role so floats, colors, and texture links carry across the swap to the best of our ability.

Consumed by material.assetType's setShader ref method (and, transitively, by the appearance toolbox's swapShader).

API

local remap = require("modules.material_remap")

remap.propertyRole("MAIN_COLOR")        -- "base_color"  (scalar/color side)
remap.textureRole("MAIN_TEX")           -- "base_color_texture" (texture side)

-- Remap current property values onto the new shader's accepted names.
local mapped, carried, dropped =
    remap.remapProperties(currentProps, shaderRef:getProperties())

-- Canonicalize texture slot names so links bind on the new shader.
local texMapped, texCarried = remap.canonicalizeTextures(currentTextures)

Why two tables

albedo as a color is the base-color factor; albedo as a texture is the base-color map. mat.yaml keeps colors: / floats: separate from textures:, so the caller always knows which side it's remapping. Splitting PROPERTY_ROLES from TEXTURE_ROLES removes the ambiguity instead of guessing from the value shape.

Property remap vs texture remap

  • Properties are remapped against the target shader's real reflected field names (shaderRef:getProperties(), naga reflection). Direct name match wins; otherwise role-to-role. Properties the new shader doesn't expose are dropped.
  • Textures are canonicalized to the engine's builtin on-disk slot convention (base_color_texture, normal_texture, …) because the engine does not yet surface a target shader's reflected texture-slot list to Luau. Unknown slots pass through unchanged.

The alias lists are deliberately broad (glTF / Unity / Unreal / Godot / hand-rolled WGSL conventions). Add new aliases here rather than special-casing a shader at a call site.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

module MaterialRemap Canonical property/texture-role dictionary for cross-shader value preservation. When a material swaps shaders the new shader exposes a DIFFERENT vocabulary (one shader's `MAIN_TEX` is another's `albedo` is a third's `base_color_texture`). This module maps any known alias onto a canonical role so values carry across the swap "to our best ability".

norm(s: string) → string

Normalize a key for fuzzy matching: lowercase, drop every non-alphanumeric character. Collapses `base_color`, `baseColor`, `base-color`, `BASE COLOR` to one comparison key.

argtypedescription
sstring

buildLookup(roleTable: { [string]: { string } }) → void

argtypedescription
roleTable{ [string]: { string } }

propertyRole(name: string) → string

Canonical role for a scalar/color property name, or nil when unknown.

argtypedescription
namestringProperty name as it appears in a shader / mat.yaml.

examples

material_remap.propertyRole("MAIN_COLOR") -- "base_color"

roleShapePair(role: string) →

The colour+scalar role pair a role belongs to, as `{ colour, scalar }`, or nil when the role stands alone. Both halves answer with the same pair, so a caller holding either one can ask which value shape belongs where.

argtypedescription
rolestringA canonical role from `propertyRole`.

examples

material_remap.roleShapePair("emissive") -- { colour = "emissive", scalar = "emissive_intensity" }

textureRole(slot: string) → string

Canonical texture-slot role (and on-disk slot name) for a texture slot name, or nil when unknown.

argtypedescription
slotstringTexture slot name as it appears in a shader / mat.yaml.

examples

material_remap.textureRole("MAIN_TEX") -- "base_color_texture"
⌬ Types
Carry = { from: string, to: string }

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

2items
This part has no composite children. See the Files segment for its leaf payloads.
backing path · modules/material_remap.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.