Page MenuHome

Silhouette Overlap Overlay
ClosedPublic

Authored by Jeroen Bakker (jbakker) on Apr 23 2018, 3:03 PM.

Details

Summary

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.

Diff Detail

Repository
rB Blender

Event Timeline

Sergey Sharybin (sergey) added inline comments.
source/blender/draw/engines/workbench/workbench_materials.c
59

Don't use statics. At least make it a state type of a thing inside of DrawContext.

60

Style: opening parenthesis goes on the next line.

Abandon will use arcanist. Also did the comments Sergey asked.

Clément Foucault (fclem) requested changes to this revision.Apr 23 2018, 3:48 PM
Clément Foucault (fclem) added inline comments.
source/blender/draw/engines/workbench/workbench_materials.c
59

Dont polute DrawContext with engine specific data. Use ViewLayerEngineData (per viewlayer storage) or StorageList (per viewport).

This revision now requires changes to proceed.Apr 23 2018, 3:48 PM
source/blender/draw/modes/shaders/overlay_object_data_frag.glsl
1 ↗(On Diff #10453)

This should go to gpu_shader_uniform_id_frag.glsl

source/blender/draw/modes/shaders/overlay_object_data_vert.glsl
1 ↗(On Diff #10453)

this file is useless just use the corresponding gpu_shader_....

source/blender/draw/modes/shaders/overlay_object_overlap_frag.glsl
16 ↗(On Diff #10453)

use texelFetchOffset for readability

23 ↗(On Diff #10453)

use equal(ivec4, ivec4) for the comparison and a dot product to sum them.

dot(vec4(comparison_result), vec4(1.0/4.0)) will give you the normalized value you want.

  • Workbench: comments from sergey and clement
Jeroen Bakker (jbakker) marked 4 inline comments as done.Apr 23 2018, 4:24 PM
Jeroen Bakker (jbakker) added inline comments.
source/blender/draw/engines/workbench/workbench_materials.c
59

Note: the next_random_color_offset will be removed when using the hash that mont29 came up with (murmur on top of ob->idname and lib path)
Will work on that

source/blender/draw/modes/shaders/overlay_object_data_frag.glsl
1 ↗(On Diff #10453)

My idea was that the object_data would be able to write multiple data types like object_id, material_id, normals in a single pass.
I added this to a specific frag shader, with this in mind. Are these options also usefull to add to a generic shader where defines will determine what the buffers are drawn?

source/blender/draw/modes/shaders/overlay_object_data_vert.glsl
1 ↗(On Diff #10453)

Same comment as above.

In case it's useful, for the "Object Info" shading node we also have randomization per object, see computation of dob->random_id in make_dupli().

The user of persistent_id there makes sure that objects instanced multiple times by duplis will still get a different color even if their name is the same. I'm not sure if that's useful for this overlay or not.

@Brecht Van Lommel (brecht) thanks for the hint will look into it.

As discussed yesterday with @Clément Foucault (fclem) we will move the rendering of the outline to the workbench engine. We already planned that the workbench engine would be a deferred renderer. The consequence is that the Scene lighting should also implement this eventually.

  • Workbench: Implemented as deferred rendering
  • Workbench: Enable Sculptmode for workbench

Some notes on the glsl code.

source/blender/draw/engines/workbench/shaders/workbench_deferred_mix_frag.glsl
9 ↗(On Diff #10462)

Use an UBO instead of a lot of uniforms, since they won't change at all during the whole frame/redrawn. Also use camel case for thoses.

20 ↗(On Diff #10462)

It's not normalized but a clamped dot. Also nice to know that clamp(x, 0.0, 1.0) (aka saturate(x) ) is faster than max(x, 0.0) if you don't care about the top values.

28 ↗(On Diff #10462)

I'm guessing the direction will change in the future? If not just use clamp(N.x, 0.0, 1.0) .

48 ↗(On Diff #10462)

Dont pass the light color like this. Use an array or just get them from the (future) UBO directly inside the function. Depends on if the function will be reused.

57 ↗(On Diff #10462)

what about splitting this to its own file? this way it's easier to share implementation with scene lighting mode.

57 ↗(On Diff #10462)

Style: Don't use cardinal direction. Use top/bottom/left/right. Can use t,b,l,r for shorter vars but I would rather even use a ivec4 to store them directly, simplifying the code.

Jeroen Bakker (jbakker) marked 3 inline comments as done.
  • Workbench: Solved GLSL comments D3174

Fixed some GLSL implementation issues

  • Added UBO
  • Optimized GLSL
Jeroen Bakker (jbakker) marked an inline comment as done.
  • Workbench: Overlap

Looks good to me now.

This revision is now accepted and ready to land.Apr 24 2018, 4:47 PM
Jeroen Bakker (jbakker) marked an inline comment as done.
  • Workbench: GLSL rework
  • Workbench: Synced GLSL data types
This revision was automatically updated to reflect the committed changes.

Here are some codestyle and perf improvement. You can see the perf impact by using the debug value (Ctrl+atl+D) set to > 20. Each values after 20 is unfolding the GPU timing tree. 24 should be enough if you don't have much stats nesting.

source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl
5

Rename in depthBuffer. depth should be the result of sampling this texture.

6

prefer colorBuffer for consistency.

7

normalBuffer with a comment that it's viewspace.

20

Style: use camel case only for uniforms or varyings. Other vars should be snake case.

source/blender/draw/engines/workbench/workbench_materials.c
181

You went full bananas on this! Use DRW_TEX_RGBA_8 for color. No need for HDR content here.

182

... and compress the normal like the clay engine does. Use DRW_TEX_RG_8.