[WIP] Freestyle contour mesh tessellation
Open, NormalPublic


I've implementeted the first tessellation part of the paper "Computing Smooth Surface Contours With Accurate Topology ( http://www.labri.fr/perso/pbenard/publications/contours/ ) as a modifier in blender.

Here is a video of the current progress. I've set freestyle to render contours and borders with line width starting at 1 and ending at 5:

Note that this might be a best case scenario.

The code is hosted on github at: https://github.com/DarkDefender/blender-npr-tess
(Look in "source/blender/modifiers/intern/MOD_mybesh.c")
You need opensubdiv 2.6.x to run it.

What is left to do is:

  • Port the code to the latest opensubdiv version
  • Lots of clean up in the code
  • Optimize (the code is currently single threaded)
  • Implement the second part of the paper.

Currently the code doesn't produce nice results for more complex meshes (like on suzanne). Because the opensubdiv version I use has a lot of bugs, (you can't subdivide a torus and there are errors in the computed limit surface on suzanne) I can't yet tell if it's a problem on my side or the opensubdiv side.

This is why I felt like this would be a good time to request help with porting the modifier to blender trunk.
Because this is my first blender project I have a strong feeling that I have done a lot of things overly complicated.

The help I specifically request is how and what functions I should use to call opensubdiv from blender proper. The old functions that I used previously has be removed from 3.x.x (IIRC). I'm a bit lost on how to do this with the new API to be honest...

I realize that this is quite a huge code dump and I will gladly answer any questions that might come up.
I would really like to have this included upstream (when it's ready) because I think that the improvments the paper does to the freestyle line chaining is needed if you want to use it in animation.


Sergey Sharybin (sergey) triaged this task as "Normal" priority.Jun 14 2016, 12:09 PM

Campbell requested some examples with characters so I took some from BBB:

Please note that the result could be better than this.

Firstly because this is a two part paper (I've only implemented the first part).
Secondly there are currently some issues with the tesselation that I don't know if it's a bug with my code or if it's just the way it is. The paper mentions that there will be tesselation errors (or problems might be a better word) that can't be fixed.

The second point is why I posted this here. I feel like I need to get some outside input on some things to be able to either solve the problems or decide that it's not feasible to try to solve them.

Just a quick heads up. I've managed to get the code to run in blender master and with opensubdiv 3.0.x

I will just spend quite a bit of time on bugfixing now. The result will hopefully be a lot better than the one I posted when I'm done.

I have uploaded the ported code to: https://github.com/DarkDefender/blender-npr-tess2

However I noticed that I run into a segfault in glibc:

#0  0x00007ffff222d4bf in __ieee754_log_fma4 () from /lib64/libm.so.6
#1  0x000000000276c94a in sqrt3f (f=3.66065979) at /home/zed/programmering/new_blender/blender/source/blender/blenlib/intern/math_base_inline.c:72
#2  0x00000000027736ae in get_k_r (eval=0x7fffd340e128, face_index=2551, u=0.311174393, v=0.67027092, cam_loc=0x7fffd747c290)
    at /home/zed/programmering/new_blender/blender/source/blender/modifiers/intern/MOD_mybmesh.c:581
#3  0x000000000277fbce in k_r_sign_cross (u=0x7fffd6c7f930, v=0x7fffd6c7f940)

I updated to glibc 2.23 (from 2.22) and it sadly didn't fix the issue.
@Campbell Barton (campbellbarton) @Sergey Sharybin (sergey) is this a know issue with sqrt3f/glibc?

Add Comment