Commit Graph

230 Commits

Author SHA1 Message Date
Clément Foucault f84414d6e1 EEEVEE: Object Motion Blur: Initial Implementation
This adds object motion blur vectors for EEVEE as well as better noise
reduction for it.

For TAA reprojection we just compute the motion vector on the fly based on
camera motion and depth buffer. This makes possible to store another motion
vector only for the blurring which is not useful for TAA history fetching.

Motion Data is saved per object & per geometry if using deformation blur.
We support deformation motion blur by saving previous VBO and modifying the
actual GPUBatch for the geometry to include theses VBOs.

We store Previous and Next frame motion in the same motion vector buffer
(RG for prev and BA for next). This makes non linear motion blur (like
rotating objects) less prone to outward/inward blur.

We also improve the motion blur post process to expand outside the objects
border. We use a tile base approach and the max size of the blur is set via
a new render setting.

We use a background reconstruction method that needs another setting
(Background Separation).

Sampling is done using a fixed 8 dithered samples per direction. The final
render samples will clear the noise like other stochastic effects.

One caveat is that hair particles are not yet supported. Support will
come in another patch.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7297
2020-06-19 17:05:49 +02:00
Clément Foucault 3e4c8d48aa Cleanup: DRW: Remove builtin 3D only shader usage 2020-06-03 11:02:56 +02:00
Clément Foucault b18c2a3c41 EEVEE: Refactor of eevee_material.c
These are the modifications:

-With DRW modification we reduce the number of passes we need to populate.
-Rename passes for consistent naming.
-Reduce complexity in code compilation
-Cleanup how renderpass accumulation passes are setup, using pass instances.
-Make sculpt mode compatible with shadows
-Make hair passes compatible with SSS
-Error shader and lookdev materials now use standalone materials.
-Support default shader (world and material) using a default nodetree internally.
-Change BLEND_CLIP to be emulated by gpu nodetree. Making less shader variations.
-Use BLI_memblock for cache memory allocation.
-Renderpasses are handled by switching a UBO ref bind.

One major hack in this patch is the use of modified pointer as ghash keys.
This rely on the assumption that the keys will never overlap because the
number of options per key will never be bigger than the pointed struct.

The use of one single nodetree to support default material is also a bit hacky
since it won't support concurent usage of this nodetree.
(see EEVEE_shader_default_surface_nodetree)

Another change is that objects with shader errors now appear solid magenta instead
of shaded magenta. This is only because of code reuse purpose but could be changed
if really needed.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D7642
2020-06-02 16:58:07 +02:00
Jacques Lucke cfb7664d5b Fix: build error due to missing definitions
Reviewers: sergey, brecht

Differential Revision: https://developer.blender.org/D7787
2020-05-19 17:36:40 +02:00
Pablo Dobarro 78e3b7c28d Sculpt: Render Face Sets always as flat shading
This removes the smooth shading rendering from the face set overlay when
smooth shading is enabled.

Reviewed By: jbakker

Maniphest Tasks: T74906, T74622, T75331, T76530

Differential Revision: https://developer.blender.org/D7105
2020-05-14 16:47:50 +02:00
Brecht Van Lommel fd53b72871 Objects: Eevee and workbench rendering of new Volume, Hair, PointCloud
Only the volume drawing part is really finished and exposed to the user. Hair
plugs into the existing hair rendering code and is fairly straightforward. The
pointcloud drawing is a hack using overlays rather than Eevee and workbench.

The most tricky part for volume rendering is the case where each volume grid
has a different transform, which requires an additional matrix in the shader
and non-trivial logic in Eevee volume drawing. In the common case were all the
transforms match we don't use the additional per-grid matrix in the shader.

Ref T73201, T68981

Differential Revision: https://developer.blender.org/D6955
2020-03-18 11:23:05 +01:00
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
Clément Foucault 7dd0be9554 EEVEE: Replace octahedron reflection probe by cubemap array
We implement cubemap array support for EEVEE's lightcache reflection probes.
This removes stretched texels and bottom hemisphere seams artifacts caused
by the octahedral projection previously used.

This introduce versioning code for the lightcache which will discard any
lightcache version that is not compatible.

Differential Revision: https://developer.blender.org/D7066
2020-03-11 17:12:16 +01:00
Clément Foucault c476c36e40 Workbench Simplification Refactor
This patch is (almost) a complete rewrite of workbench engine.
The features remain unchanged but the code quality is greatly improved.
Hair shading is brighter but also more correct.

This also introduce the concept of `DRWShaderLibrary` to make a simple
include system inside the GLSL files.

Differential Revision: https://developer.blender.org/D7060
2020-03-11 17:12:16 +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
Clément Foucault 8955b8b992 Cleanup: Workbench: Remove checkerboard depth
This is not needed anymore with the new overlay xray fading.
2020-02-24 13:48:38 +01:00
Clément Foucault ed21506f26 Overlay: Remove Xray dithering noise
We now use a better smoother technique that uses correct alpha blending.
This is possible now that we render overlays in a separate buffer.
2020-02-24 13:48:38 +01:00
Jeroen Bakker be2bc97eba EEVEE: Render Passes
This patch adds new render passes to EEVEE. These passes include:

* Emission
* Diffuse Light
* Diffuse Color
* Glossy Light
* Glossy Color
* Environment
* Volume Scattering
* Volume Transmission
* Bloom
* Shadow

With these passes it will be possible to use EEVEE effectively for
compositing. During development we kept a close eye on how to get similar
results compared to cycles render passes there are some differences that
are related to how EEVEE works. For EEVEE we combined the passes to
`Diffuse` and `Specular`. There are no transmittance or sss passes anymore.
Cycles will be changed accordingly.

Cycles volume transmittance is added to multiple surface col passes. For
EEVEE we left the volume transmittance as a separate pass.

Known Limitations

* All materials that use alpha blending will not be rendered in the render
  passes. Other transparency modes are supported.
* More GPU memory is required to store the render passes. When rendering
  a HD image with all render passes enabled at max extra 570MB GPU memory is
  required.

Implementation Details

An overview of render passes have been described in
https://wiki.blender.org/wiki/Source/Render/EEVEE/RenderPasses

Future Developments

* In this implementation the materials are re-rendered for Diffuse/Glossy
  and Emission passes. We could use multi target rendering to improve the
  render speed.
* Other passes can be added later
* Don't render material based passes when only requesting AO or Shadow.
* Add more passes to the system. These could include Cryptomatte, AOV's, Vector,
  ObjectID, MaterialID, UV.

Reviewed By: Clément Foucault

Differential Revision: https://developer.blender.org/D6331
2020-02-21 11:13:43 +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
Clément Foucault 3685347b41 Selection: Add conservative rasterization to select really small objects
The conservative depth shader is ~4.5x slower than the normal one as it
uses geometry shader and fragment shader discard.

This patch also includes a hack to also fix the view parallel planar
geometry and the really small wire objects.

For some reason, the conservative raster fix does not work with normal
selection but does with box select.

This is a fix for T63356.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D6714
2020-02-04 15:20:15 +01:00
Campbell Barton bc92d05522 Cleanup: sort file lists 2019-12-17 10:07:44 +11:00
Clément Foucault b9f896f6f1 Overlay Engine: Armature: Use Wire AA on custom bone loose edges 2019-12-05 16:36:06 +01:00
Clément Foucault d40579c62b Overlay Engine: Fix bone outline antialiasing 2019-12-05 16:36:06 +01:00
Clément Foucault 4705aa4fe5 Overlay Engine: LightProbe: Simplify drawing of irradiance grid data
This separates it from the outline pass and fix a visibility bug
when extras were off.
2019-12-04 22:32:17 +01:00
Clément Foucault 6d3eb85f66 Overlay Engine: Simplify outline rendering by using the antialiasing pass
This use the overlay AA pass to antialias the selection outlines.

This also do all search and expand in one pass and reduce the computation
time and memory used (2 x 32bit/pixel buffer less).

Note that the aliasing is a bit worse than the old FXAA that we used to have.
2019-12-04 22:32:17 +01:00
Clément Foucault 3e241af3ae Overlay Engine: Wireframe: Remove geometry shader and fragment discard
This Simplify and should also speedup the drawing a tiny bit.

We now discard the edges in the vertex shader by setting one of the verts
at vec4(0,0,0,0) to not produce any fragment
2019-12-02 14:35:49 +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
Jeroen Bakker 9d7f65630b EEVEE: GLSL Renderpasses
Most of the renderpasses in EEVEE used post-processing on the CPU. For
final image rendering this is sufficient, but when we want to display
the data to the user we don't want to transfer to the CPU to do post
processing to then upload it back to the GPU to display the result.

This patch moves the renderpass postprocessing to a GLSL shader.

This is the first step to do, before we will enable the renderpasses in the viewport.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D6206
2019-11-27 15:50:54 +01:00
Clément Foucault 4ddf3215a7 Fix T68380 Skin modifier root not displayed 2019-10-16 18:58:12 +02:00
Campbell Barton 423435bd2e Cleanup: sort struct, file lists 2019-09-09 21:09:19 +10:00
Clément Foucault d8aaf25c23 Eevee: Shadow map refactor
Reviewed By: brecht

Differential Revision: http://developer.blender.org/D5659
2019-09-05 17:37:50 +02:00
Campbell Barton 7fee153bf5 3D View: show selected object axis when affect origins is enabled
This replaces temporarily enabling draw-axis.
2019-08-27 01:46:03 +10:00
Clément Foucault 9c010c44f4 Mesh Batch Cache: Refactor + Multithread
For clarity sake, the batch cache now uses exclusively per Loop attributes.
While this is a bit of a waste of VRAM (for the few case where per vert
attribs are enough) it reduces the complexity and amount of overall VBO
to update in general situations.

This patch also makes the VertexBuffers filling multithreaded. This make
the update of dense meshes a bit faster. The main bottleneck is the
IndexBuffers update which cannot be multithreaded efficiently (have to
increment a counter and/or do a final sorting pass).

We introduce the concept of "extract" functions/step.
All extract functions are executed in one thread each and if possible,
using multiple thread for looping over all elements.

Reviewed By: brecht

Differential Revision: http://developer.blender.org/D5424
2019-08-14 19:05:26 +02:00
Campbell Barton 4b9e05b428 Cleanup: clang-format, sort structs & cmake files 2019-08-15 01:34:58 +10:00
mano-wii 44d95cbf95 Cleanup: DRW manager: Move `select_buffer.c` utilities out of the selection engine internals 2019-08-12 12:10:44 -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
Lazydodo 9fbf522dd8 Cleanup: Fix eeve_lut arrays being duplicated in blender binary.
Both eevee_materials.c and workbench_deferred.c include eeve_lut.h which has its arrays marked as static leading to the blue_noise array being embedded into our binary twice.

This change takes the arrays out of the header and properly marks them as const since they are lookup tables and should not be written to.

Reviewers: fclem, brecht

Differential Revision: https://developer.blender.org/D5346
2019-08-04 14:32:53 -06:00
mano-wii 43ec8d7ae9 Cleanup: Rearrange Select Engine into multiple files 2019-07-30 20:47:18 -03: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
Jeroen Bakker fed6c1a970 Fix T62876: Camera Background Images
Migrate old legacy code to the draw mamager/object mode. The old legacy
version did not work with wireframe. By migrating the code
to modern draw manager code we have mode control on the drawing process.

Still background images do not work with OIT, the cause seems to be that the transparent pixels are treated as background pixels.
Also There are some artifacts when working with Holdouts and DoF, this
is because the draw engines do not pass the correct alpha values.

Reviewers: fclem, brecht

Differential Revision: https://developer.blender.org/D4638
2019-06-21 09:53:51 +02:00
Jeroen Bakker a3a6cda8fb Fix T65745: Bone Selection X-Ray Drawing.
The Pose Bone Selection used normal matric multiplication, but that
mismatched the Depth buffer from all draw engines. They used the
optimized matrices from common_view_lib.

This change will use the optimized version, so the depth buffer matches
and the render artifacts would be correct.

Please note that bone selection is not using shcfg and therefore render clipping is still off.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D5100
2019-06-21 09:47:03 +02:00
Jeroen Bakker eeda9369b6 TexturePaint: Missing Texture Depth Test
Depth testing was off as it used the precomputed ModelView matrix. As
draw engines currently use a different approach the depth was sometimes
a bit off making the color disappear.

This change will use a different vertex shader that will write the
correct depth. I expected the same change to be needed in the bone
selection overlay but was not able to reproduce it.

Reviewed By: fclem

Maniphest Tasks: T64615

Differential Revision: https://developer.blender.org/D5006
2019-06-05 14:29:27 +02:00
Clément Foucault 942a748d5d Eevee: Merge shadow map processing into one drawcall per light
This removes a lot of framebuffer configuration and binding.
2019-06-04 18:42:50 +02:00
Clément Foucault 05b0f52aa7 DRW: Move all batch request functions to own header
This is in order to using BLI_INLINE for thoses functions and keep headers
cleany separated.
2019-05-08 17:52:48 +02:00
Jeroen Bakker 38a0896f15 Overlay: Mesh Analysis
Enabling the drawing of the mesh analysis overlay.
Currently the settings are part of the scene toolsettings. What makes sense,
for 3d printing, but does not fit well with the per viewport blender 2.80
overlays.

Reviewers: brecht, fclem

Differential Revision: https://developer.blender.org/D4707
2019-04-25 11:25:22 +02:00
Campbell Barton 2753959ed7 Cleanup: sort CMake include paths 2019-04-24 14:41:12 +10: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
Campbell Barton edc1b01675 CMake: add libs needed for gtests 2019-04-16 08:07:01 +02:00
Campbell Barton 5498e7f193 CMake: add library deps to CMakeLists.txt
Tested to work on Linux and macOS.

This will be enabled once all platforms are verified.

See D4684
2019-04-16 06:20:52 +02:00
Campbell Barton 47adab4f99 CMake: prepare for BLENDER_SORTED_LIBS removal
No functional change, this adds LIB definition and args to cmake files.
Without this it's difficult to migrate away from 'BLENDER_SORTED_LIBS'
since there are many platforms/configurations that could break when
changing linking order.

Manually add and enable WITHOUT_SORTED_LIBS to try building
without sorted libs (currently fails since all variables are empty).
This check will eventually be removed.

See T46725.
2019-04-14 15:37:24 +02:00
Clément Foucault f12040e088 DRW: Opti: Fix hotspot in DRW_mesh_batch_cache_get_surface_shaded
The hotspot was generated by mesh_cd_layers_type_overlap who was testing
way more data than it should have.

Here we reduce the whole CD layer mask to a 32bit bitflag that is easily
or'ed and tested.

Bonus point: We use atomic operation to merge the mask in order to allow
future multi-threading. (this was a TODO)

In the scene attached to T58188 this removes 5% of CPU time.
2019-04-06 01:55:21 +02:00
Campbell Barton 168d3fd528 Cleanup: file rename lamp -> light 2019-02-27 12:36:32 +11:00
Campbell Barton caa8e7ff28 DRW: de-duplicate vertex & weight paint engines
These were almost exact duplicates, use one engine for drawing both
kinds of vertex color.
2019-02-14 15:22:58 +11:00
Campbell Barton dbd7f36da8 GPU: refactor clipped drawing from DRW into GPU
Needed to fix T61196, supporting clipped back-buffer in the 3D view
which is done outside the draw module.

It was also inconvenient having DRW_shader_* versions of GPU_shader_*
API calls.

- Clipping distances are now supported as a shader configuration
  for builtin shaders.
- Add shader config argument when accessing builtin shaders.
- Move GPU_shader_create_from_arrays() from DRW to GPU.
2019-02-06 09:15:16 +11:00
Clément Foucault 773f3428cf Edit Mesh: Add workaround for system that does not support wide lines
This adds a new geometry shader (specific to edit mesh for now) that
reproduces the effect of glLineWidth > 1.0, since this is not supported on
all platform.

This fix could be generalized to other shaders later.
2019-02-05 15:02:15 +01:00