Commit Graph

166 Commits

Author SHA1 Message Date
mano-wii 1f458895f8 Fix crash when rendering a scene first and then goes to eevee preview modes and cleanup
The crash only occurs with Intel 3rd generation GPUs.
It occurs because the program needs to be used at least once in the opengl context in which it is created.
2018-11-16 13:46:13 -02:00
Clément Foucault 03d0219d7a Edit Mesh: Refactor edit mesh drawing
This decouple the vertex display from the face+edges.

This is to reduce the number of triangles required to fix the edges
artifacts (aliasing) and increase viewport reactivity when not actively
navigating (ie. mouse scroll).

Also it makes all vertices visible (not cut-off) even when navigating.

However it makes the navigation drawing a bit slower because it has to
render twice.

Also add a depth bias to the wires to avoid depth fighting when previewing
final mesh (modifiers applied).
2018-10-12 16:43:40 +02:00
Antonioya c2519d8521 GP: New Glow Shader FX (wip)
New shader to simulate a glow of the color.

The glow can be generated by luminance threshold or using a selection color.
2018-10-10 23:00:56 +02:00
Clément Foucault 89c30ff746 Pose Mode: Add back IK Degrees of freedom display 2018-10-03 15:44:12 +02:00
Antonioya f1afa6f6a7 GP: implement Shadow FX (wip)
Initial implementation of effect to create a drop shadow of the strokes
2018-09-30 11:49:02 +02:00
Jeroen Bakker 3da46a8d8d Implement a new dedicated weight painting shader.
Move the weight paint drawing to the fragment shader. The shader
uses a texture that uses the U.coba_weight custom color band, or
an internal color band.

In addition to actual weights, the shader has to display two
alert colors: missing vertex group, and zero weight. The zero
weight alert has to be blended with regular weight colors,
so that a single alert vertex surrounded by weighted ones is
still visible.

Reviewers: campbellbarton, fclem

Differential Revision: https://developer.blender.org/D3675
2018-09-27 17:33:33 +03:00
Clément Foucault 586ec7588f Cleanup: Edit Surface & Curve engines unused code 2018-09-26 16:42:57 +02:00
Clément Foucault 5158da9e37 Curve Edit: Cleanup/Improve/Fix handles drawing
Now handles are drawn using index buffer instead of duplicating memory
requirement.

Also make use of shader tricks to draw handles antialiased, and respond to
UI scalling.

Make vertex point match edit mesh vertex size.
2018-09-26 00:49:50 +02:00
Campbell Barton 1450a37555 CMake: add missing headers 2018-09-06 21:23:25 +10:00
Clément Foucault c05b9bbcc0 Fix T56692: The edges are not highlighted in Mark Freestyle Edge
This was not ported yet.
2018-09-05 19:00:12 +02:00
Clément Foucault 0ba3a1a686 Sculpt: Optimize Mask Overlay drawing
* Remove support for diffuse color in the pbvh buffers.
* Upload raw data to GPU.
* Only draw nodes that have mask data when drawing the overlay.

This should fix T56466
2018-08-24 16:46:59 +02:00
Clément Foucault 435f308eed Object Mode: Use same empty (arrow) drawing as the bone axes display 2018-08-17 13:04:26 +02:00
Clément Foucault c761153f64 Overlays: Support for wireframes and edit mode overlay on xray objects 2018-08-16 23:57:59 +02:00
Clément Foucault 485b8d41be Workbench: Add support for the xray object option
Xray object can be see through other objects. They cast shadows as well
but cannot receive then.
2018-08-14 21:38:13 +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
Brecht Van Lommel 644fadf2f0 Render: add "OpenGL" render engine.
This is intended for quick renders for previsualization, animation previews
or sequencer previews. It provides the same settings as found in the 3D view
Shading popover in solid display mode, but in the scene render properties.

The "Workbench" engine was removed, and this name no longer appears in the
user interface, it's purely an internal name. We might come up with a better
name for this OpenGL engine still, but it's good to be consistent with the
OpenGL Render operator name since this has a similar purpose.
2018-07-17 16:46:09 +02:00
Clément Foucault 7a693626d6 Smoke: Port display to Workbench + object mode
This does not fix the smokesim. It only port the drawing method.

The Object mode engine is in charge of rendering the velocity debugging.

Things left to do:
- Flame rendering.
- Color Ramp coloring of volume data.
- View facing slicing (for now it's only doing sampling starting from the
  volume bounds which gives a squarish look)
- Add option to enable dithering (currently on by default.
2018-07-16 20:08:09 +02:00
Clément Foucault 1a43e08187 Eevee: LightCache: Initial Implementation
This separate probe rendering from viewport rendering, making possible to
run the baking in another thread (non blocking and faster).

The baked lighting is saved in the blend file. Nothing needs to be
recomputed on load.

There is a few missing bits / bugs:
- Cache cannot be saved to disk as a separate file, it is saved in the DNA
  for now making file larger and memory usage higher.
- Auto update only cubemaps does update the grids (bug).
- Probes cannot be updated individually (considered as dynamic).
- Light Cache cannot be (re)generated during render.
2018-07-10 15:31:34 +02:00
Jeroen Bakker 2b4c7600b7 Workbench: Anti-aliasing refactor
- TAA is also enabled for Forward rendering
- Uses less GPU memory (removed one history buffer)
- TAA is done after the color management
- consolidated the aa code between forward and deferred rendering
(workbench_effects_aa.c)
2018-06-28 14:39:15 +02:00
Jeroen Bakker cf8a059769 Workbench: Tempural Anti Aliasing
- FXAA is now also done in the workbench_forward engine.
- User can enable TAA8 in the userpref by setting their max
viewport AA to TAA8. FXAA will still be used when navigating
2018-06-26 16:35:47 +02:00
Jeroen Bakker e552247489 MeshEditMode: refactor
- added a lib for shaded functions
- decreased active face inner size
2018-06-15 15:37:13 +02:00
Jeroen Bakker 0276abbcf7 Workbench: FXAA
FXAA implementation in the deferred renderpass of the workbench.
Can be enabled per 3dview. Eventually this will also be a user setting
as it is more a system/performance setting than a scene setting.
2018-06-15 13:02:16 +02:00
Jeroen Bakker b6b1e0f56c T55454: removal of clay engine
The ClayEngine was introduced to test the blender2.8 architecture during
development. As currently we have the wanted features implemented with
matcaps we are going to remove the clay engine as it was never intended
to be an official releasable engine

Note: The test cases are never run. But when enabled will be skipped as
they were implemented over the Clay Engine
2018-06-12 15:32:31 +02:00
Clément Foucault 542462d35c Workbench: Xray: Add selected/active non-occluded outlines
This Fix the problem when multiple objects are selected and one of them
occlude the others. You cannot see clearly what is selected.

With this option, selection is more clear when Xray mode is enabled.
2018-06-10 20:06:26 +02:00
Clément Foucault 95894421cb Workbench: Xray: Optimize and fix implementation.
There was a method explained in the Weighted Blended Order-Independent
Transparency paper to support hardware that does not support per render
target blending function.

So now only 2 geometry passes are required instead of 3 (one being the
outline/depth fill pass).

This also fix how the blending is done. There was some premult confusion
in the implementation.
2018-06-10 20:06:26 +02:00
Clément Foucault 147eef9741 Eevee: Improve compilation time (reduce branching).
This patch reduce the branching in the lamp loop, improving compilation time
noticeably (2372ms to 1785ms for the default shader).

This should not change the appearance of the shader.

Performance impact is negligeable.
2018-06-09 21:11:03 +02:00
Jeroen Bakker f1fd5ed74f T55333 Workbench: Cavity Shader
A cavity shader based on SSAO. Works on all workbench deferred passes.

Per 3d viewport the cavity shader options can be set as different
shading needed different options. Some global options are in the
Viewport Display of the scene like num samples and distance.

Experimental: Naming of Ridges and Valleys
2018-06-06 14:51:18 +02:00
Clément Foucault d0f7ab27a8 Wireframe: Optimization for intel GPUs.
Intel GPU take more advantage of the geometry shader than other vendors.

Using a simple geom shader approach in this case is more performant.
2018-06-03 15:26:37 +02:00
Joshua Leung 72a360827b T54991: Restore support for Motion Path drawing in 2.8
This commit restores support for Motion Path drawing in 2.8 (as it wasn't ported over
to the new draw engines earlier, and the existing space_view3d/drawanimviz.c code was
removed during the Blender Internal removal).

Notes:
* Motion Paths are now implemented as an overlay (enabled by default).
  Therefore, you can turn all of them on/off from the "Overlays" popover

* By and large, we have kept the same draw style as was used in 2.7
  Further changes can happen later following further design work.

* One change from 2.7 is that thicker lines are used by default (2px vs 1px)


Todo's:
* There are some bad-level calls introduced here (i.e. the actgroup_to_keylist() stuff).
  These were introduced to optimise drawing performance (by avoiding full keyframes -> keylist
  conversion step on each drawcall). Instead, this has been moved to the calculation step
  (in blenkernel).  Soon, there will be some cleanups/improvements with those functions,
  so until then, we'll keep the bad level calls.


Credits:
* Clément Foucault (fclem) - Draw Engine magic + Shader Conversion/Optimisation
* Joshua Leung (Aligorith) - COW fixes, UI integration, etc.


Revision History:
See "tmp-b28-motionpath_drawing" branch (rBa12ab5b2ef49ccacae091ccb54d72de0d63f990d)
2018-06-01 16:38:21 +02:00
Clément Foucault bf4ce5755f Overlay: Add Wireframe overlay.
This overlay is showing mesh topology. It is usable with transparency
even if the mesh order can mess up with the expected result (some object
more prominent than others).

Edge thickness and alpha values are hardcoded for now but can easily be
added to theme or object settings.
2018-05-31 19:09:20 +02:00
Clément Foucault 328f8dc21c DRW: Add new GPU hair system.
This new system use transform feedback to compute subdivided hair points
position. For now no smoothing is done between input points.

This new system decouple the strands data (uv, mcol) with the points
position, requiring less update work if only simulation is running.

In the future, we can have compute shader do the work of the feedback
transform pass since it's really what it's meant to. Also we could generate
the child particles during this pass, releasing some CPU time.

draw_hair.c has been created to handle all of the Shading group creations
as well as subdivision shaders.

We store one final batch per settings combination because multiple viewport
or render could use the same particle system with a different subdivision
count or hair shape type.
2018-05-30 12:25:20 +02:00
Jeroen Bakker 765fd29d68 EEvEE: LookDev 2018-05-28 17:07:39 +02:00
Clément Foucault 8df99a5d8a DRW: Add new DRW_debug API.
This new API aim to provide simple function that can be called by the draw
engines during any phase of the draw pipeline. All calls are saved and
issued after all engines have finished rendering.

This removes the need of setuping special passes and shading groups for some
simple debug drawing.
2018-05-26 23:24:11 +02:00
Jeroen Bakker e561eef3ff Workbench: Revealage buffer 2018-05-24 09:28:29 +02:00
Jeroen Bakker 6afccf6348 Workbench: Checkboard pattern for supporting objects 2018-05-23 15:22:51 +02:00
Jeroen Bakker dfe088c5d9 Workbench: SeeThrough draw option
Option to see through all meshes (transparency)

Works for OB_SOLID and OB_TEXTURED. Does not work for
V3D_SHADING_SHADOW.

TODO: Fresnel effect
2018-05-22 14:55:50 +02:00
Clément Foucault 7a28dea1e1 Workbench: Shadow: Add Depth Fail method
Also add new debug visualisation.

Depth fail method is not used for the moment but has nice benefits. It will
be used efficiently in the future.
2018-05-20 19:14:22 +02:00
Clément Foucault 74a08cf128 Eevee: Depth of field: Change final blending.
This new blending allows background to fill the gaps left by forground
objects. However this has a drawback, background objects that should be
partially occluded in this case can be seen through the blurred objects.

This does not fix the problem of blurred foreground over sharp background.

Also cleanup code to be simpler and remove unused geometry shader.
2018-05-12 23:28:55 +02:00
Sergey Sharybin 5cea8bf435 Draw manager: Initial implementation of key points visualization
Does all points all the time, ignoring the setting in viewport header.
This is to be addressed by the next commit.
2018-05-09 14:59:48 +02:00
Sergey Sharybin 49fc1d0f54 Draw manager: Initial implementation of particle edit mode
Gets edit more from the current object and displays it as a path.
this is how both hair and particle edit modes are supposed to work.

This only covers path itself, it doesn't do anything like keys
visualization or selection. However, it's already possible to
comb and such.

Only implements particle mode. There are also some settings to
do soft body and cloth. No idea yet what that all is about.

Copy-on-write is not supported either, this is due to some
edit mode ownership problems which are to be addressed from
dependency graph side.

Shading is dead-simple: uses tangent as a color. This is where
i hope to get some help from Clément.
2018-05-09 10:34:45 +02:00
Clément Foucault 9a79178c2e Armature: Add back Stick bone draw type.
The actual code is a bit convoluted but allows good and "pseudo efficient"
drawing. (pseudo efficient because rendering instances with that amount of
vertices is really inneficient. We should go full procedural but need to
have bufferTexture implemented first) But drawing speed is not a bottleneck
here and it's already a million time less crappy than the old (2.79) immediate
mode method.

Instead of drawing actual wires with different width we render a triangle
fan batch (containing 3 fans: bone, head, tail) which is then oriented in
screen space to the bone direction. We then interpolate a float value
accross vertices giving us a nice blend factor to blend the colors and
gives us really smooth interpolation inside the bone.

The outside edge still being geometry will be antialiased by MSAA if enabled.
2018-05-08 12:18:35 +02:00
Clément Foucault c472936074 Armature: Fix/Change bone axes display.
Now the axes are displayed correctly at the tip of the bone and with the
axes names.

I've made some modifications though:
- Axes are colored. (should not be in object mode but that's TODO)
- Axes ends are not flat arrows anymore. Replaced with a small diamond.
- Axes names are now scale by their respective axes instead of being
  affected by other axes.
- Changed axes names "font" to be a bit more sexy.
2018-05-06 18:36:47 +02:00
Clément Foucault 817cf2a317 Armature: Rename bone shaders and add 2 colors smooth blending.
This will enable us to do more nice stuff in future commits.

This commit is a temporary commit, it will compile but will crash if
trying to display any armature. Next commit does work.
2018-05-05 21:04:21 +02:00
Jeroen Bakker 3f95daa31f Workbench: Shadows
Initial review of the shard shadows in the workbench engine.

Speed optimizations like transform feedback are not implemented yet. I first want this part to be reviewed and merged.

@fclem please check the note in drw_stencil_set it was holding back nequal == 0 as by default DST.stencil_mask was set to 0. questioin is should we remove the whole check or not.

Also I am still looking for a better name (or split the enum) for DRW_STATE_STENCIL_DEPTH_FAIL_INCR_DECR_WRAP

Reviewers: fclem

Reviewed By: fclem

Tags: #code_quest

Differential Revision: https://developer.blender.org/D3198
2018-05-04 14:08:40 +02:00
Jeroen Bakker 0b1c673e14 Workbench: selection method for studio lighting 2018-05-03 15:33:13 +02:00
Jeroen Bakker 2bf333b35d Workbench: studiolight 2018-05-03 15:31:03 +02:00
Germano 1677ea89c7 Metaball: Move handles shader to draw/modes/shader and reference them in draw_common.c 2018-05-03 09:11:02 -03:00
Clément Foucault e764d2b6ba Armature: More work and cleanup on envelope bones drawing.
- Draw tail & head sphere with point shader (no needs for another way).
- Use the same function for issuing the calls for wire and solid envelope.
2018-05-02 20:49:38 +02:00
Clément Foucault 01cec3e0c5 Armature: Envelope Bones: Change drawing method.
We now use a more pleasant and efficient way to display enveloppe bones
and their radius.

For this we use a capsule geometry that is displaced (in the vertex shader)
to a signed distance field that represents the bone shape.

The bone distance radius are now drawn in 3D using a "pseudo-fresnel" effect.
This gives a better understanding of what is inside the radius of influence.

When capsules are not needed, we switch to default raytraced points.
The capsules are not distorded by the bone's matrix (same as their actual
influence radius) and are correctly displayed even with complex scaled
parents hierarchy.
2018-05-02 20:49:38 +02:00
Clément Foucault 8c2a6f957a Armature: "Raytrace" bones endpoint spheres.
Here is how it works:
We render a high poly disc that we orient & scale towards the camera so that
it covers the same pixel of the sphere it's supposed to represent.

Then the pixel shader raytrace the sphere (effectively starting from
the poly disc depth) and outputs the depth to gl_FragDepth.

This approach has many benefit:
- high quality obviously: per pixel accurate depth!
- compatible with MSAA: since the sphere horizon is delimited by polygons,
  we get the coverage computed by the rasterizer. However we still gets
  aliasing if the sphere intersect directly other meshes.
- virtually no overdraw: there is no backface to shade but we still get
  overdraw because by little triangle [gpus rasterize pixel by groups of 4].
- allows early depth test: since the poly disc is set at the nearest depth
  we can output, we can use GL_ARB_conservative_depth to enable early depth
  test and discard pixels that are already behind geometry.
- can draw outline pretty easily without geometry shader.
2018-05-02 20:49:38 +02:00