[WIP] Freestyle contour mesh tessellation #48644

Closed
opened 2016-06-13 15:56:28 +02:00 by Sebastian Parborg · 14 comments

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:
compare.mkv

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.

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: [compare.mkv](https://archive.blender.org/developer/F316984/compare.mkv) 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.
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @ZedDB

Added subscriber: @ZedDB

Added subscriber: @Sergey

Added subscriber: @Sergey

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Author
Member

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

Bird.png
Squirrel.png

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.

Campbell requested some examples with characters so I took some from BBB: ![Bird.png](https://archive.blender.org/developer/F317146/Bird.png) ![Squirrel.png](https://archive.blender.org/developer/F317148/Squirrel.png) 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.
Author
Member

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.

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.
Member

Added subscriber: @kjym3

Added subscriber: @kjym3
Author
Member

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.
@ideasman42 @Sergey is this a know issue with sqrt3f/glibc?

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. @ideasman42 @Sergey is this a know issue with sqrt3f/glibc?
Member

Added subscriber: @JoshuaLeung

Added subscriber: @JoshuaLeung
Author
Member

A quick update. I've worked with the GSoC student YimingWu so see if my work would be useful with his LANPR solution (and it seems to be!).

I've ported my code to blender 2.8 and hosted it here:
https://github.com/DarkDefender/blender

I'm glad to say that is seems to work nicely and improves the results of both the offline LANPR and real time LANPR renders.

YimingWu reported it here:
https://twitter.com/ChengduLittleA/status/1016992667358584833
But I'll upload images of offline and realtime here also.

Offline improvement (monkey to the right is with tesselation):
cpu_test.png
Realtime (white lines is the tesselated mesh):
real_time_test.png

A quick update. I've worked with the GSoC student YimingWu so see if my work would be useful with his LANPR solution (and it seems to be!). I've ported my code to blender 2.8 and hosted it here: https://github.com/DarkDefender/blender I'm glad to say that is seems to work nicely and improves the results of both the offline LANPR and real time LANPR renders. YimingWu reported it here: https://twitter.com/ChengduLittleA/status/1016992667358584833 But I'll upload images of offline and realtime here also. Offline improvement (monkey to the right is with tesselation): ![cpu_test.png](https://archive.blender.org/developer/F3912768/cpu_test.png) Realtime (white lines is the tesselated mesh): ![real_time_test.png](https://archive.blender.org/developer/F3912775/real_time_test.png)
Author
Member

comp.png
I just wanted to post an other update. Now I feel like the result of my modifier should have the same mesh output as the one in the original paper.
However, there are still some illogical linebreaks in the freestyle output. The mesh tesselation in those areas look fine, so I guess that to solve those we need to implement the second part of the paper where they modify freestyle.

I've also noticed that the thing that seriously slows down my code is the OSD mesh creation. On the squirrel (17 106 quads) OSD creation takes 4.346086 sec while the rest of my modifier code takes 3.414331. I'll try to multi thread a part of my code. If that goes well then I might push the time down to around 1 sec for the non OSD creation stuff.

Edit: Managed to multi thread the most expensive step (split ff bb edges) so now my modifer code has around 1sec execution time as I expected!

![comp.png](https://archive.blender.org/developer/F4138650/comp.png) I just wanted to post an other update. Now I feel like the result of my modifier should have the same mesh output as the one in the original paper. However, there are still some illogical linebreaks in the freestyle output. The mesh tesselation in those areas look fine, so I guess that to solve those we need to implement the second part of the paper where they modify freestyle. I've also noticed that the thing that seriously slows down my code is the OSD mesh creation. On the squirrel (17 106 quads) OSD creation takes 4.346086 sec while the rest of my modifier code takes 3.414331. I'll try to multi thread a part of my code. If that goes well then I might push the time down to around 1 sec for the non OSD creation stuff. Edit: Managed to multi thread the most expensive step (split ff bb edges) so now my modifer code has around 1sec execution time as I expected!

Added subscriber: @dfelinto

Added subscriber: @dfelinto

Changed status from 'Confirmed' to: 'Archived'

Changed status from 'Confirmed' to: 'Archived'
Dalai Felinto self-assigned this 2019-12-23 18:42:02 +01:00

Hi, thanks for your patch.

We are undergoing a Tracker Curfew where we are automatically closing old patches.

If you think the patch is still relevant please update and re-submit it. For new features make sure there is a clear design from the user level perspective.

Hi, thanks for your patch. We are undergoing a [Tracker Curfew ](https://code.blender.org/?p=3861) where we are automatically closing old patches. If you think the patch is still relevant please update and re-submit it. For new features make sure there is a clear design from the user level perspective.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#48644
No description provided.