Files
Mujoco_WASM/model/adhesion/fridge_door.xml
T
Yuval Tassa f9a00bd5b5 Add light softness: spotlight edge softness for physically-based rendering.
The new spotlight attribute softness (real in [0, 1], default 0) is the
fraction of the cone, measured inward from the cutoff, over which
intensity falls to zero. It is used by physically-based lighting models;
the Phong model's corresponding knob remains exponent.

The filament renderer previously hardcoded the inner cone angle to 0,
making the entire beam penumbra: the shader attenuates by the squared
smoothstep ((cos(theta) - cos(outer)) / (cos(inner) - cos(outer)))^2, so
a cutoff-25 spot delivered its rated candela only exactly on-axis and
about a third of it averaged over the light pool, with the deficit
shrinking as the cutoff widens. The inner angle is now
(1 - softness) * cutoff, so at the default the light delivers its full
intensity everywhere inside the cone and illuminance follows E = I/d^2
independent of the cutoff. Setting softness to 1 reproduces the previous
appearance exactly (verified bit-identical), which is the migration path
for models tuned against the old behavior.

The filament light type also changes from FOCUSED_SPOT to SPOT. With
intensity given in candela and the cone set at build time the two types
produce identical output (FOCUSED_SPOT's power-conserving rescale only
applies when the cone changes after the intensity is set), but SPOT
guarantees that candela never rescales with cone angle should the cone
ever become runtime-editable.

Verified with headless renders under a linear tone mapper against an
equal-candela point light at cutoffs 25/45/80: softness 0 gives
spot/point luminance ratio 1.000 at all sampled angles inside the cone;
softness 0.2 is flat over the inner 80% of the cone; softness 1 matches
the previous renderer with zero linear-pixel difference. XML round-trip
and the [0, 1] compile-time check verified. Introspect and wasm bindings
regenerated.

PiperOrigin-RevId: 959334706
Change-Id: I0f0729781899880de1729ea9b3d8c055d715a025
2026-08-04 18:11:48 -07:00

57 lines
2.8 KiB
XML

<mujoco model="Magnetic fridge door">
<!-- The two dark strips are magnets, modeled with adhesion: within the gap band
(the magnet's range) they attract with the summed adhesion of the pair, so a
nearly-closed door snaps shut on its own and stays latched; pulling harder
than the pull-off force pops it open cleanly. Drag the door with Ctrl+drag
after double-clicking it. -->
<statistic center="0 0 .4" meansize="0.03"/>
<visual>
<global elevation="-20" azimuth="-120"/>
<headlight diffuse=".5 .5 .5"/>
<map stiffness="30"/>
</visual>
<asset>
<texture name="ibl" type="cube" builtin="gradient" rgb1=".5 .6 .7" rgb2=".9 .9 .95" width="32" height="32"/>
<texture type="skybox" builtin="gradient" rgb1=".5 .6 .7" rgb2=".9 .9 .95" width="32" height="512"/>
<material name="body" rgba=".92 .92 .94 1"/>
<material name="inside" rgba=".8 .8 .82 1"/>
<material name="magnet" rgba=".2 .2 .22 1"/>
</asset>
<worldbody>
<light pos="1.5 -.5 2" dir="-.6 .2 -.75" diffuse=".7 .7 .7" intensity="200000"
softness="1"/>
<light type="image" texture="ibl" intensity="10000"/>
<geom name="floor" type="plane" size="2 2 .01" rgba=".7 .75 .7 1"/>
<!-- cabinet: interior x [-.35 0], y [-.25 .25], z [0 .8] -->
<geom name="left" type="box" size=".175 .015 .4" pos="-.175 -.235 .4" material="body"/>
<geom name="right" type="box" size=".175 .015 .4" pos="-.175 .235 .4" material="body"/>
<geom name="top" type="box" size=".175 .25 .015" pos="-.175 0 .785" material="body"/>
<geom name="bottom" type="box" size=".175 .25 .015" pos="-.175 0 .03" material="body"/>
<geom name="back" type="box" size=".015 .25 .4" pos="-.335 0 .4" material="body"/>
<geom name="shelf" type="box" size=".155 .21 .008" pos="-.18 0 .4" material="inside"/>
<!-- frame magnet strip, just inside the right wall's front edge -->
<geom name="magnet1" type="box" size=".005 .01 .3" pos="-.015 .19 .4" material="magnet" adhesion="1.5" gap=".003"/>
<body name="door" pos="0 -.25 .42">
<joint name="hinge" pos="0 0 0" axis="0 0 -1" range="0 135" damping=".08" stiffness="0.05"/>
<geom name="hinge" type="cylinder" size=".007" fromto="0 0 -.37 0 0 .37" rgba=".4 .4 .42 1" contype="0" conaffinity="0"/>
<geom name="panel" type="box" size=".015 .24 .37" pos=".015 .25 0" material="body" mass="1.5"/>
<body name="handle">
<geom name="handle" type="capsule" size=".012" fromto=".06 .46 -.12 .06 .46 .12" rgba=".4 .4 .42 1" mass=".1"/>
</body>
<geom name="magnet2" type="box" size=".005 .01 .3" pos="-.005 .44 0" material="magnet" adhesion="1.5" gap=".003" mass=".05"/>
</body>
</worldbody>
<keyframe>
<key name="open" qpos="1.6"/>
<key name="ajar" qpos=".006"/>
</keyframe>
</mujoco>