Commit Graph

131 Commits

Author SHA1 Message Date
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
Clément Foucault e493a1a1ae DRW: Armature: New bone outline shader.
This fix the issue with the zfighting we were getting at bones edges.

Moreover, this enables us to render arbitrarly large outline with
varying thickness.
2018-05-02 20:49:38 +02:00
Clément Foucault befbf7eb9b Vertex Paint: Use Linear colors for interpolation.
This matches Cycles and Eevee's behaviour.
2018-05-02 16:45:08 +02:00
Jeroen Bakker f938ff1010 Workbench: Dither background color/gradient 2018-04-25 11:30:38 +02:00
Jeroen Bakker 35220ccde0 Silhouette Overlap Overlay
Added Object Overlap Overlay

 - Added R32UI support to GPU_framebuffer
 - Added R32U support to draw manager
 - The overlay mode has a object data pass that will render 'needed' data to specific buffers so we can mix them together via a deferred rendering. In future will also add UV's and other data
 - Overlap is implemented as an overlay so it could be used on top of the Scene lighted Solid mode (that will be rendered by Eevee.

Reviewers: fclem, brecht

Reviewed By: fclem

Subscribers: sergey

Tags: #code_quest

Maniphest Tasks: T54726

Differential Revision: https://developer.blender.org/D3174
2018-04-25 11:09:49 +02:00
Clément Foucault e2613e4051 Eevee: Add Velocity pass.
This pass create a velocity buffer which is basically a 2D motion vector
texture. This is not yet used for rendering but will be usefull for motion
blur and temporal reprojection.
2018-04-20 18:29:33 +02:00
Jeroen Bakker cc0c971f84 Workbench: Added the basics for the OverlayMode
Implemented the face orientation overlay for testing.
Overlay mode is only drawn when there are overlays to be rendered.
The overlay mode is rendered before the object mode.
2018-04-20 10:45:46 +02:00
Jeroen Bakker a091da7ffa Workbench: reuse similar materials
Similar materials will reuse the same shadergroup. Currently using
a custom hash function that might select too similar colors into the
same material.

Reintroduced the workbench_materials.c this file will be responsible for
material lookup/creation and shader compilation

Fixed a GPUShader mem leak
2018-04-18 13:44:33 +02:00
Jeroen Bakker ccb104b9c2 Workbench: Basic Solid Studio
Currently uses static lighting. Will become HDRI lighting.
Added do_versions to set default drawtype_solid and drawtype_texture to
OB_LIGHTING_STUDIO. When View3D space is created drawtype_solid and
drawtype_texture are also set to OB_LIGHTING_STUDIO.

Current studio lighting uses a dot product to simulate static lighting.
Will need to be changed in the future with different lighting models.
2018-04-18 08:20:12 +02:00
Jeroen Bakker 3f762dd764 Workbench: clean up the viewport shading code
- added the drawtype_solid, drawtype_wireframe, drawtype_texture to
View3D
- enabled workbench panels for important render engines
- merged workbench_materials to solid_flat_mode. All draw modes will get
its own fast implementation in the workbench
2018-04-17 22:11:56 +02:00
Jeroen Bakker d26b7592b8 Workbench: Switching Draw engines based on draw mode 2018-04-17 16:34:41 +02:00
Jeroen Bakker c7d6aa4338 Merge branch 'blender2.8' into blender2.8-workbench 2018-04-16 20:35:59 +02:00
Clément Foucault 7f5d76b37f Object Mode: Rework outline drawing.
This changes quite a few things.
- Outline is now per object.
- No more outline at object intersection (fix hairs problem).
- Simplify the code quite a bit.

We use a R16UI buffer to save one id per object outline. We convert this id
to color when detecting the outline.

Added textureGatherOffsets to the code but could not test on current hardware
so leaving it commented for now.
2018-04-16 19:38:58 +02:00
Jeroen Bakker 7ffc8bc25d Merge branch 'blender2.8' into blender2.8-workbench 2018-04-16 08:20:12 +02:00
Clément Foucault 61a22262d1 Eevee: Cleanup remaining shadow geometry references. 2018-04-15 22:23:51 +02:00
Jeroen Bakker e6998b6e62 Workbench: Silhouette shading
Currently it uses the `obj->col`. This needs to be made more intelligent
with fe collection overrides.
2018-04-13 15:49:50 +02:00
Clément Foucault bc15ec0896 GPUFramebuffer: Refactor (Part 2)
This refactor modernise the use of framebuffers.
It also touches a lot of files so breaking down changes we have:
 - GPUTexture: Allow textures to be attached to more than one GPUFrameBuffer.
   This allows to create and configure more FBO without the need to attach
   and detach texture at drawing time.
 - GPUFrameBuffer: The wrapper starts to mimic opengl a bit closer. This
   allows to configure the framebuffer inside a context other than the one
   that will be rendering the framebuffer. We do the actual configuration
   when binding the FBO. We also Keep track of config validity and save
   drawbuffers state in the FBO. We remove the different bind/unbind
   functions. These make little sense now that we have separate contexts.
 - DRWFrameBuffer: We replace DRW_framebuffer functions by GPU_framebuffer
   ones to avoid another layer of abstraction. We move the DRW convenience
   functions to GPUFramebuffer instead and even add new ones. The MACRO
   GPU_framebuffer_ensure_config is pretty much all you need to create and
   config a GPUFramebuffer.
 - DRWTexture: Due to the removal of DRWFrameBuffer, we needed to create
   functions to create textures for thoses framebuffers. Pool textures are
   now using default texture parameters for the texture type asked.
 - DRWManager: Make sure no framebuffer object is bound when doing cache
   filling.
 - GPUViewport: Add new color_only_fb and depth_only_fb along with FB API
   usage update. This let draw engines render to color/depth only target
   and without the need to attach/detach textures.
 - WM_window: Assert when a framebuffer is bound when changing context.
   This balance the fact we are not track ogl context inside GPUFramebuffer.
 - Eevee, Clay, Mode engines: Update to new API. This comes with a lot of
   code simplification.

This also come with some cleanups in some engine codes.
2018-03-25 20:06:12 +02:00
Clément Foucault 47acd706fd GPUCompositing: Remove entire module.
This module has no use now with the new DrawManager and DrawEngines and it
is using deprecated paths.

Moving gpu_shader_fullscreen_vert.glsl
to draw/modes/shaders/common_fullscreen_vert.glsl
2018-03-22 16:11:49 +01:00
Clément Foucault 5c30121b8c Clay: Add FXAA.
I tried to use real multisampling but the main problem is the outline detection that needs to have matching depth samples.

So adding FXAA instead. Always on for now, may add a parameter for it later.

One thing to note is that we need to copy the final output once again to the main color buffer because we cannot swap the dtxl textures (they can be referenced elsewhere like GPUOffscreen).

We could improve upon this and add TAA on top if viewport is still.
2018-03-14 14:55:36 +01:00
Clément Foucault b4209b138f Clay: Refactor: Port clay to a deferred pipeline.
This means that rendering clay with AO only needs 1 geometry pass.
Thus greatly improving performance of poly heavy scene.

This also fix a self shadow issue in the AO, making low sample count
way better.

We also do not need to blit the depth anymore since we
are doing a fullscreen shading pass.

The constant cost of running the a deferred shading pass is negligeable.
This include quite a bit of code cleanup inside clay_engine.c.

The deferred pipeline is only enabled if at least one material needs it.
Multisampling is not supported yet.

Small hacks when doing deferred:
- We invert the normal before encoding it for precision.
- We put the facing direction into the sign of the mat_id.
- We dither the normal to fight the low bitdepth artifacts of the normal
  buffer (which is 8bits per channel to reduce bandwidth usage).
2018-03-14 12:41:00 +01:00
Clément Foucault 8444aaaa69 DRW: Put all view-only dependant uniform in a UBO.
This leads to less lookups to the GWNShaderInterface and less uniform upload.

We still keep a legacy path so that Builtin uniforms can still work. We might restrict this path to Builtin shader only in the future.
2018-03-10 02:18:25 +01:00
Clément Foucault 0df21e2504 DRW: Refactor & Split draw_manager.c into multiple files.
Refactor include:
- Removal of DRWInterface. (was useless)
- Split DRWCallHeader into a new struct DRWCallState that will be reused in the future.
- Use BLI_link_utils for APPEND/PREPEND.
- Creation of the new DRWManager struct type. This will enable us to create more than one manager in the future.
- Removal of some dead code.
2018-02-28 01:29:26 +01:00
Clément Foucault e52c5bcdb5 Eevee: Add mist pass support.
Eevee: Render: Fix crash when not enabling mist pass.
2018-02-01 20:47:56 +01:00
Clément Foucault ba9a4dedda Eevee: Initial Final Render support.
TAA / multiple samples is not working at the moment.
2018-01-29 22:00:15 +01:00
Germano d072022bbf Deduplicate GLSL frag code in particle drawing
Differential Revision: D2993
2018-01-29 15:51:23 -02:00
Clément Foucault a507c251b2 Eevee: Put all constant uniforms in a global UBO.
This is an optimization / cleanup commit.

The use of a global ubo remove lots of uniform lookups and only transfert data when needed.

Lots of renaming for more consistent codestyle.
2018-01-21 23:16:59 +01:00
Clément Foucault 8e35a9e4c7 Eevee: Perf: Update noises (in utilTex) via GPU drawing.
This leads to a ~3ms improvement of CPU time during drawing.
This prevent the rendering from being stalled waiting for the texture data to be transfered.
2018-01-17 14:02:48 +01:00
Clément Foucault aa0097ad5e DRW: Add instance data memory manager.
This is a special memory manager that keeps memory blocks ready to send as vbo data.
Since we loose which memory block was used each DRWShadingGroup we need to redistribute them in the same order/size to avoid to realloc each frame.
This is why DRWInstanceDatas are sorted in a list for each different data size.
2018-01-09 14:54:11 +01:00
mano-wii 375d27f230 Curve Edit Mode: Use curve handle theme colors 2018-01-09 13:30:30 +11:00
Clément Foucault 5b6cfa705c Eevee: Irradiance Visibility: Initial Implementation
This augment the existing irradiance grid with a new visibility precomputation.
We store a small shadowmap for each grid sample so that light does not leak through walls and such.

The visibility parameter are similar to the one used by the Variance Shadow Map for point lights.

Technical details:

We store the visibility in the same texture (array) as the irradiance itself (in order to reduce the number of sampler).
But the irradiance and the visibility are not the same data so we must encode them in order to use the same texture format.
We use RGBA8 normalized texture and encode irradiance as RGBE (shared exponent).
Using RGBE encoding instead of R11_G11_B10 may lead to some lighting changes, but quality seems to be nearly the same in my test cases.
Using full RGBA16/32F maybe a future option but that will require much more memory and reduce the perf significantly.

Visibility moments (VSM) are encoded as 16bits fixed point precision using a special range. This seems to retain enough precision for the needs.
Also interpolation does not seems to be big problem (even though it's incorrect).
2017-12-04 10:10:27 +01:00
Germano 88c88c4610 Fix T51210: Draw Manager: Support for Metaball Drawing
Differential Revision: D2914
2017-11-16 15:12:32 -02:00
Clément Foucault f8b1430566 Eevee: Initial Separable Subsurface Scattering implementation.
How to use:
- Enable subsurface scattering in the render options.
- Add Subsurface BSDF to your shader.
- Check "Screen Space Subsurface Scattering" in the material panel options.

This initial implementation has a few limitations:
- only supports gaussian SSS.
- Does not support principled shader.
- The radius parameters is baked down to a number of samples and then put into an UBO. This means the radius input socket cannot be used. You need to tweak the default vector directly.
- The "texture blur" is considered as always set to 1
2017-11-14 00:49:54 +01:00
Clément Foucault 345ffe3e4d Eevee: Effects: Split each effect in it's own file.
This also:
- make sure to only compile the shader needed by the active effects.
- same thing for the shading groups.
- disable TAA if motion blur is active (avoid infinite refresh).
2017-11-01 01:17:35 +01:00
mano-wii 8277bee748 Draw Manager: re-enable edit-mesh text overlay 2017-10-30 17:50:47 +11:00
Clément Foucault 66d8f82b83 Eevee: Overhaul the volumetric system.
The system now uses several 3D textures in order to decouple every steps of the volumetric rendering.

See https://www.ea.com/frostbite/news/physically-based-unified-volumetric-rendering-in-frostbite for more details.

On the technical side, instead of using a compute shader to populate the 3D textures we use layered rendering with a geometry shader to render 1 fullscreen triangle per 3D texture slice.
2017-10-27 22:49:15 +02:00
Clément Foucault 1054f65a29 Object Mode : Add probes data outlines and selectability
This required some small changes to the data display shaders so that they match the way the object mode renders them.
Strangely enough, I had to remove the normal attribute from the display code because it was being not bound as soon as I created another rendering call in object mode. The problem may be deeper but I did not have time for this so I derive the normal from the sphere pos.
2017-09-30 19:37:40 +02:00