p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

GSOC 26: render multi-material models per part

Open Nixxx19 opened this issue 5 months ago • 1 comments

part of my google summer of code 2026 project, "full texture support for .mtl files in p5.js". works toward #6924.

this is phase 3: the renderer side, building on the data + parser foundation in #8879. multi-material models now actually draw, one part per material, each with its own look. public api is unchanged, you still just call loadModel() and model().

project phases for context:

  • phase 1: design + pipeline study
  • phase 2: data model + obj/mtl parser (#8879)
  • phase 3: per-part rendering (this PR)

what's in here:

  • the renderer loops over a geometry's parts and draws each one
  • each part applies its own material (fill, specular, ambient, shininess, texture) around its draw, restored after so nothing leaks between parts
  • a single-material geometry is its own part, so that path renders exactly as before, byte for byte
  • p5.GeometryPart gains what the renderer needs to treat it as a drawable (hasFillTransparency, userVertexProperties)

tests:

  • a multi-material model (octa-color, 8 materials) draws one fill per part and passes the instance count through
  • the existing obj+mtl diffuse-colour visual test still matches its reference screenshot
  • full unit suite green, including the webgpu and visual (pixel-compare) tests

stacked on #8879, so it should go in after that one merges.

Nixxx19 avatar Jun 24 '26 10:06 Nixxx19

Continuous Release

CDN link

  • https://raw.esm.sh/pr/p5@7b074cb/lib/p5.min.js

Published Packages

  • https://pkg.pr.new/p5@7b074cb

Commit hash: e861e3c

Previous deployments

59b2cce

  • https://raw.esm.sh/pr/p5@24319e8/lib/p5.min.js
  • https://pkg.pr.new/p5@24319e8

aba7591

  • https://raw.esm.sh/pr/p5@978e3fc/lib/p5.min.js
  • https://pkg.pr.new/p5@978e3fc

c8f0ec2

  • https://raw.esm.sh/pr/p5@a0b2e04/lib/p5.min.js
  • https://pkg.pr.new/p5@a0b2e04

e303901

  • https://raw.esm.sh/pr/p5@c5033e1/lib/p5.min.js
  • https://pkg.pr.new/p5@c5033e1

c7db707

  • https://raw.esm.sh/pr/p5@253c93c/lib/p5.min.js
  • https://pkg.pr.new/p5@253c93c

c9c0cc4

  • https://raw.esm.sh/pr/p5@63355be/lib/p5.min.js
  • https://pkg.pr.new/p5@63355be

ef33f8e

  • https://raw.esm.sh/pr/p5@40e6b39/lib/p5.min.js
  • https://pkg.pr.new/p5@40e6b39

This is an automated message.

p5-bot[bot] avatar Jun 24 '26 10:06 p5-bot[bot]

Looking good! I left a few comments. One thing that would be good to clarify is what the valid states of a geometry are (should they always have parts?) so that that can be an invariant in the code and simplifies implementation.

thanks for the review! on the invariant, yeah a geometry should always have at least one part, the constructor guarantees it (parts = [this]) and loaders replace it. i'll lean into that so the renderer just loops parts with no fallback, like you said, addressing the rest now

Nixxx19 avatar Jul 09 '26 06:07 Nixxx19

heads up, the failing check is just flaky ci, not anything in this pr.

Nixxx19 avatar Jul 09 '26 07:07 Nixxx19