three-gpu-pathtracer icon indicating copy to clipboard operation
three-gpu-pathtracer copied to clipboard

three-gpu-pathtracer hardcodes first UV Map for materials, even if that's the wrong one

Open FrostKiwi opened this issue 2 months ago • 1 comments

Describe the bug As noticed in https://github.com/mrdoob/three.js/pull/32067#issuecomment-3425068785, three-gpu-pathtracer seems to hardcode the UV map that it uses to UV Map zero. For scenes with baked AO, three-gpu-pathtracer ignores baked AO, as it should and only uses the other texture channels during its Material setup.

Geometry may come with multiple UV Maps, as for Baked AO other Mapping strategies are needed. Whilst it's convention to keep the UV Maps for the base material as UVMap 0 and UV Maps for AO as UVMap 1, it may be the other way around. ThreeJS has no issues handling this and no matter what UV Map is used for which texture, it handles it fine. three-gpu-pathtracer on the other hand has issues here and seems to hardcode that it always uses UV Map0 of its textures, even if the texture setup requires UV Map 1.

This breaks materials for assets with UV map 1 for its textures. Setting it the other way around, fixes the issue, as shown in the screenshots below.

Expected behavior

Like ThreeJS, pick the correct UV map, instead of assuming UV map 0 for materials.

Screenshots and Repro Model

ThreeJS v0.180.0 (UV for AO in Channel 0, UV for Base Materials in Channel 1) three-gpu-pathtracer (UV for AO in Channel 0, UV for Base Materials in Channel 1) three-gpu-pathtracer (UV for Base Materials in Channel 0, UV for AO in Channel 1)
Image Image Image
Image

Platform:

  • Device: [all]
  • OS: [all]
  • GPU: [all]
  • Browser: [all]
  • Browser Version: [all]
  • Three.js version: [v0.180.0]
  • Library version: [v0.0.23]

FrostKiwi avatar Oct 22 '25 06:10 FrostKiwi

Hi @FrostKiwi! Thanks for the report - when the pathtracer was written three.js did not support setting custom UV channels per texture so the code is written to support the original mechanism. So currently users will have to adjust the texture maps to use the original convention from three.js. It could be added but realistically I think this is something to be added when the project (someday) is rewritten for WebGPU compute shaders.

gkjohnson avatar Oct 23 '25 02:10 gkjohnson