@@ -496,3 +496,102 @@ proliferation of overlapping technologies, which differ not only between platfor
496496case of Linux. The addition of a couple of extra functions (such as those provided by OSMesa for example) could have
497497avoided a lot of confusion. EGL is a newer standard from Khronos which aims to do this, and it is gaining popularity.
498498But we cannot yet assume that all users have it installed.
499+
500+ .. _saRender :
501+
502+ `render <https://github.com/google-deepmind/mujoco/blob/main/sample/render.cc >`_
503+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
504+
505+ This code sample renders a model configuration offscreen and saves the result directly to a PNG image file. It supports
506+ both the modern Filament rendering backend (:ref: `mjrf <FilamentRenderingApi >`) with physically-based rendering (PBR),
507+ and the classic OpenGL renderer (:ref: `mjrContext `). The rendering runs headless without creating an interactive window.
508+
509+ .. code-block :: Shell
510+
511+ render model [output] [options]
512+
513+ Where the command-line arguments and options are
514+
515+ .. list-table ::
516+ :width: 95%
517+ :align: left
518+ :widths: 2 1 4
519+ :header-rows: 1
520+
521+ * - Option
522+ - Default
523+ - Meaning
524+ * - ``model ``
525+ - (required)
526+ - path to model (positional argument)
527+ * - ``output ``
528+ - (default)
529+ - path to output image file (positional argument, default: ``<model>.png ``)
530+ * - ``--backend=B ``
531+ - ``filament ``
532+ - rendering backend (``filament ``, ``classic ``)
533+ * - ``--width=N ``
534+ - 640
535+ - image width in pixels
536+ * - ``--height=N ``
537+ - 480
538+ - image height in pixels
539+ * - ``--camera=C ``
540+ - (free)
541+ - camera name or integer index (default: free camera)
542+ * - ``--lookat=X,Y,Z ``
543+ - (center)
544+ - free camera lookat position
545+ * - ``--distance=D ``
546+ - (fit)
547+ - free camera distance
548+ * - ``--azimuth=A ``
549+ - ``90 ``
550+ - free camera azimuth in degrees
551+ * - ``--elevation=E ``
552+ - ``-45 ``
553+ - free camera elevation in degrees
554+ * - ``--key=K ``
555+ - (none)
556+ - keyframe name or integer index to load prior to rendering
557+ * - ``--geomgroup=G ``
558+ - ``111000 ``
559+ - 6-character string enabling/disabling geom groups 0-5 (e.g. ``111111 ``)
560+ * - ``--sitegroup=S ``
561+ - ``111000 ``
562+ - 6-character string enabling/disabling site groups 0-5
563+ * - ``--label=L ``
564+ - (none)
565+ - type of label (e.g. ``--label=geom ``, ``--label=body ``, ``--label=site ``)
566+ * - ``--frame=F ``
567+ - (none)
568+ - type of coordinate frame (e.g. ``--frame=geom ``, ``--frame=body ``, ``--frame=site ``)
569+ * - ``--<visflag>=0|1 ``
570+ - (default)
571+ - toggle visualization flag declared in :ref: `mjVISSTRING ` (e.g. ``--joint=1 ``, ``--contactpoint=1 ``)
572+ * - ``--<rndflag>=0|1 ``
573+ - (default)
574+ - toggle rendering flag declared in :ref: `mjRNDSTRING ` (e.g. ``--shadow=0 ``, ``--wireframe=1 ``)
575+
576+ **Notes: **
577+
578+ - Running ``render `` with no arguments (or with ``--help `` / ``-h ``) prints the help message.
579+ - The non-optional ``model `` path and optional ``output `` path are positional arguments. If ``output `` is
580+ omitted, the output filename is derived from the model filename with the ``.png `` extension (e.g.
581+ ``humanoid.xml `` becomes ``humanoid.png ``).
582+ - ``--backend=filament `` uses MuJoCo's Filament C API to configure a scene from the model, setting up lighting,
583+ materials, and textures, and rendering via Filament's offscreen pipeline. ``--backend=classic `` uses standard OpenGL
584+ offscreen rendering with an EGL context.
585+ - The default camera is the model's free camera looking at the center of the scene. Specifying ``--camera=name `` selects
586+ a named camera defined in the model XML, while integer indices ``0, 1, ... `` select fixed cameras in order of definition.
587+ When using the free camera, its viewpoint can be adjusted via ``--lookat=x,y,z ``, ``--distance=d ``, ``--azimuth=a ``,
588+ and ``--elevation=e ``.
589+ - If a keyframe is specified via ``--key ``, the model state is reset to that keyframe before evaluating kinematics and
590+ rendering. If no keyframe is specified and a keyframe named ``test `` exists in the model, it is used by default.
591+ - Visualization and rendering flags can be individually toggled using normalized flag names from :ref: `mjVISSTRING `
592+ and :ref: `mjRNDSTRING `.
593+ - Labels can be enabled using ``--label=L `` where ``L `` is a label type name from :ref: `mjLABELSTRING ` (e.g. ``geom ``,
594+ ``body ``, ``joint ``) or an integer index.
595+ - Coordinate frames can be rendered using ``--frame=F `` where ``F `` is a frame type name from :ref: `mjFRAMESTRING ` (e.g.
596+ ``geom ``, ``body ``, ``site ``, ``world ``) or an integer index.
597+
0 commit comments