Filament: `filament.ao.bilateral_threshold` and six other model options are ignored since 4.0.1, which changed the default ambient occlusion

オープン
#3,933 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 6 日以内に返信

@jeongseok-meta がすでに取り組んでいます。

2026年11月21日 から。

  • #3934 @jeongseok-meta による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
56/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp, python

調査の方向性

Start with src/render/filament/mjrfilament.cc and src/render/filament/core/scene_view.cc, where the issue says model render options are read and applied; compare those paths with the 4.0.0 references and the removed options. Check doc/programming/rendering.rst for the documented keys and defaults. Done means all seven options can be set again, while unset options preserve current output and the documented AO threshold behavior is addressed.

索引モデルが issue の本文から書いたものです。

説明

Intro

Hi! I use MuJoCo with the Filament renderer to render camera images for robot simulation.

My setup

MuJoCo 4.0.0 and 4.0.1 from PyPI, and main at 6a6595c built from source. Python API, Linux x86_64, Python 3.12. Vulkan backend through SwiftShader on CPU (libvk_swiftshader.so from Chrome for Testing 158 for linux64).

What's happening? What did you expect?

Since 4.0.1 the Filament renderer no longer reads the model numeric filament.ao.bilateral_threshold. 4.0.0 read it with a documented default of 0.5; now the renderer runs with Filament's own default, 0.05. Ambient occlusion is on by default, so a model that never sets the key renders differently from 4.0.0, and a model that does set it gets no effect. The 4.0.1 changelog doesn't mention it, and main (6a6595c) has no replacement: model options now go through mjrfRenderOpts, which has no field for it.

4.0.0 vs 4.0.1: the ambient occlusion band at the base of the box differs

What changed:

The same commit stopped reading filament.cg.gamut_mapping, filament.cg.luminance_scaling, filament.fog.in_scattering_start, filament.fog.in_scattering_size, filament.bloom.dirt_strength and filament.bloom.resolution. Their 4.0.0 defaults were Filament's own, so only the ability to set them went away. filament.ao.bilateral_threshold is the one whose default output changed.

Expected: the documented keys keep working. The commit message says "These flags can be restored later if needed." On main a restore that changes nothing for models that don't set the keys adds the seven options to the mjrf*Opts structs with Filament's values as defaults (0.05, 0.2, 384, false, false, 0, -1), reads them in mjrf_modelRenderOpts and applies them in SceneView::Apply. A local build of main with exactly that renders as below: nothing declared matches main, and 0.5 declared matches 4.0.0. Restoring 0.5 as the default instead would bring back 4.0.0's look for every model, at the cost of changing today's output.

main with the options restored and threshold 0.5 declared vs 4.0.0: identical

main with the options restored vs main, nothing declared: identical

Steps for reproduction
  1. Save the script below as filament_ao_repro.py. It renders the model below from 8 views at 640x480 with the Vulkan backend and saves the frames, or compares two runs.
  2. Run the commands below. They need a Vulkan driver; without a GPU, SwiftShader works, for example from a Chrome for Testing linux64 build: export VK_ICD_FILENAMES=$CHROME_DIR/vk_swiftshader_icd.json LD_LIBRARY_PATH=$CHROME_DIR.
python3 -m venv v400 && v400/bin/pip install mujoco==4.0.0 numpy
python3 -m venv v401 && v401/bin/pip install mujoco==4.0.1 numpy
v400/bin/python filament_ao_repro.py render out/400
v401/bin/python filament_ao_repro.py render out/401
v400/bin/python filament_ao_repro.py render out/400_off --ao-off
v401/bin/python filament_ao_repro.py render out/401_off --ao-off
v400/bin/python filament_ao_repro.py render out/400_t005 --threshold 0.05
v401/bin/python filament_ao_repro.py render out/401_t05 --threshold 0.5
v401/bin/python filament_ao_repro.py compare out/400 out/401
v401/bin/python filament_ao_repro.py compare out/400_off out/401_off
v401/bin/python filament_ao_repro.py compare out/400_t005 out/401
v401/bin/python filament_ao_repro.py compare out/401_t05 out/401
  1. Results. Each row compares two runs over the same 8 views. Identical frames: higher is better, and 8/8 means every pixel matches. Max difference (in 8-bit levels) and pixels changed: lower is better, and 0 means no change.
Comparison Identical frames Max difference Pixels changed
4.0.0 vs 4.0.1, nothing declared 0/8 4-8 17.1-18.6%, mostly the band at the base of the box
4.0.0 vs 4.0.1, ambient occlusion off (filament.ao.enabled = 0) 8/8 0 0%
4.0.0 with filament.ao.bilateral_threshold = 0.05 vs 4.0.1 8/8 0 0%
4.0.1 with filament.ao.bilateral_threshold = 0.5 vs 4.0.1 8/8 0 0% (the key is ignored)
main (6a6595c) vs 4.0.1 8/8 0 0%
main with the threshold at 0.5 vs main 8/8 0 0% (still ignored)
main with the options restored, nothing declared, vs main 8/8 0 0%
main with the options restored and the threshold at 0.5 vs 4.0.0 8/8 0 0%

On this scene the threshold is the whole difference between 4.0.0 and 4.0.1.

Minimal model for reproduction
minimal XML (without the numeric, 4.0.0 and 4.0.1 already differ)
<mujoco model="box_on_plane">
  <custom>
    <!-- 4.0.0 reads this; 4.0.1 and main ignore it. -->
    <numeric name="filament.ao.bilateral_threshold" data="0.5"/>
  </custom>
  <asset>
    <texture name="grid" type="2d" builtin="checker" width="512" height="512"
             rgb1=".55 .55 .55" rgb2=".45 .45 .45"/>
    <material name="grid" texture="grid" texrepeat="4 4"/>
  </asset>
  <worldbody>
    <light pos="0 0 3" dir="0 0 -1"/>
    <geom name="floor" type="plane" size="2 2 0.1" material="grid"/>
    <geom name="box" type="box" pos="0 0 0.2" size="0.2 0.2 0.2" rgba=".8 .8 .8 1"/>
  </worldbody>
</mujoco>
Code required for reproduction
filament_ao_repro.py
"""Renders a box on a plane with MuJoCo's Filament renderer, or compares two runs.

  python filament_ao_repro.py render OUT_DIR [--ao-off] [--threshold X]
  python filament_ao_repro.py compare DIR_A DIR_B

`render` saves 8 frames (one camera orbit) as .npy files. Ambient occlusion is on
by default; --ao-off sets the model numeric `filament.ao.enabled` to 0 and
--threshold X sets `filament.ao.bilateral_threshold` to X.
"""

import argparse
import glob
import os

import mujoco
import numpy as np

XML = """
<mujoco model="box_on_plane">
  <custom>CUSTOM</custom>
  <asset>
    <texture name="grid" type="2d" builtin="checker" width="512" height="512"
             rgb1=".55 .55 .55" rgb2=".45 .45 .45"/>
    <material name="grid" texture="grid" texrepeat="4 4"/>
  </asset>
  <worldbody>
    <light pos="0 0 3" dir="0 0 -1"/>
    <geom name="floor" type="plane" size="2 2 0.1" material="grid"/>
    <geom name="box" type="box" pos="0 0 0.2" size="0.2 0.2 0.2" rgba=".8 .8 .8 1"/>
  </worldbody>
</mujoco>
"""


def render(args):
  # pylint: disable-next=g-import-not-at-top
  from mujoco import mjrf
  from mujoco.rendering.filament import model_scene
  from mujoco.rendering.filament import renderer
  from mujoco.studio import window  # pylint: disable=unused-import

  custom = ""
  if args.ao_off:
    custom += '<numeric name="filament.ao.enabled" data="0"/>'
  if args.threshold is not None:
    custom += (
        '<numeric name="filament.ao.bilateral_threshold"'
        f' data="{args.threshold}"/>'
    )
  model = mujoco.MjModel.from_xml_string(XML.replace("CUSTOM", custom))
  data = mujoco.MjData(model)
  mujoco.mj_forward(model, data)

  ctx = mjrf.Context(
      mjrf.ContextConfig(graphics_api=mjrf.GraphicsApi.GRAPHICS_API_VULKAN)
  )
  r = renderer.Renderer(ctx)
  scene = model_scene.ModelScene(ctx, model, r.scene("scn"))
  scene.update(data)
  buf = np.empty((480, 640, 3), dtype=np.uint8)
  r.target("out", buf)

  cam = mujoco.MjvCamera()
  mujoco.mjv_defaultFreeCamera(model, cam)
  cam.lookat[:] = (0.0, 0.0, 0.15)
  cam.distance = 1.6
  cam.elevation = -25.0

  os.makedirs(args.out, exist_ok=True)
  print(f"mujoco {mujoco.__version__}")
  for i in range(8):
    cam.azimuth = 45.0 + i * 45.0
    view = renderer.View(
        scene="scn",
        target="out",
        camera=mujoco.mjv_camera2GLCamera(model, data, cam),
    )
    r.render([view])
    np.save(os.path.join(args.out, f"frame_{i}.npy"), buf)


def compare(args):
  names = sorted(
      os.path.basename(p) for p in glob.glob(os.path.join(args.a, "*.npy"))
  )
  same = 0
  for name in names:
    a = np.load(os.path.join(args.a, name)).astype(np.int16)
    b = np.load(os.path.join(args.b, name)).astype(np.int16)
    d = np.abs(a - b)
    same += not d.any()
    print(
        f"{name}: max diff {d.max()}, pixels that differ"
        f" {np.any(d > 0, axis=-1).mean() * 100:.1f}%"
    )
  print(f"{same}/{len(names)} frames identical")


def main():
  parser = argparse.ArgumentParser()
  sub = parser.add_subparsers(dest="cmd", required=True)
  p = sub.add_parser("render")
  p.add_argument("out")
  p.add_argument("--ao-off", action="store_true")
  p.add_argument("--threshold", type=float)
  p = sub.add_parser("compare")
  p.add_argument("a")
  p.add_argument("b")
  args = parser.parse_args()
  render(args) if args.cmd == "render" else compare(args)


if __name__ == "__main__":
  main()
Confirmations
主要言語
C++
スター
18.3k
フォーク
2.2k
平均マージ
9日 11時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

google-deepmind/mujoco のほかの issue

google-deepmind/mujoco の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。