Skip to content

[BUG FIX] Preserve PBR base color in packed RGBA - #3038

Closed
NoahLinckeScout wants to merge 1 commit into
Genesis-Embodied-AI:mainfrom
NoahLinckeScout:noah-pbr-base-color-precedence
Closed

[BUG FIX] Preserve PBR base color in packed RGBA#3038
NoahLinckeScout wants to merge 1 commit into
Genesis-Embodied-AI:mainfrom
NoahLinckeScout:noah-pbr-base-color-precedence

Conversation

@NoahLinckeScout

@NoahLinckeScout NoahLinckeScout commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Why

Some GLBs, including HLOD tiles, use a zero base-color factor while putting their imagery in an emissive texture. The previous packed-RGBA path treated the mere presence of a diffuse texture as authoritative, producing black terrain. Conversely, preferring emissive whenever present loses the intended PBR base color of ordinary assets such as vehicles.

What changed

  • Prefer a nonblack PBR diffuse texture when creating packed RGBA.
  • Fall back to emissive when diffuse is absent or intentionally black.
  • Cover both the normal PBR and zero-base-factor HLOD cases.

Impact / safety properties

This only affects the packed RGBA representation consumed by renderers; it leaves the original material textures and shading inputs intact.

Validation

Constructed both material shapes under Genesis initialization and verified the selected RGBA pixels.

Fixes #3046.

@NoahLinckeScout
NoahLinckeScout force-pushed the noah-pbr-base-color-precedence branch from 0ef742e to 7eb24b3 Compare July 15, 2026 19:21
@duburcqa
duburcqa marked this pull request as ready for review July 21, 2026 21:24
duburcqa
duburcqa previously approved these changes Jul 21, 2026
@duburcqa duburcqa changed the title [BUG FIX] Preserve PBR base color in packed RGBA [BUG FIX] Correctly render assets that pair a base color with an emissive map. Jul 21, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc85491dae

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread genesis/options/surfaces.py Outdated
Comment thread genesis/vis/rasterizer_context.py Outdated
@duburcqa duburcqa changed the title [BUG FIX] Correctly render assets that pair a base color with an emissive map. [BUG FIX] Preserve PBR base color in packed RGBA. Jul 21, 2026
@duburcqa

Copy link
Copy Markdown
Collaborator

@codex review

duburcqa
duburcqa previously approved these changes Jul 21, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 931ce42991

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread genesis/vis/rasterizer_context.py Outdated
Comment thread genesis/options/surfaces.py Outdated
@duburcqa
duburcqa force-pushed the noah-pbr-base-color-precedence branch from 1911484 to f74bd0f Compare July 22, 2026 05:47
duburcqa
duburcqa previously approved these changes Jul 22, 2026
@duburcqa
duburcqa force-pushed the noah-pbr-base-color-precedence branch 2 times, most recently from 209eac2 to beafdf8 Compare July 22, 2026 06:52
duburcqa
duburcqa previously approved these changes Jul 22, 2026
@duburcqa

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: beafdf8142

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread genesis/options/surfaces.py Outdated
Comment thread genesis/vis/rasterizer_context.py Outdated
duburcqa
duburcqa previously approved these changes Jul 22, 2026
@duburcqa

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 318a2a3436

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread genesis/options/surfaces.py Outdated
Comment on lines +236 to +237
if base_texture is not None and not base_texture.is_black:
return base_texture

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep emissive-only assets from defaulting to white

When a GLB uses KHR_materials_unlit, parse_glb_material explicitly moves the base color into emissive_texture and clears color_texture, but Surface.update_texture then installs the default white ColorTexture as the primary texture. This new resolver treats that injected white as an authored nonblack base and returns it, so get_rgba() packs white instead of the unlit/emissive texture. This regresses unlit assets and other emissive-only fallback cases unless the fallback can distinguish an absent base from the defaulted one.

Useful? React with 👍 / 👎.

Comment thread genesis/utils/gltf.py Outdated
Comment on lines 219 to 220
if material.emissiveTexture.texCoord is not None and (color_texture is None or color_texture.is_black):
uvs_used = material.emissiveTexture.texCoord

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Follow emissive UVs when the base has no atlas

When the base color is only a factor (ColorTexture) and the emissive channel is an image, the base albedo does not consume UVs, but this condition still prevents emissiveTexture.texCoord from becoming uvs_used. A GLB with baseColorFactor plus an emissive map on TEXCOORD_1 will therefore bake TEXCOORD_0 and sample the emissive map with the wrong coordinates. The base UV should win only for base textures that actually require UVs.

Useful? React with 👍 / 👎.

Comment thread genesis/utils/mesh.py Outdated
Comment on lines +338 to +341
material = trimesh.visual.material.PBRMaterial(
baseColorFactor=color_f32_to_u8(texture.color), **emissive_kwargs
)
visual = trimesh.visual.TextureVisuals(material=material)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve UVs for color bases with emissive images

When texture is a ColorTexture but emission is an ImageTexture, emissive_kwargs contains an emissiveTexture, yet this branch creates TextureVisuals without uv=uvs. Mesh._get_trimesh_props then sends no texcoord_0 to pyrender, while materials with HAS_EMISSIVE_TEX sample uv_0 in mesh.frag, so the emissive map is lost or can fail to render for solid-base materials with textured emission. Pass the available UVs whenever the PBR material includes a texture.

Useful? React with 👍 / 👎.

@duburcqa duburcqa changed the title [BUG FIX] Preserve PBR base color in packed RGBA. [BUG FIX] Preserve PBR base color in packed RGBA Jul 22, 2026
@duburcqa
duburcqa force-pushed the noah-pbr-base-color-precedence branch from 8143285 to 7eb24b3 Compare July 22, 2026 07:55
@duburcqa

Copy link
Copy Markdown
Collaborator

Superseded by #3088, which consolidates and extends this fix (all surfaces, additive emissive across renderers, and glTF UV-set / unlit handling). Thanks @NoahLinckeScout for the original fix - it is preserved as the first change there.

@duburcqa duburcqa closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Packed RGBA lets emissive replace an authored PBR base color

2 participants