Commit Graph

555 Commits

Author SHA1 Message Date
Haroon Qureshi c0fa33f97f Rename mjrFilamentConfig to mjrfContextConfig.
PiperOrigin-RevId: 932996526
Change-Id: Ia81ee074471ab4ff41e0829fa5ba70203599fdb6
2026-06-16 03:36:22 -07:00
Haroon Qureshi ecee1e0c53 Rename nattributes to num_attributes for consistency.
PiperOrigin-RevId: 932973447
Change-Id: Idbf9a52c89e24f34ae360d1617cb72dfaa92aa4e
2026-06-16 02:40:13 -07:00
Haroon Qureshi 9e45ce9801 Use num_ prefix consistently in API.
PiperOrigin-RevId: 932391786
Change-Id: I71c7f300fdb84ce1129ea3da6336df2fcffc5712
2026-06-15 05:08:34 -07:00
Michael Moss 4bb02e299d Resolve Studio assets path dynamically.
PiperOrigin-RevId: 931162732
Change-Id: Ib44a74790facfa797ca2c4f107edb0062a89c117
2026-06-12 08:26:24 -07:00
Haroon Qureshi 01d5be61e3 Move ModelObjects and LightManager to filament/support.
PiperOrigin-RevId: 931136854
Change-Id: I3ce3b7265c5d3c9a49fa84be46e87a76c6e2c8b5
2026-06-12 07:18:07 -07:00
Haroon Qureshi a37389ccfb Split SceneObjects out from ModelObjects.
PiperOrigin-RevId: 930960334
Change-Id: I7958a8240a90e2eb7fb87e58e5bea561459a7695
2026-06-11 23:36:10 -07:00
Haroon Qureshi 96781fa793 Move filament renderer out of experimental into src/render/filament.
Also:
- renames the main header file to mjrfilament.h.
- moves filament_util under a "support" folder.
PiperOrigin-RevId: 930448415
Change-Id: Iad89756aaf1ddf4c3e67e1afc3a13776f71fa20f
2026-06-11 04:43:20 -07:00
Google DeepMind 711aa9fcd8 Fix typo in window size check.
Corrected the comparison from `max_window_width != window_height_` to `max_window_height != window_height_` when checking if the window dimensions have changed.

PiperOrigin-RevId: 929825452
Change-Id: I4ae46502495e16f86c19d4efabe8c048d708789b
2026-06-10 06:55:17 -07:00
Michael Moss 6f6a72f66b CMake updates for Studio integration
PiperOrigin-RevId: 929809674
Change-Id: Iabe670ced44f09fc1ea6d8dcde4b3c9ea4ad270a
2026-06-10 06:20:50 -07:00
Matija Kecman edbe6a6f74 Fix memory and resource leaks in failing resource provider open callbacks
When an mjpResourceProvider's open callback returns 0 (failure), MuJoCo does
not invoke the corresponding close callback. Previously, several resource
provider implementations allocated heap memory or system file handles before
encountering an error, failing to clean them up before returning 0. This change addresses these leaks across the codebase and clarifies the API contract.

PiperOrigin-RevId: 929803942
Change-Id: Ib7344033726895cdf037a8d9356ffc183c78c2d3
2026-06-10 06:08:17 -07:00
Haroon Qureshi ecb15a8d9e Cache the render targets.
PiperOrigin-RevId: 929230223
Change-Id: I06571687ba0153c6ee8631685d1d37052419d2ac
2026-06-09 09:11:19 -07:00
Haroon Qureshi b083ae487e Introduce outline render passes and shader.
Use the jump flood algorithm to render an outline around selected
objects. This requires using custom post-processing shaders and
render passes which is managed by a new "Outliner" class.

PiperOrigin-RevId: 929212147
Change-Id: Ie6f475c7c677df7b0d4fc030a8e9520ff9dd03af
2026-06-09 08:31:49 -07:00
Haroon Qureshi e6e5229126 Format header to conform to style guide.
Also moves some types to the mjrender.h header.

PiperOrigin-RevId: 929189125
Change-Id: I19e5598210898c0defb663c60d7ecfb9a19bcd38
2026-06-09 07:43:16 -07:00
Haroon Qureshi ae2e8aa940 Rename mjrRenderTargetConfig to mjrfRenderTargetConfig.
This rename was overlooked in the previous commit which updated
the prefixes for all filament-specific render objects.

PiperOrigin-RevId: 928710590
Change-Id: I0ff09cb077f7d5643371d43a43fc992352e6d85d
2026-06-08 12:33:27 -07:00
Haroon Qureshi 2fcd135179 Remove layer mask from public API.
Instead, use materials to determine the layer mask of an object.

This hides the details/complexities of how layers are used
to render different passes from the user and will allow the
renderer to do more advanced rendering passes.

PiperOrigin-RevId: 928682525
Change-Id: I1f53dc8d12d2e574de6528977f55e79f896c6e42
2026-06-08 11:37:47 -07:00
Haroon Qureshi 982e3be9ef Add mjrfCallback type.
PiperOrigin-RevId: 928640487
Change-Id: Iebf470caafe924a976e4a1b39b0c47727e22195b
2026-06-08 10:26:40 -07:00
Haroon Qureshi 7e790879ef Fix namespace for filament-specific "mjrf" API.
PiperOrigin-RevId: 928582582
Change-Id: Idc312607b2f063d8ace8d5cc79bfbc8ac588d13f
2026-06-08 08:37:52 -07:00
Haroon Qureshi 116cfe9c70 Remove initial width/height arguments.
The ValidateSwapChains function will correctly set up swap chains
before any render calls, negating the need to have something done
in the constructor.

PiperOrigin-RevId: 928529339
Change-Id: Ie584d57f649730adc092f8683f18697892a5a14f
2026-06-08 06:34:40 -07:00
Haroon Qureshi da5500c202 Implement additional draw modes:
- Default rendering but without textures.
- Island coloring based on sleep state.
- Selected object highlighting.

PiperOrigin-RevId: 928482603
Change-Id: I5eda1307bc6e71a4b0b2933b5b941e945cb9de75
2026-06-08 04:29:27 -07:00
Haroon Qureshi b17b5f7918 Expose mjv_flexBodyIdAndPoint as a helper function.
Use the above in studio rather than a custom implementation.

PiperOrigin-RevId: 928432476
Change-Id: I99d772c4baf7260abbf9ac8f6d8032704f1ba769
2026-06-08 02:28:39 -07:00
Haroon Qureshi 0093210173 Remove hard-coded render target formats.
The formats are defined in the config.

PiperOrigin-RevId: 928412818
Change-Id: I20ea72214d8e1484723793d8a3f89cdcb4b617b1
2026-06-08 01:45:24 -07:00
Haroon Qureshi 511cf27ff8 Move segmentation coloring logic into renderer.
PiperOrigin-RevId: 927300828
Change-Id: I994c5742ec30993d2245df167042e72820f91ac7
2026-06-05 07:57:59 -07:00
Haroon Qureshi 8fbacf2883 Introduce MaterialManager to allow sharing of material instances.
PiperOrigin-RevId: 927139826
Change-Id: I923a24f28ab7af3a8c854286f064e851b9fd494e
2026-06-05 01:17:37 -07:00
Haroon Qureshi 53ac994759 Add missing files.
PiperOrigin-RevId: 926123240
Change-Id: I59b9baaa106ef12a9bf3c7a6399558753c2c5415
2026-06-03 10:27:41 -07:00
Google DeepMind 36f5c4899c Remove the usage of Texture::setImage that uses FaceOffsets
PiperOrigin-RevId: 926092842
Change-Id: I8010804c6dda89d41ebaf650af776505e5c5ed34
2026-06-03 09:47:37 -07:00
Haroon Qureshi 4d70b18048 Manage reflections at the scene level.
Renderables may be created/destroyed frequently causing issues with
the underlying RenderTargets used for reflections. Instead, use a
ReflectionManager (associated with a Scene) to manage the RenderTargets.

PiperOrigin-RevId: 926072766
Change-Id: I56c70000183417a92ab9297bc6fec5779f484cbd
2026-06-03 09:18:32 -07:00
Kevin Zakka 25afa6b732 Fix wasm OOM on large models: 32mb stack, raise MAXIMUM_MEMORY to 4gb.
PiperOrigin-RevId: 926060014
Change-Id: I8c4e152321737b1f4cc963f3c6c424af2fe951b4
2026-06-03 08:59:05 -07:00
Kevin Zakka 0897e3aec1 Skip the prefetcher when the URL scheme isn't fetchable.
Drag-and-drop uploads go through Module.loadFile and never reached the prefetcher. This is a guard for future provider schemes (e.g., vfs) that shouldn't be passed to fetch().

PiperOrigin-RevId: 926042158
Change-Id: I119d5b1a7512f8e84bb4c752414797593a1e98cd
2026-06-03 08:23:19 -07:00
Haroon Qureshi 4cfdf5f34b Bind materials before rendering reflection passes.
PiperOrigin-RevId: 925911124
Change-Id: I134d29424233ccbf57f56e7379e8830662a57836
2026-06-03 03:31:03 -07:00
Haroon Qureshi 0fe2064847 Cleanup Renderable API.
Add function for getting the material. Remove unused/unneeded functions.

PiperOrigin-RevId: 925847769
Change-Id: Iefaf9112b7419830eb2dc4d1323e9c27725c4b16
2026-06-03 01:06:21 -07:00
Matija Kecman 0e4749501c Allow custom step function in StepControl::Advance.
The StepControl::Advance method now accepts an optional std::function to be used instead of mj_step. This allows for custom simulation logic to be executed within the stepping loop. The Python bindings for StepControl::advance have been updated to support passing a Python callable as the custom step function.

PiperOrigin-RevId: 925393132
Change-Id: Id2820c4b55cbdfee6b01adc2395e99a990d4e7a3
2026-06-02 09:20:06 -07:00
Copybara-Service 15cbc8fb55 Merge pull request #3156 from andrewkaufman:newton-schemas
PiperOrigin-RevId: 925328794
Change-Id: If45b8659ea9b88785660331bca5ee837ac172f67
2026-06-02 07:06:59 -07:00
Yuval Tassa d7e872b6f9 Add UI control for MuJoCo threadpool size.
PiperOrigin-RevId: 923860258
Change-Id: I11dc5d7904f1c3657d7e1dd2b0e3c7864c0c7ead
2026-05-30 03:41:38 -07:00
Haroon Qureshi f63b92da5e Clear draw queue instead of failing if rendering skipped.
PiperOrigin-RevId: 923420183
Change-Id: I34aac76810a7bf0e4a0394ebe27b45a8fc32f110
2026-05-29 08:09:15 -07:00
Copybara-Service f755d718d3 Merge pull request #3293 from kevinzakka:studio-live-parallel-prefetch
PiperOrigin-RevId: 922417778
Change-Id: Ia839747c4af0e705962308dc84e9a7c3926fc910
2026-05-27 16:47:18 -07:00
Haroon Qureshi 36ea0c466f Support multiscene, multiview rendering.
Update Renderable so that it can switch its own draw states (material
instance, shadow casting, reflection textures, etc.) per render request.
This allows us to use the same Renderable with different effects from
different views within the same frame.

PiperOrigin-RevId: 922102817
Change-Id: I1cf02fddb7a00345a741db1bee88e716517765f4
2026-05-27 06:54:58 -07:00
Matija Kecman c0b8aa9dec Make studio python more like studio C++
- C++ Platform UX: Added a "Copy Camera" button to copy XML camera definitions to clipboard.
  - C++ Platform UX: Extracted `SetSpeedIndex` and `GetExpectedLabelWidth` into reusable platform helpers.
  - C++ Platform UX: Fixed combo box widths and removed auto-hide tab bar flag from dockspace.
  - C++ Studio App: Deduplicated label width and speed index logic by adopting platform helpers.
  - C++ Studio App: Updated the toolbar layout to use a 2-column table.
  - Python Bindings: Added pybind definitions for `set_camera_index`, `set_speed_index`, and `camera_to_string`.
  - Python Studio App: Aligned toolbar UI with C++ using a 2-column table and fixed immediate theme switching.
  - Python Studio App: Added a Help menu displaying the MuJoCo version and Stats toggle.
  - Python Events: Added `-`/`=` shortcuts for simulation speed and `Esc`/`[`/`]` shortcuts for camera selection.

PiperOrigin-RevId: 922097319
Change-Id: Iec74afe37bf5c7a1ebf1cab4141e47fff5fe9274
2026-05-27 06:42:59 -07:00
Kevin Zakka 249e9c08b8 MuJoCo Live: pre-fetch model assets in parallel before compilation.
The prefetcher asks mju_getXMLDependencies for the transitive asset
list, fetches every URL with Promise.all, and primes the bytes into the
WASM-side FetchCache. When the compiler runs, every resource it opens
is already in memory. Cold-load on a typical Menagerie model drops from
~9 s to ~2 s.
2026-05-26 16:01:48 -07:00
Yuval Tassa 393c1e4217 Migrate mjtByte to mjtBool for boolean-valued fields.
PiperOrigin-RevId: 921408093
Change-Id: Icb00457836359779f0f72fc02d6a7c0dc9f6bd23
2026-05-26 05:35:49 -07:00
Baruch Tabanpour 466d068089 MuJoCo Studio: Support Ctrl+Option+Left Click Drag for perturbation
Support Ctrl+Option+Left Click Drag (maps to Ctrl+Alt+Left Click Drag in the application) to apply point force perturbations (translation) on the robot in the WebGL live viewer. This matches the Mac experience in the native MuJoCo simulate app and provides a fallback for Mac users where Right Click is difficult to trigger.

PiperOrigin-RevId: 919767954
Change-Id: I4a1d1c05784a8257d13f64f738af5b4841a615b3
2026-05-22 11:14:46 -07:00
Saran Tunyasuvunakool 5c21c8d28b Minor restyling of the loading screen.
PiperOrigin-RevId: 919744412
Change-Id: I3e4aa0b59d100ac85e8f915d7d733b2b3ea1ecea
2026-05-22 10:26:04 -07:00
Yuval Tassa ab0e0091d5 Standardize "DO NOT EDIT" comments in generated files.
PiperOrigin-RevId: 919718422
Change-Id: I2cba07d75d37d45f3f30b23d049c944b080248ad
2026-05-22 09:34:45 -07:00
Haroon Qureshi 8ae51e104d Move DrawTextAt from imgui_bridge to imgui_widgets.
PiperOrigin-RevId: 919508805
Change-Id: Ie311b88164d8c2ff7a8452ec2f1b8be7e7d9770e
2026-05-22 00:52:54 -07:00
Haroon Qureshi 3499adacae Store skin and flex meshes separately.
PiperOrigin-RevId: 919490079
Change-Id: I45473ee59e22465732fb4b470a94c2944fed9c37
2026-05-22 00:09:49 -07:00
Haroon Qureshi 88b8b58429 Add support for transparent PBR materials.
PiperOrigin-RevId: 919477028
Change-Id: I75cc311fc73dd5fe26b72ba8d49fd421fda455e3
2026-05-21 23:35:53 -07:00
Baruch Tabanpour 5b73846a1e Upgrade MuJoCo Live loading screen
PiperOrigin-RevId: 919112273
Change-Id: I0ffdf908e32d4197e007ebcc2d9f5136b59cf6b3
2026-05-21 10:03:40 -07:00
Matija Kecman 585be6cee5 Fix wireframe rendering
PiperOrigin-RevId: 919100432
Change-Id: I2931d793ab9639bdaaad11f6d77a77aa14e43b8a
2026-05-21 09:41:59 -07:00
Saran Tunyasuvunakool 7c47a89cd0 Add asset file download indicator to the loading screen.
This provides visual feedback to the user while loading large models.

PiperOrigin-RevId: 918708877
Change-Id: I77ea475cce6d9718e6cf8b33cb72b3f524a6ee63
2026-05-20 16:26:40 -07:00
Haroon Qureshi 53b3137a12 Separate Light management into a separate class.
PiperOrigin-RevId: 918508291
Change-Id: I9cadc1b612006a0450f8a2fd9088d56cc2e610a3
2026-05-20 10:01:15 -07:00
Haroon Qureshi 57d2c49316 Track size/scale separately for renderables.
PiperOrigin-RevId: 918476985
Change-Id: I414b1abe2f9b3a3a7549ab5195971127d5598c36
2026-05-20 08:54:28 -07:00