Commit Graph

92 Commits

Author SHA1 Message Date
Julian Eisel dc2df8307f VR: Initial Virtual Reality support - Milestone 1, Scene Inspection
NOTE: While most of the milestone 1 goals are there, a few smaller features and
improvements are still to be done.

Big picture of this milestone: Initial, OpenXR-based virtual reality support
for users and foundation for advanced use cases.
Maniphest Task: https://developer.blender.org/T71347
The tasks contains more information about this milestone.

To be clear: This is not a feature rich VR implementation, it's focused on the
initial scene inspection use case. We intentionally focused on that, further
features like controller support are part of the next milestone.

- How to use?
Instructions on how to use this are here:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/How_to_Test
These will be updated and moved to a more official place (likely the manual) soon.

Currently Windows Mixed Reality and Oculus devices are usable. Valve/HTC
headsets don't support the OpenXR standard yet and hence, do not work with this
implementation.

---------------

This is the C-side implementation of the features added for initial VR
support as per milestone 1. A "VR Scene Inspection" Add-on will be
committed separately, to expose the VR functionality in the UI. It also
adds some further features for milestone 1, namely a landmarking system
(stored view locations in the VR space)

Main additions/features:
* Support for rendering viewports to an HMD, with good performance.
* Option to sync the VR view perspective with a fully interactive,
  regular 3D View (VR-Mirror).
* Option to disable positional tracking. Keeps the current position (calculated
  based on the VR eye center pose) when enabled while a VR session is running.
* Some regular viewport settings for the VR view
* RNA/Python-API to query and set VR session state information.
* WM-XR: Layer tying Ghost-XR to the Blender specific APIs/data
* wmSurface API: drawable, non-window container (manages Ghost-OpenGL and GPU
  context)
* DNA/RNA for management of VR session settings
* `--debug-xr` and `--debug-xr-time` commandline options
* Utility batch & config file for using the Oculus runtime on Windows.
* Most VR data is runtime only. The exception is user settings which are saved
  to files (`XrSessionSettings`).
* VR support can be disabled through the `WITH_XR_OPENXR` compiler flag.

For architecture and code documentation, see
https://wiki.blender.org/wiki/Source/Interface/XR.

---------------

A few thank you's:
* A huge shoutout to Ray Molenkamp for his help during the project - it would
  have not been that successful without him!
* Sebastian Koenig and Simeon Conzendorf for testing and feedback!
* The reviewers, especially Brecht Van Lommel!
* Dalai Felinto for pushing and managing me to get this done ;)
* The OpenXR working group for providing an open standard. I think we're the
  first bigger application to adopt OpenXR. Congratulations to them and
  ourselves :)

This project started as a Google Summer of Code 2019 project - "Core Support of
Virtual Reality Headsets through OpenXR" (see
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/).
Some further information, including ideas for further improvements can be found
in the final GSoC report:
https://wiki.blender.org/wiki/User:Severin/GSoC-2019/Final_Report

Differential Revisions: D6193, D7098

Reviewed by: Brecht Van Lommel, Jeroen Bakker
2020-03-17 21:42:44 +01:00
Antonio Vazquez 29f3af9527 GPencil: Refactor of Draw Engine, Vertex Paint and all internal functions
This commit is a full refactor of the grease pencil modules including Draw Engine, Modifiers, VFX, depsgraph update, improvements in operators and conversion of Sculpt and Weight paint tools to real brushes.

Also, a huge code cleanup has been done at all levels.

Thanks to @fclem for his work and yo @pepeland and @mendio for the testing and help in the development.

Differential Revision: https://developer.blender.org/D6293
2020-03-09 16:27:24 +01:00
Julian Eisel b2ee1770d4 Cleanup: Rename ARegion variables from ar to region
The old convention was easy to confuse with ScrArea.
Part of https://developer.blender.org/T74432.

This is mostly a batch rename with some manual fixing. Only single word
variable names are changed, no prefixed/suffixed names.

Brecht van Lommel and Campbell Barton both gave me a green light for
this convention change.

Also ran clan clang format on affected files.
2020-03-06 17:19:23 +01:00
Jeroen Bakker ae3263e525 DrawEngine: Clean up
Put DefaultFramebufferList and DefaultTextureList into an own header
file. These structs were private, but also used by the window manager
and gpu package. The previous implementation we needed to keep these
structs in sync.
2020-02-25 07:47:35 +01:00
Clément Foucault 804e90b42d DRW: Color Management improvement
Reviewed By: brecht sergey jbakker

Differential Revision: http://developer.blender.org/D6729
2020-02-11 15:19:04 +01:00
Jeroen Bakker 7878adf49c DrawManager: Disable Clipping in material/rendered mode
Viewport: Disable Clipping For EEVEE and External Renderers

Currently it is possible that, when using viewport clipping, the display and tools communicate
different information to the user then the renderer does. The reason is
that the renderer does not support viewport clipping. Both EEVEE and
Cycles do not support it.

This patch will disable the clipping in all the tools and drawing code
when the viewport drawing mode is `Material Preview` or `Rendered`.

This patch introduces a `RV3D_CLIPPING_ENABLED` util that checks if
clipping is enabled for the given `rv3d` and `v3d`. Also in places where
it was needed we added the `ViewContext` as a carrier for the `View3D`
and `RegionView3D`.

There are a few areas in the tooling (select, projection painting) that
still needs to be tackled after this patch.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D6047
2019-12-11 16:58:14 +01:00
Clément Foucault 9516921c05 Overlay Engine: Refactor & Cleanup
This is the unification of all overlays into one overlay engine as described in T65347.

I went over all the code making it more future proof with less hacks and removing old / not relevent parts.

Goals / Acheivements:
- Remove internal shader usage (only drw shaders)
- Remove viewportSize and viewportSizeInv and put them in gloabl ubo
- Fixed some drawing issues: Missing probe option and Missing Alt+B clipping of some shader
- Remove old (legacy) shaders dependancy (not using view UBO).
- Less shader variation (less compilation time at first load and less patching needed for vulkan)
- removed some geom shaders when I could
- Remove static e_data (except shaders storage where it is OK)
- Clear the way to fix some anoying limitations (dithered transparency, background image compositing etc...)
- Wireframe drawing now uses the same batching capabilities as workbench & eevee (indirect drawing).
- Reduced complexity, removed ~3000 Lines of code in draw (also removed a lot of unused shader in GPU).
- Post AA to avoid complexity and cost of MSAA.

Remaining issues:
- ~~Armature edits, overlay toggles, (... others?) are not refreshing viewport after AA is complete~~
- FXAA is not the best for wires, maybe investigate SMAA
- Maybe do something more temporally stable for AA.
- ~~Paint overlays are not working with AA.~~
- ~~infront objects are difficult to select.~~
- ~~the infront wires sometimes goes through they solid counterpart (missing clear maybe?) (toggle overlays on-off when using infront+wireframe overlay in solid shading)~~

Note: I made some decision to change slightly the appearance of some objects to simplify their drawing. Namely the empty arrows end (which is now hollow/wire) and distance points of the cameras/spots being done by lines.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D6296
2019-12-02 13:15:52 +01:00
Sergey Sharybin fc2b966fc7 Refactor: Add C++ guard code to headers
C++ is used more and more, and it is becoming more and more annoying to
keep track of whether header have C++ guard or not.

Is easier and more clear to be consistent in all headers and have such
guards in all headers.
2019-11-29 14:39:54 +01:00
Campbell Barton 6eadd40597 Cleanup: redundant struct declarations 2019-08-25 16:45:47 +10:00
Campbell Barton 66bd96e0bb Cleanup: remove gawain reference 2019-08-17 01:17:30 +10:00
mano-wii 4d320f4313 Edit Mesh Selection: Refactor: Redraw idmap buffer at runtime with only objects inside the rect
But in the future the selection code may also be used in object mode (eg for snapping).
So to avoid using too much VRAM resources, it is good to avoid drawing all objects in the viewport.

The solution was to create an array with only objects that are detected within the selection area.
If the selection operator is modal, objects already detected are not removed from the array until view3d is moved or orbited.
To detect the object, its BoundBox is tested.
Since the Select Engine does not have a dedicated depth texture, whenever a new object is "found" the depth of the objects in the array already drawn is redrawn.

Reviewers: campbellbarton, fclem

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D5435
2019-08-15 10:31:54 -03:00
mano-wii 764cc75e1f Edit Mesh Selection: Move ED_view3d_select_ functions to bf_draw
It is easier to deal with private values of the DRW_select engine and gives room for improvement.

Reviewers: campbellbarton, fclem

Differential Revision: https://developer.blender.org/D5415
2019-08-07 12:43:31 -03:00
mano-wii 9d7d34c12a Select utils refactor: remove lagacy `ED_view3d_select_id_read_rect`
`ED_view3d_select_id_read_rect` serves only as a bridge to `DRW_framebuffer_select_id_read`.
Keeping these codes similar only increases the complexity of some functions.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D5415
2019-08-07 12:43:31 -03:00
Campbell Barton 0c7a4c74d3 Cleanup: clang-format, also typo fix. 2019-08-02 20:04:45 +10:00
mano-wii 421280a3f7 Cleanup: remove unused member 2019-07-31 22:46:41 -03:00
Campbell Barton b9718299ea Fix crash clicking in the 3D view on startup
Setting the 3D view cursor on startup could crash because the
viewport hasn't been assigned to the region.
2019-07-30 21:43:40 +10:00
mano-wii 651d8bfd98 3D View: Move selection API to a Selection engine.
This commit moves the API of selecting faces, vertices and edges to a DRW manager engine.

Reviewers: campbellbarton, fclem

Subscribers: jbakker, brecht

Differential Revision: https://developer.blender.org/D5090
2019-07-30 06:46:59 -03:00
mano-wii 8a6414ed46 Fix T54686: objects don't occlude each other for edit-mesh select 2019-05-16 09:36:15 +10:00
Clément Foucault 60aede44ba Cleanup: DRW: Remove DRW_pass_free 2019-05-09 01:08:17 +02:00
Campbell Barton 44ca116ca2 Cleanup: formatting, unused args 2019-04-20 09:15:06 +02:00
mano-wii 8f4ba1c046 Fix T63669: Particle editing bypassing occlusion.
The problem occurs because status changes between BackBuffer and Offscreen.

Reviewers: fclem

Differential Revision: https://developer.blender.org/D4703
2019-04-19 11:49:17 -03:00
Clément Foucault 223f7e79f9 DRW: Add batch garbage collection
This is only working for shading batches for the moment and only if some Custom data layer are not needed anymore.

The collection rate is hardcoded at 60 sec but could be exposed to the user.

This system can be extended and discard most unused batches in the future.

This commit is in prevision of removing BKE_MESH_BATCH_DIRTY_SHADING when changing shader parameters.
2019-04-19 15:19:43 +02:00
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Clément Foucault 4d71b655ec GPU: Fix color difference when rendering to gpu_py_offscreen
Now we do the color management inside the Draw manager and output CM byte
buffer.
2019-03-28 22:38:55 +01:00
mano-wii 27b73f0c5b GPencil: Remove legacy `ED_gpencil_draw_view3d` code.
Differential Revision: https://developer.blender.org/D4598
2019-03-27 10:53:15 -03:00
mano-wii 6e3331990f DRW manager: Use existing viewport instead of creating a viewport in DRW_draw_depth_loop. 2019-03-26 12:29:12 -03:00
Jeroen Bakker 33a759a39c Revert "DRW Manager: create and use new DRW_framebuffer_depth_read utility."
This reverts commit 40f8f445a3.

There are many paths that lead to uninitialized depth buffer where the
depth read would fail.

Fix T62965
2019-03-26 15:07:05 +01:00
mano-wii 40f8f445a3 DRW Manager: create and use new DRW_framebuffer_depth_read utility. 2019-03-22 13:08:03 -03:00
mano-wii 681661dbed GPU: Simplify select shaders.
The shaders are: `GPU_SHADER_3D_FLAT_SELECT_ID` and `GPU_SHADER_3D_UNIFORM_SELECT_ID`.
This commit allows the drawing of the mesh select ids to be done on a 32UI format texture.
This simplifies the shader that previously acted on the backbuffer and had to do an uint to rgba conversion.

Differential Revision: https://developer.blender.org/D4350
2019-03-15 17:02:48 -03:00
Campbell Barton de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton 65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Campbell Barton 66e6cd5315 Cleanup: unused struct declarations 2019-01-28 22:06:53 +11:00
Campbell Barton c0f88ed8a8 Cleanup: sort forward declarations of enum & struct
Done using:
  source/tools/utils_maintenance/c_sort_blocks.py
2019-01-28 21:17:58 +11:00
Campbell Barton dc3b5024be Cleanup: add BEGIN/END to GPL headers 2019-01-23 11:32:43 +11:00
Sergey Sharybin 1ed31bef1a Draw manager: Expose grease pencil helper function 2018-11-09 17:53:02 +01:00
Brecht Van Lommel c39f34def9 Fix Cycles viewport render info overlapping other text.
Now it shows more compact info below the view/object name. Render time and
memory usage is left out, as in most cases this is not so important. These
could be added back optionally if needed.
2018-11-08 18:31:33 +01:00
Antonioya 541d07045b GP: Redesign drawing cache to support particles
Full redesign of the cache system used for drawing strokes and handle derived frame data.

Before, the cache was saved in bGPdata and a hash was used to manage several objects with the same datablock.

Old design made the use of particles very inefficient and prone to bugs and segment faults, and especially when this was mixed with onion skinning and multiple objects using same datablock. Also, there were some conflicts with the depsgrah logic (the old design was done before despgraph was in place) that made the use of hash not working.

The new design saves the data in the object runtime struct and avoid the use of any hash to find the right data. This improves the speed and reduce a lot the complexity of the code, memory allocation, hash overload and adds full support for particles and reused datablocks.

The particles can reuse the modifiers and shader effects of the original grease pencil object.
2018-10-20 09:08:34 +02:00
Clément Foucault 30ae0ce0e1 Xray: Add possibility to select wires in priority before surfaces
If no wires were found, try to select surfaces in a second loop.
2018-09-04 17:15:00 +02:00
Antonioya 66da2f537a New Grease Pencil object for 2D animation
This commit merge the full development done in greasepencil-object branch and include mainly the following features.

- New grease pencil object.
- New drawing engine.
- New grease pencil modes Draw/Sculpt/Edit and Weight Paint.
- New brushes for grease pencil.
- New modifiers for grease pencil.
- New shaders FX.
- New material system (replace old palettes and colors).
- Split of annotations (old grease pencil) and new grease pencil object.
- UI adapted to blender 2.8.

You can get more info here:

https://code.blender.org/2017/12/drawing-2d-animation-in-blender-2-8/
https://code.blender.org/2018/07/grease-pencil-status-update/

This is the result of nearly two years of development and I want thanks firstly the other members of the grease pencil team: Daniel M. Lara, Matias Mendiola and Joshua Leung for their support, ideas and to keep working in the project all the time, without them this project had been impossible.

Also, I want thanks other Blender developers for their help, advices and to be there always to help me, and specially to Clément Foucault, Dalai Felinto, Pablo Vázquez and Campbell Barton.
2018-07-31 10:50:43 +02:00
Clément Foucault 5037dd8abd GPU: Add GC to FBOs and UBOs and centralize all GCs
GPUFrameBuffers were being free when no context was attached or in the
wrong gl context. This make sure this does not happen again.

You can now safely free any gl resource from any thread (well as long as
it's not used anymore!).
2018-07-19 16:13:15 +02:00
Clément Foucault 8cd7828792 GWN: Port to GPU module: Replace GWN prefix by GPU 2018-07-18 11:49:15 +02:00
Clément Foucault c90a0d5dda DRW: Add new features from lightcache branch
- Change gl_context_mutex to a ticket mutex ensuring interactivity even
  when rendering.
- Add DRW_custom_pipeline for using DRW outside of the viewport and render
  pipeline.
- DRW_opengl_render_context_*** and DRW_gawain_render_context_*** to use
  with DRW_custom_pipeline.
- Add possibility to bypass deferred compilation on demand (not User
  demand).
- Add union to access DRWMatrixState members more easily.
2018-07-10 15:31:34 +02:00
Clément Foucault 873d7f7e14 DrawData: Change drawdata to a generic struct shared accross ID types
This makes tagging much more generic and make the world updates more in
line with the new tagging system (Depsgraph).
2018-07-10 15:31:34 +02:00
Campbell Barton 750a78be9c 3D View: improve selection locking
Locked selection would still occlude with objects which could not be
selected.
2018-06-19 16:43:01 +02:00
Jeroen Bakker d3c4248946 Workbench: StudioLight HDRI's
The Studio lights are now loaded from disk. The location is
`datafiles/studiolights` they need to be JPG for now. JPG cannot store
HDRI color range but they are clamped inside the Workbench
engine for speed reason. I didn't select JP2K as it might not be
enabled.

Users can add upto 20 HDRI files. This limitation is inside the
RNA_space.c Currently the icons are calculated when you first open the
selection box for the HDRI's. We could add them to a background
rendering later.

I added 2 test files a sky texture rendered in Cycles and an HDRI from
cloud.blender.org.
2018-05-11 17:02:13 +02:00
Campbell Barton 33f3298e28 Cleanup: use 'uint' in draw manager 2018-05-11 07:48:52 +02:00
Brecht Van Lommel b365cc017a 3D Viewport: move overlay settings from collections to 3D viewport.
For some we may add per object overrides, but for most we plan to keep them
strictly per viewport settings. Display settings from the mesh still need to
be moved here, only collections were done to remove that code.
2018-05-05 15:54:43 +02:00
Jeroen Bakker 2bf333b35d Workbench: studiolight 2018-05-03 15:31:03 +02:00
Sergey Sharybin bfe88006a3 Remove unused function
Is not needed anymore since 9577ebde79.
2018-04-30 12:27:18 +02:00