BlenderXR #57158

Closed
opened 2018-10-11 06:23:07 +02:00 by Max Krichenbauer · 14 comments

Dear Blender Team,

First of all, please excuse our slow and clumsy navigation of proposing code. This is our first time to do so.

We're the developers of MARUI-Plug-In, a popular VR/AR/XR user interface for Autodesk Maya
( https://www.marui-plugin.com )
over the years, we have been repeatedly asked by Blender users to make a similar plug-in for Blender.
We'd be happy to do so, but rather than a clumsy plug-in we'd like to make the UI free and open for everyone to use.
Therefore, we have created BlenderXR - a simple abstraction layer that allows using common current VR headsets.
https://github.com/MARUI-PlugIn/BlenderXR/
This is a temporary work-around to start working on the user interface until OpenXR will become available - then we propose switching to OpenXR and abandoning BlenderXR.
The complete user interface functionality is inside the Blender code base and can be retained.
Including BlenderXR is not required. It is an optional addition for users who want to use Blender in VR/AR/XR.

The attached patch was created based on to the blender2.8 branch,
commit fd2ffb0b9e of 2018-10-11 10:24:38.

blenderxr_2018-10-11.diff

Please let us know your opinion.
We hope we can continue contributing and provide a complete and powerful VR user interface, similar to what MARUI is for Maya.

Best regards,
Max

Dear Blender Team, First of all, please excuse our slow and clumsy navigation of proposing code. This is our first time to do so. We're the developers of MARUI-Plug-In, a popular VR/AR/XR user interface for Autodesk Maya ( https://www.marui-plugin.com ) over the years, we have been repeatedly asked by Blender users to make a similar plug-in for Blender. We'd be happy to do so, but rather than a clumsy plug-in we'd like to make the UI free and open for everyone to use. Therefore, we have created BlenderXR - a simple abstraction layer that allows using common current VR headsets. https://github.com/MARUI-PlugIn/BlenderXR/ This is a temporary work-around to start working on the user interface until OpenXR will become available - then we propose switching to OpenXR and abandoning BlenderXR. The complete user interface functionality is inside the Blender code base and can be retained. Including BlenderXR is not required. It is an optional addition for users who want to use Blender in VR/AR/XR. The attached patch was created based on to the blender2.8 branch, commit fd2ffb0b9e674a5edefa159d086d6a64edb3abe5 of 2018-10-11 10:24:38. [blenderxr_2018-10-11.diff](https://archive.blender.org/developer/F5020691/blenderxr_2018-10-11.diff) Please let us know your opinion. We hope we can continue contributing and provide a complete and powerful VR user interface, similar to what MARUI is for Maya. Best regards, Max

Added subscriber: @makx

Added subscriber: @makx
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Hi Max,

thanx for your efforts! These are much appreciated.
Could you create a Differntial here: https://developer.blender.org/differential/diff/create/ ?

This will make review much easier.

Hi Max, thanx for your efforts! These are much appreciated. Could you create a Differntial here: https://developer.blender.org/differential/diff/create/ ? This will make review much easier.
Member

Added subscriber: @LazyDodo

Added subscriber: @LazyDodo
Member

Give it is based on 2.8, may i recommend uploading the diff with arc ?

Give it is based on 2.8, may i recommend uploading the diff with [arc ](https://en.blender.org/index.php/Dev:Doc/Tools/Code_Review#Use_Arcanist)?

@lichtwerk
Thank you!
I have selected "Create a Patch Task" because I thought the description fitted our patch better.
Now I also tried to create a diff but I'm getting the error
"Uploaded file is too large: current limit is 8M. To adjust this limit change 'upload_max_filesize' in php.ini."

@LazyDodo
Thank you! I didn't know about arc before. I'll look into it.

I'd also like to add a quick description of the proposal:

BlenderXR Developer Proposal

List of Modified Files:


wm_window.c
  wm_window_close()
    line 538: Uninitialize VR and unload the VR shared library functions when the
      VR mirror window is closed.
  NEW FUNCTION: wm_window_new_vr_exec()
    line 1016: Create a new VR mirror window. The VR mirror window is a "main" BlenderXR
      window that contains the VR viewports used for blitting the HMD. When this function
      is called from clicking on the "Window->New VR Window" menu option in the Blender
      editor, the current window context is copied into a new window and an attempt is
      made to load the VR shared library functions and initialize VR. If successful,
      the window is created and left as-is, otherwise the window is immediately closed.
  wm_window_process_events()
    line 1676: If the VR mirror window exists (VR is running), don't sleep the
      main thread when there are no window events (normally sleeps 5 ms).
      This is done to improve VR performance.

wm_draw.c
  wm_draw_region_stereo_set()
    line 147: Hide some viewport 2D overlays (text, cursor, etc.) because they are distracting
      and additional modifications would be necessary to render them properly in VR.
  wm_draw_region_buffer_free()
      line 282: Prevent the VR viewports and offscreen buffers from being undesirably freed
        on window resize events, window stereo changes, etc. as VR rendering does not depend
        on window size and other related settings.
  wm_draw_window_offscreen()
    line 545: Create VR offscreen buffers and viewports if necessary and draw to the VR
      viewports / render targets. This is also where VR tracking information is updated
      and VR interaction with the Blender scene is performed.
  wm_draw_window_onscreen()
    line 645: Blit the HMD from the VR viewports and also blit the VR mirror window.
  wm_draw_update()
    line 877: Always update (redraw) the VR mirror window that contains the VR viewports.
      This is done to ensure that the VR eye textures are continuously updated.

draw_manager.c
  DRW_draw_view()
    line 1490: VR pre-scene render (for setting up view and projection matrices for each eye).
      Must be called before drw_engines_draw_background();
    line 1525: VR post-scene render (for drawing VR controllers and UI elements).
      Must be called after ED_region_draw_cb_draw() and should be called before drw_engines_draw_scene();

view3d_utils.c
  ED_view3d_viewplane_get()
    line 157: Compute the VR camera viewplane / parameters for each eye.

view3d_view.c
  void view3d_viewmatrix_set()
    line 810: Compute the VR view matrix for each eye.

DNA_view3d_types.h
  line 327: Added a new RegionView3D rflag definition (RV3D_IS_VR) to identify if a given
    viewport is a VR viewport.


GPU_viewport.h (gpu_viewport.c)
  line 57: Moved the "GPUViewport" struct definition from its previous location in gpu_viewport.c.
    This is done to access the framebuffers corresponding to the VR viewports when blitting the HMD.

GPU_framebuffer.h (gpu_framebuffer.c)
  line 54: Moved the "GPUAttachmentType" enum and "GPUFrameBuffer" struct definitions
    from their previous locations in gpu_framebuffer.c. This is done to access the
    OpenGL textures for the VR viewports when blitting the HMD.

GPU_texture.h (gpu_texture.c)
  line 171: Moved the "GPUTexture" struct definition from its previous location in gpu_texture.c
    This is done to access the OpenGL texture bind codes for the VR viewports when blitting the HMD.


gpu_context.cpp
  line 159: Temporarily removed a "DEBUG" assertion.

gpu_immediate.c
  line 47: Temporarily turned off "TRUST_NO_ONE" assertions.


GPU_immediate.h
  line 37: Added "#ifdef __cplusplus" brackets to allow being included by VR .cpp files
    for GPU rendering.

GPU_state.h
  line 31: Added "#ifdef __cplusplus" brackets to allow being included by VR .cpp files
    for GPU rendering.

GPU_vertex_format.h
  line 31: Added "#ifdef __cplusplus" brackets to allow being included by VR .cpp files
    for GPU rendering.

BKE_gpencil.h
  line 31: Added "#ifdef __cplusplus" brackets to allow being included by VR .cpp files
    for the VR gpencil annotation widget.

gpencil_intern.h
  line 31: Added "#ifdef __cplusplus" brackets to allow being included by VR .cpp files
    for the VR gpencil annotation widget.


Descriptions of Blender VR module (bf_vr) files:

vr_build.h
  This is a temporary "build header" used to toggle VR modifications and aid in debugging.

vr_main.h
  Contains the definition for the "VR" struct, which holds all VR device, tracking,
    and status information.

vr_main.c
  The main VR module. Handles VR initialization/un-initialization and loading/unloading
    of external VR shared libraries.

vr_api.h
  Serves as an internal "export" header for sending VR UI C++ functions to vr_main.c
    and other C areas of Blender that may want to access these functions.


vr_types.h
  Contains macro, enum, and struct definitions used internally by the bf_vr module.

vr_draw.h (vr_draw.cpp)
  Contains OpenGL-related utility functions for drawing VR UI elements.

vr_math.h (vr_math.cpp)
  Contains math-related utility functions relevant to VR.

vr_ui.h (vr_ui.cpp)
  The VR user interface module. Controls VR navigation, interaction, and drawing of
    VR UI elements.

vr_widget.h (vr_widget.cpp)
  Base module for the VR UI widget system. Contains implementations for the VR widgets
    that interact with the Blender scene (for example, navigation, selection, and annotation).

vr_widget_layout.h (vr_widget_layout.cpp)
  Contains definitions for device-unified button identifiers as well as default device-specific
    widget-to-button mappings.

I hope this makes things more clear.

@lichtwerk Thank you! I have selected "Create a Patch Task" because I thought the description fitted our patch better. Now I also tried to create a diff but I'm getting the error "Uploaded file is too large: current limit is 8M. To adjust this limit change 'upload_max_filesize' in php.ini." @LazyDodo Thank you! I didn't know about arc before. I'll look into it. I'd also like to add a quick description of the proposal: ``` BlenderXR Developer Proposal List of Modified Files: wm_window.c wm_window_close() line 538: Uninitialize VR and unload the VR shared library functions when the VR mirror window is closed. NEW FUNCTION: wm_window_new_vr_exec() line 1016: Create a new VR mirror window. The VR mirror window is a "main" BlenderXR window that contains the VR viewports used for blitting the HMD. When this function is called from clicking on the "Window->New VR Window" menu option in the Blender editor, the current window context is copied into a new window and an attempt is made to load the VR shared library functions and initialize VR. If successful, the window is created and left as-is, otherwise the window is immediately closed. wm_window_process_events() line 1676: If the VR mirror window exists (VR is running), don't sleep the main thread when there are no window events (normally sleeps 5 ms). This is done to improve VR performance. wm_draw.c wm_draw_region_stereo_set() line 147: Hide some viewport 2D overlays (text, cursor, etc.) because they are distracting and additional modifications would be necessary to render them properly in VR. wm_draw_region_buffer_free() line 282: Prevent the VR viewports and offscreen buffers from being undesirably freed on window resize events, window stereo changes, etc. as VR rendering does not depend on window size and other related settings. wm_draw_window_offscreen() line 545: Create VR offscreen buffers and viewports if necessary and draw to the VR viewports / render targets. This is also where VR tracking information is updated and VR interaction with the Blender scene is performed. wm_draw_window_onscreen() line 645: Blit the HMD from the VR viewports and also blit the VR mirror window. wm_draw_update() line 877: Always update (redraw) the VR mirror window that contains the VR viewports. This is done to ensure that the VR eye textures are continuously updated. draw_manager.c DRW_draw_view() line 1490: VR pre-scene render (for setting up view and projection matrices for each eye). Must be called before drw_engines_draw_background(); line 1525: VR post-scene render (for drawing VR controllers and UI elements). Must be called after ED_region_draw_cb_draw() and should be called before drw_engines_draw_scene(); view3d_utils.c ED_view3d_viewplane_get() line 157: Compute the VR camera viewplane / parameters for each eye. view3d_view.c void view3d_viewmatrix_set() line 810: Compute the VR view matrix for each eye. DNA_view3d_types.h line 327: Added a new RegionView3D rflag definition (RV3D_IS_VR) to identify if a given viewport is a VR viewport. GPU_viewport.h (gpu_viewport.c) line 57: Moved the "GPUViewport" struct definition from its previous location in gpu_viewport.c. This is done to access the framebuffers corresponding to the VR viewports when blitting the HMD. GPU_framebuffer.h (gpu_framebuffer.c) line 54: Moved the "GPUAttachmentType" enum and "GPUFrameBuffer" struct definitions from their previous locations in gpu_framebuffer.c. This is done to access the OpenGL textures for the VR viewports when blitting the HMD. GPU_texture.h (gpu_texture.c) line 171: Moved the "GPUTexture" struct definition from its previous location in gpu_texture.c This is done to access the OpenGL texture bind codes for the VR viewports when blitting the HMD. gpu_context.cpp line 159: Temporarily removed a "DEBUG" assertion. gpu_immediate.c line 47: Temporarily turned off "TRUST_NO_ONE" assertions. GPU_immediate.h line 37: Added "#ifdef __cplusplus" brackets to allow being included by VR .cpp files for GPU rendering. GPU_state.h line 31: Added "#ifdef __cplusplus" brackets to allow being included by VR .cpp files for GPU rendering. GPU_vertex_format.h line 31: Added "#ifdef __cplusplus" brackets to allow being included by VR .cpp files for GPU rendering. BKE_gpencil.h line 31: Added "#ifdef __cplusplus" brackets to allow being included by VR .cpp files for the VR gpencil annotation widget. gpencil_intern.h line 31: Added "#ifdef __cplusplus" brackets to allow being included by VR .cpp files for the VR gpencil annotation widget. Descriptions of Blender VR module (bf_vr) files: vr_build.h This is a temporary "build header" used to toggle VR modifications and aid in debugging. vr_main.h Contains the definition for the "VR" struct, which holds all VR device, tracking, and status information. vr_main.c The main VR module. Handles VR initialization/un-initialization and loading/unloading of external VR shared libraries. vr_api.h Serves as an internal "export" header for sending VR UI C++ functions to vr_main.c and other C areas of Blender that may want to access these functions. vr_types.h Contains macro, enum, and struct definitions used internally by the bf_vr module. vr_draw.h (vr_draw.cpp) Contains OpenGL-related utility functions for drawing VR UI elements. vr_math.h (vr_math.cpp) Contains math-related utility functions relevant to VR. vr_ui.h (vr_ui.cpp) The VR user interface module. Controls VR navigation, interaction, and drawing of VR UI elements. vr_widget.h (vr_widget.cpp) Base module for the VR UI widget system. Contains implementations for the VR widgets that interact with the Blender scene (for example, navigation, selection, and annotation). vr_widget_layout.h (vr_widget_layout.cpp) Contains definitions for device-unified button identifiers as well as default device-specific widget-to-button mappings. ``` I hope this makes things more clear.

Added subscriber: @pepe-school-land

Added subscriber: @pepe-school-land

HI Max!

I´m Daniel Martinez Lara, one of the members of Grease Pencil Team: Thanks so much for share this, I know that is just a basic implementation but great see the potential of Grease Pencil and VR, I made this video just to test it https://www.facebook.com/pepeland3D/videos/253025238744831/?t=44

Daniel

HI Max! I´m Daniel Martinez Lara, one of the members of Grease Pencil Team: Thanks so much for share this, I know that is just a basic implementation but great see the potential of Grease Pencil and VR, I made this video just to test it https://www.facebook.com/pepeland3D/videos/253025238744831/?t=44 Daniel

@pepe-school-land
Hi Daniel!
Thank you so much for your message and video!
I just shard it with the team - we're all happy and honored you enjoyed drawing in VR.
Also thank you so much for the awesome Grease Pencil feature!
By the way: you can also erase lines by holding the "SHIFT" button on your controller (the "A" button on the right controller) and the trigger button at the same time.

Best regards,
Max

@pepe-school-land Hi Daniel! Thank you so much for your message and video! I just shard it with the team - we're all happy and honored you enjoyed drawing in VR. Also thank you so much for the awesome Grease Pencil feature! By the way: you can also erase lines by holding the "SHIFT" button on your controller (the "A" button on the right controller) and the trigger button at the same time. Best regards, Max

Added subscriber: @nokipaike

Added subscriber: @nokipaike

@pepe-school-land whoaaa coool video!
@makx big surprise! thank you!

@pepe-school-land whoaaa coool video! @makx big surprise! thank you!

Added subscriber: @dfelinto

Added subscriber: @dfelinto

Changed status from 'Confirmed' to: 'Archived'

Changed status from 'Confirmed' to: 'Archived'
Dalai Felinto self-assigned this 2019-12-23 18:39:34 +01:00

Hi, thanks for your patch.

We are undergoing a Tracker Curfew where we are automatically closing old patches.

If you think the patch is still relevant please update and re-submit it. For new features make sure there is a clear design from the user level perspective.

Hi, thanks for your patch. We are undergoing a [Tracker Curfew ](https://code.blender.org/?p=3861) where we are automatically closing old patches. If you think the patch is still relevant please update and re-submit it. For new features make sure there is a clear design from the user level perspective.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#57158
No description provided.