Page MenuHome

Silhouette Overlap Overlay

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



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

rB Blender

Event Timeline

Sergey Sharybin (sergey) added inline comments.

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


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.

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
1 ↗(On Diff #10453)

This should go to gpu_shader_uniform_id_frag.glsl

1 ↗(On Diff #10453)

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

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.

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

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?

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.

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.


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


prefer colorBuffer for consistency.


normalBuffer with a comment that it's viewspace.


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


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


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