Skip to content

Inconsistent Lighting Behavior Between Textured and Untextured Geoms #2598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
jjyyxx opened this issue Apr 25, 2025 · 0 comments
Open
2 tasks done

Inconsistent Lighting Behavior Between Textured and Untextured Geoms #2598

jjyyxx opened this issue Apr 25, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@jjyyxx
Copy link
Contributor

jjyyxx commented Apr 25, 2025

Intro

Hi!

I am a graduate student at HKU, I use MuJoCo for my research on robotic manipulation.

My setup

MuJoCo 3.3.0, Python, Linux

What's happening? What did you expect?

When comparing two geoms, A and B, under MuJoCo's GL_MODULATE setting:

  • Geom A uses material MA with rgba = (0.5, 0.5, 0.5, 1) (a non-white color).
  • Geom B uses material MB with rgba = (1, 1, 1, 1) and applies a pure-color texture (0.5, 0.5, 0.5, 1).

Under diffuse lighting, both geoms render the same color, as expected. However, when ambient or specular lighting is introduced:

  • Geom A's rendered color changes according to ambient/specular intensity.
  • Geom B's rendered color remains invariant to ambient/specular lighting.

This inconsistency makes it impossible to seamlessly transition between textured and untextured faces under non-diffuse lighting.

Additional Clarification Request: Color Space Handling

OpenGL's Fixed Function Pipeline (FFP) operates in linear RGB unless explicitly configured otherwise (e.g., via GL_SRGB8_ALPHA8 or GL_FRAMEBUFFER_SRGB). Since MuJoCo does not appear to enable either:

  1. Are all input/output colors (including textures) treated as linear RGB?
  2. If textures are typically authored in sRGB, does the lack of gamma correction lead to incorrect brightness after lighting?

I would appreciate any corrections or insights into these behaviors.

Steps for reproduction

Run script to generate textuer, then launch model.

Minimal model for reproduction

<mujoco>
    <visual>
        <headlight active="0" />
    </visual>
    <asset>
        <texture name="test" type="2d" file="test.png" />
        <material name="test" texture="test" rgba="1 1 1 1" specular=".5" />
        <material name="test2" rgba="0.4980392156862745 0.4980392156862745 0.4980392156862745 1" specular=".5" />
    </asset>

    <worldbody>
        <light directional="true" ambient="0.8 0.0 0.0" diffuse="1 1 1" specular="0.0 0.0 0.0" pos="0 0 5" dir="0 0 -1"/>
        <geom type="plane" size="0.1 0.1 1" pos="-0.1 -0.1 0" material="test"/>
        <geom type="plane" size="0.1 0.1 1" pos=" 0.1  0.1 0" material="test"/>
        <geom type="plane" size="0.1 0.1 1" pos=" 0.1 -0.1 0" material="test2"/>
        <geom type="plane" size="0.1 0.1 1" pos="-0.1  0.1 0" material="test2"/>
    </worldbody>
</mujoco>

Code required for reproduction

import PIL.Image
import numpy as np

image_array = np.zeros((16, 16, 3), dtype=np.uint8)
image_array[...] = (0x7F, 0x7F, 0x7F)
PIL.Image.fromarray(image_array).save("test.png")

Confirmations

@jjyyxx jjyyxx added the bug Something isn't working label Apr 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant