Filament: `filament.ao.bilateral_threshold` and six other model options are ignored since 4.0.1, which changed the default ambient occlusion
メンテナーはふだん 6 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 56/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
調査の方向性
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.

What changed:
- 4.0.0,
scene_view.ccL635-636, readReadElement(model, "filament.ao.bilateral_threshold", 0.5f), andrendering.rstL440-443 documentedao.bilateral_thresholdas real, default 0.5, "Depth difference treated as an edge by the blur filter." - fb0521ea ("Remove some custom flags.") removed that read and the row.
- Filament's default is
float bilateralThreshold = 0.05f;at the revision MuJoCo pins (rc/1.79.0, 0643fd0f).
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.


Steps for reproduction
- 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. - 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
- 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
- I searched the latest documentation thoroughly before posting.
- I searched previous Issues and Discussions, I am certain this has not been raised before.
- 主要言語
- C++
- スター
- 18.3k
- フォーク
- 2.2k
- 平均マージ
- 9日 11時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google-deepmind/mujoco のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google-deepmind/mujoco#3932 ·
メンテナーはふだん 6 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
google-deepmind/mujoco#3929 ·
メンテナーはふだん 6 日以内に返信
-
`import mujoco.mjx` fails with TypeError when warp-lang is too old対応中かも @moah0911 が 22 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
google-deepmind/mujoco#3738 ·
メンテナーはふだん 6 日以内に返信
-
Unity 6.6 support再び着手できるかも @Balint-H が 53 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンenhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
google-deepmind/mujoco#3615 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 6 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 56/100
google-deepmind/mujoco#3931 ·
メンテナーはふだん 6 日以内に返信
google-deepmind/mujoco の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
maplibre/maplibre-native#5072 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
tenstorrent/tt-umd#4017 ·
メンテナーはふだん 3 日以内に返信
-
difficulty:easy func:gui prio:low type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NatronGitHub/Natron#1538 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
hyprwm/hyprsunset#103 · コメント 1 件 ·