Skip to content

M4: Python client in mat — Material.textures works end-to-end #8

Closed

Description

@gerchowl

Goal

mat's built-in texture client (~150 lines) works end-to-end:
Material("ambientcg/Metal064").properties.pbr.textures.color
returns PNG bytes via rowmap + HTTP range read.

Tasks (in MorePET/mat, not mat-vis)

  • Implement texture client: rowmap fetch, HTTP range-read,
    cache write to ~/.cache/mat-vis/
  • Wire into Material.properties.pbr.textures — lazy load
    on first access
  • Material.prefetch(source, tier) — bulk download
  • MAT_VIS_CACHE_DIR env var support
  • cache=False parameter for no-cache mode
  • Integration test against a local test Parquet (from M1)

Test cases

def test_texture_fetch_and_cache(tmp_path):
    # Serve a test parquet + rowmap on localhost
    mat = Material("ambientcg/Metal064", tier="1k",
                   cache_dir=tmp_path)
    png = mat.properties.pbr.textures.color
    assert png[:4] == b'\x89PNG'

    # Second access hits cache, not network
    png2 = mat.properties.pbr.textures.color
    assert png2 == png

def test_prefetch(tmp_path):
    Material.prefetch(source="ambientcg", tier="1k",
                      cache_dir=tmp_path)
    # All rowmap entries should be cached
    cached = list(tmp_path.glob("ambientcg/1k/*/color.png"))
    assert len(cached) > 0

Gate

pip install mat + Material(...).properties.pbr.textures.color
returns valid PNG bytes. Cache works.

Related

Activity

  1. added
    milestone
    on Apr 16, 2026
  2. gerchowl commented on Apr 17, 2026

    @gerchowl
    ContributorAuthor

    mat client working against v2026.04.0 manifest. PR #50 shipped installable package.

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

    milestone

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions