Page MenuHome

Overlay: Retopology
Needs RevisionPublic

Authored by Jeroen Bakker (jbakker) on Sep 27 2019, 4:32 PM.
"Love" token, awarded by hitrpr."Love" token, awarded by Chromauron."Love" token, awarded by Serva."Love" token, awarded by 14AUDDIN."Love" token, awarded by Debuk."Love" token, awarded by ZackMercury."Like" token, awarded by andreasus."100" token, awarded by 616."Love" token, awarded by gwobbler."Love" token, awarded by jmztn."Like" token, awarded by belich."Love" token, awarded by tilapiatsu."100" token, awarded by Mephisto."Burninate" token, awarded by DotBow."Love" token, awarded by brilliant_ape."Mountain of Wealth" token, awarded by TheAngerSpecialist."Mountain of Wealth" token, awarded by franMarz."Love" token, awarded by undo."Orange Medal" token, awarded by billreynish."Love" token, awarded by Rusculleda."Like" token, awarded by erickblender."Love" token, awarded by xorrito."Love" token, awarded by roman13."Love" token, awarded by andruxa696."Love" token, awarded by Brandon777."100" token, awarded by Frozen_Death_Knight."Love" token, awarded by michaelknubben."Love" token, awarded by Alrob."Like" token, awarded by 1D_Inc."Love" token, awarded by amonpaike.



This patch started out as a prototype for a retopology overlay. Before we started there were
several ideas how to tackle this issue (Frontface Backface and average back+front face shifting)

In the end we go the best results by mixing back and front depth buffers including a slider. With
this situation users can control what suits best for their needs.

And this patch needs a lot of testing it changes the Depth buffer and by doing that it can
intervene with the workings of other tools that needs the original depth buffer.

Known Limitation

  • When using modifiers make sure you project the edge cage on the modifiers. Otherwise the geometry generated by the modifiers will not be visible as it is not part of the edit data. In edit mode a shaded version of the mesh is drawn by the active render engine, but for retopology we can't. There not a good way how to solve this.

Future developments

  • When slider is set to 0.0 we should not do any depth testing. As backfaces could become visible we should separate the color drawing and the alpha blending.
  • Improve snapping tools with a collection to snap against. As how we could see it this collection might be select-able per mesh. The snapping tools will have an option to use this collection. (Use Retopology Collection) This needs further design.
  • After the snapping tools we could improve the drawing of the retopology overlay by only looking at the depth of objects that are in the depth buffer.
  • Add option to draw the retopology faces using other colors like material viewport colors or vertex colors.
  • Enable this addon when in sculpt mode. The new overlay engine should support this, but sculpt drawing is always a hassle so will not include that in the first release.

Diff Detail

rB Blender
T70267 (branched from master)
Build Status
Buildable 6483
Build 6483: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

@Erick Tukuniata (erickblender) Thanks for the feedback!

The UX issues I'll leave to the tool developers, they are more familiar with the use-cases and consequences. I stick to the rendering.

That said..... we use a stencil buffer and that introduces the AA artifacts

Trickery has been added to get most of the AA working again. I haven't been able to find a good solution to remove the rest.
Implementing the overlay without the stencil buffer would slow down the drawing.

@Lucas (xorrito) enabling this mode in sculpting is complex. I am proposing changes to the drawing code that might make this possible eventually, but that needs to be discussed and agreed upon.

I gave myself the pleasure of testing this patch by retopoing an old sculpt here are 3 more feedback:

  • Sometimes, i mean it, sometimes we can select the hidden part of the mesh ( the unwanted) with the circle selection tool. This is pretty undesirable effect special since with retopo we have snapping turn on the mesh

see video:

  • There is some kinds of glitch if the Dyntopo mesh is not thick enough. This is not a big deal, i wanted just to let you know about this. see video:

The third one is just the same above that you have already answered, it will be really really good to have this in sculpt mode for the use smooth brush.

Thanks and keep up good work :)

I agree, sculpt mode retopo overlay would be really nice. Especially with the awesome relax brush Pablo Dobarro is working on. (it seems almost special made for retopology.)

I will have a look at the circle selection. Thanks for reporting

The glitch I am aware of. I wasn't able to reduce these artifacts without adding more disturbing artifacts at this moment. What you see are front faces that are not hidden by other faces. I will have a go by using two depth buffers and see if these artifacts can be reduced. Will have some negative impact on performance

Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Oct 25 2019, 1:41 PM
Jeroen Bakker (jbakker) updated this revision to Diff 19252.EditedOct 29 2019, 4:39 PM

Added an option for averaging the depth. This will remove the need for the stencil buffer. Removes some artifacts, but introduces others. Will need to check if it is better or not.

Stencil method

Average Depth

Jeroen Bakker (jbakker) updated this revision to Diff 19268.EditedOct 30 2019, 11:51 AM
  • Added a slider to finetune the depth mixing

I would say all base features are added. and we could send this patch to review.

First look on the update, the slider value seems to be initialize with 50 and when adjusted it stays fixed at 1.
I will try it later with a character.

  • fix default depth_mix_factor to 0.5f when migrating old files

You're right. Was a left over from a previous test. Have added a fix.
Would love to hear what you think about it now.

Yo Jeroen can you give us some love, the wire display is so messy in the current master, see T72713

Updated retopology overlay to new overlay engine.

Still need to review the code myself, before sending it for review

Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Jan 8 2020, 11:29 AM

This is a brown color. Any feedback on a better default color would be appreciated. For now we should set it to the defaults we had. (0.4, 0.5 0.2, 0.2)


rename to do_retopology


Test if this is still needed. If not needed we should remove this line and its uses.


We should use pd->overlay.edit_flag. Otherwise the Viewport Hide Overlays has no effect


Remove comment, doesn't seem to be needed.


Unused so remove it


remove empty line

85 ↗(On Diff #20681)


35 ↗(On Diff #20681)

revert these changes. We could use it, but that need additional shaders.

112 ↗(On Diff #20681)


75 ↗(On Diff #20681)



Use this to remove drawing artifacts


Face color used in the retopology overlay

Solved comments from code review.
There is still an issue left when using for example modifiers

Would love to hear what you think about it now.

It seems like i missed this comment, sorry for that. Feel free to poke me when you want me to test it again :)

Use custom vertex shader so selected faces are drawn correctly

Yo @Jeroen Bakker (jbakker) i tried to test this patch but i m having hard to build, i m getting this error. Can you rebase it on the master?

Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)

Fixed crash when drawing for selection

Rebased with latest master

Clément Foucault (fclem) requested changes to this revision.Feb 7 2020, 7:28 PM

Ok base review of the functionalities:

  • It does not work with XRay mode.
  • The Show faces seems redundant with the Overlay > Mesh Edit Mode > Faces option we already have. Moreover I cannot make it to work?! (Edit: I had to reset the theme for it to work so I think that's ok).
  • I'm unconvinced by the depth mixing. It's too much failure prone, needs more raster passes, complexify the code.


  • Could have a setting to cull the backfaces. On by default.
  • I'm still in favor of a simple depth bias. To be user friendly, it would be in world space (or object space, but not NDC space like the regular depth bias we use).
  • If you really want to use some depth peeling thingamajig, l would do a second depth test inside the edit mode shaders. like : if (gl_FragDepth - ws_bias < frontface_depth && gl_FragDepth - ws_bias < backface_depth) {do_output;} else {discard;}. This test should be optional as it does not work if the target geometry is non manifold.
  • For a moment I had the idea of doing a mesh pass inside the workbench (so that it inherits all the shading configuration) just by modifying the object matrix to include the bias. This could be very confusing because only working in workbench mode but would fix the issue that @Julien Kaspar (JulienKaspar) has (just toggling the overlays would show the bare retopo mesh still on top of the normal one). I don't know if this is a good idea overall.


  • I would put the panel options just under the Mesh Edit Mode section and not below the Normals display section.
  • if we go for a world/object space bias, we should have a slide with sensible default range (maybe in term of percentage of object bounding size) and open range if user needs to input really high value.

I understand what the needs are: being able to overlay a mesh that is maybe beneath the surface without faces from behind small areas poking through. But I fear there is no easy silver bullet for this problem and we should go for the easiest solution from UX/perf perspective.


Why do we need another color? Can't we use the object color for that? Why using the default edit face color does not suits our needs?


I'm not convinced we need to separate into another file.

This revision now requires changes to proceed.Feb 7 2020, 7:28 PM

I have tested this patch the other day, for me the big issue remain, selecting vertices when they are not visible, like i pointed above or the video below

  • Sometimes, i mean it, sometimes we can select the hidden part of the mesh ( the unwanted) with the circle selection tool. This is pretty undesirable effect special since with retopo we have snapping turn on the mesh

see video:

Yo @Jeroen Bakker (jbakker) can we please have this one in Blender 2.83? Otherwise it will be a long wait with upcoming LTS program

Debuk (Debuk) added a comment.EditedApr 14 2020, 12:55 PM

@Jeroen Bakker (jbakker) : I also hope this is still on track for 2.83. If there are some concerns, can we at least have this included and activatable as experimental feature in master.

This patch will not make it into 2.83. At this moment the project needs to be redone and my priorities are elsewhere without any sight when I get time for it. Anyone who want to take over, feel free.