Commit Graph

218 Commits

Author SHA1 Message Date
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
Clément Foucault 112cf6eadf Edit Mesh: Remove old unused code and files
Cleanup after recent refactor.
2019-02-05 15:02:15 +01:00
Campbell Barton ab5e69e660 Cleanup: remove contributors for CMake files
Following removal from C source code.

See: 8c68ed6df1
2019-02-05 09:10:32 +11:00
Clément Foucault 3f6e14e667 Workbench: Depth Of Field: Initial Commit
The algorithm used is borrowed from :
http://tuxedolabs.blogspot.com/2018/05/bokeh-depth-of-field-in-single-pass.html

This makes it possible to have a decent blur for foreground over defocused
background in one pass only.

The algorithm is using a gather approach that is much faster
than the scatter approach used in Eevee. This makes it possible to have
custom bokeh shapes (not implemented yet) which would be impossible with
a separable gaussian technique.

The blur is done in 2 steps. The first one define the shape of the bokeh
and the second that fill the undersampling.

A downsample max-CoC tile texture speed up the gathering process.
2019-01-25 15:02:49 +01:00
Campbell Barton 2218bf02dd Cleanup: sort cmake file lists 2019-01-25 08:30:33 +11:00
Campbell Barton e72fa714a8 Cleanup: remove duplicated shaders that only added clipping checks
Originally I wanted to avoid adding draw manager specific ifdef's all
over generic shaders however this isn't needed in so many places.

Also there are shaders that are only used by the draw manager so
duplicating them only to have the original unused doesn't make sense.
2019-01-25 08:01:07 +11:00
Campbell Barton 04d18b117c DRW: API for own versions of builtin GPU shaders
DRW_shader_get_builtin_shader can replace GPU_shader_get_builtin_shader
when we need to support clipping.

Use this for loose point & wire drawing in object mode,
clips edges in lattice edit mode.
2019-01-24 16:14:00 +11:00
Campbell Barton 9bc47ed0f6 Fix clipping shaders with some AMD/Intel drivers
Caused:
    error: unsized array index must be constant

Use hard coded number of clipping planes, copying the 4th to 5 & 6
when only 4 are used.
2019-01-21 23:55:53 +11:00
Clément Foucault 4cd558b711 Mesh Batch Cache: Port Texture paint wires to new batch request 2018-12-17 17:11:45 +01:00
Clément Foucault 2afed99da3 Curve Batch Cache: Rework Implementation to use new batch request
Shaded triangles are not yet implemented (request from gpumaterials).

This also changes the mechanism to draw curve normals to make it not
dependant on normal size display. This way different viewport can
reuse the same batch.
2018-12-14 16:17:29 +01:00
Clément Foucault 1d23024014 Object Mode: Make point clouds a bit less like uniform blobs
Also this display is optimized. It does not use blending and pixel discard.
Working with scanned data should be more pleasant with this.

A better option would be to use gl_FragDepth to have a better sense of
volume but this discards early depth test.
2018-12-10 23:17:20 +01:00
Clément Foucault 9f5a27c5be GPU: Remove EXT and add assert
Some drivers accept shaders with only vertex stage, but some just silently
fails.
2018-12-07 05:33:46 +01:00
Clément Foucault 223c1a107a Workbench: Make object ID pass optionnal
We separate the background and foreground shading passes to be able to make
the object id pass optionnal if we don't need it.

This saves a bit more memory. Also not clearing all rendertargets saves
some GPU time too.
2018-12-03 17:19:11 +01:00