Line Art further improvement list #87739
Open
opened 2021-04-23 09:40:55 +02:00 by YimingWu
·
70 comments
No Branch/Tag Specified
temp-sculpt-dyntopo-hive-alloc
main
blender-v3.6-release
tmp-usd-python-mtl
temp-sculpt-dyntopo
asset-browser-frontend-split
node-group-operators
brush-assets-project
asset-shelf
blender-v2.93-release
blender-v3.3-release
universal-scene-description
temp-sculpt-attr-api
blender-v3.5-release
realtime-clock
sculpt-dev
gpencil-next
bevelv2
microfacet_hair
blender-projects-basics
principled-v2
v3.3.7
v2.93.18
v3.5.1
v3.3.6
v2.93.17
v3.5.0
v2.93.16
v3.3.5
v3.3.4
v2.93.15
v2.93.14
v3.3.3
v2.93.13
v2.93.12
v3.4.1
v3.3.2
v3.4.0
v3.3.1
v2.93.11
v3.3.0
v3.2.2
v2.93.10
v3.2.1
v3.2.0
v2.83.20
v2.93.9
v3.1.2
v3.1.1
v3.1.0
v2.83.19
v2.93.8
v3.0.1
v2.93.7
v3.0.0
v2.93.6
v2.93.5
v2.83.18
v2.93.4
v2.93.3
v2.83.17
v2.93.2
v2.93.1
v2.83.16
v2.93.0
v2.83.15
v2.83.14
v2.83.13
v2.92.0
v2.83.12
v2.91.2
v2.83.10
v2.91.0
v2.83.9
v2.83.8
v2.83.7
v2.90.1
v2.83.6.1
v2.83.6
v2.90.0
v2.83.5
v2.83.4
v2.83.3
v2.83.2
v2.83.1
v2.83
v2.82a
v2.82
v2.81a
v2.81
v2.80
v2.80-rc3
v2.80-rc2
v2.80-rc1
v2.79b
v2.79a
v2.79
v2.79-rc2
v2.79-rc1
v2.78c
v2.78b
v2.78a
v2.78
v2.78-rc2
v2.78-rc1
v2.77a
v2.77
v2.77-rc2
v2.77-rc1
v2.76b
v2.76a
v2.76
v2.76-rc3
v2.76-rc2
v2.76-rc1
v2.75a
v2.75
v2.75-rc2
v2.75-rc1
v2.74
v2.74-rc4
v2.74-rc3
v2.74-rc2
v2.74-rc1
v2.73a
v2.73
v2.73-rc1
v2.72b
2.72b
v2.72a
v2.72
v2.72-rc1
v2.71
v2.71-rc2
v2.71-rc1
v2.70a
v2.70
v2.70-rc2
v2.70-rc
v2.69
v2.68a
v2.68
v2.67b
v2.67a
v2.67
v2.66a
v2.66
v2.65a
v2.65
v2.64a
v2.64
v2.63a
v2.63
v2.61
v2.60a
v2.60
v2.59
v2.58a
v2.58
v2.57b
v2.57a
v2.57
v2.56a
v2.56
v2.55
v2.54
v2.53
v2.52
v2.51
v2.50
v2.49b
v2.49a
v2.49
v2.48a
v2.48
v2.47
v2.46
v2.45
v2.44
v2.43
v2.42a
v2.42
v2.41
v2.40
v2.37a
v2.37
v2.36
v2.35a
v2.35
v2.34
v2.33a
v2.33
v2.32
v2.31a
v2.31
v2.30
v2.28c
v2.28a
v2.28
v2.27
v2.26
v2.25
Labels
Clear labels
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
Apply labels
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
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
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
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
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
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
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 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
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
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
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
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
Milestone
Set milestone
Clear milestone
No items
No Milestone
Projects
Set Project
Clear projects
No project
Assignees
Assign users
Clear assignees
No Assignees
21 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#87739
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Removed achieved goals from the list as of 2021/03/01. Added new items as development requires.
Line Art Further Improvement Proposal
Current major problems
Line Art GPencil modifier has been useful in creating feature lines for 3d scenes. However since its development and integration, users have found some problems with the implementation and it would be nice to address them in further updates. Those problems are mainly:
Object Loading
Currently line art is inefficient in multiple aspects. First of all, it needs to load geometries with adjacent information, but the implementation right now uses
BMesh
conversion during loading, which is very inefficient (it's single threaded and it does a lot of extra work that line art doesn't end up using) A specialized line art loading code is needed to speed up this stage.Sebastian provided flame graphs showing major performance bottleneck in geometry loading and intersection calculation in current line art (master) code. The time range showing in those graphs represents one full line art calculation for test scene "Mr.Elephant", which has some imbalanced mesh density across the object list.
Seen below in blue is the object loader code execution time. Here 10s-23s is line art calculation, and one thread in the object loader worked way too long and took more than half the total time in that stage.
Overall calculation performance
The 2d acceleration structure I developed for line art couldn't utilize machine's full capacity, end up having way too much duplicated iteration during calculation, which needs improvement. Related to this design, it's relatively hard to have a efficiently threaded triangle intersection detection (one of the major advantage of line art over freestyle), this further slowed down everything.
Seen below in blue is the 2D acceleration structure building time, same file and time range as above example, as it indicated, roughly one thirds of the time (~4s) is spent building the acceleration structure, but the later occlusion query took less than half a second.
Seen below in blue is for when intersection calculation is turned on, the intersection+acceleration structure building time. Considerable performance bottleneck (17 seconds for this stage alone) can be seen clearly.
In
temp-lineart-contained
branch, an ad-hoc threading solution is in place on top of the existing code, and it does improve the performance to a extent, however the result still isn't anywhere near as ideal.Silhouette/Shadow support
Due to the unique nature of how line art calculates/registers edge visibility, it's rather complicated to have a silhouette support (which is probably one of the easiest kind of line detection in most feature line renderers), but it's still quite vital in a lot of line-based artworks. Some time ago I have researched the method that line art could use to calculate silhouette and projection shadows in similar fashion arithmetically, and a
lineart-shadow
branch has a implementation of that. However, it suffers from the same performance problem as mentioned before.Stroke smoothness
Stroke smoothness in mesh feature line rendering has always been a problem in geometry-based feature line rendering techniques. Line art already has a few ways to let uses smooth out the output, however the stroke quality is still not ideal in a lot of cases, especially in rendering subdivided meshes. Jaggy stroke and overlapped stroke is still not tackled from the root cause.
Current main goals
So to fix those problems, there are some improvements we can make:
atomic compare and swap
method for adding triangles, this is the fastest method so far.Updates as of 0516:
(All updates are in the weekly nodes on the wiki )
add_triangles
, which provided a lot of performance boost on the legacy acceleration algorithm. Embree turned out to be "not that helpful". Here's the performance result as of now:Development plan
Embree core
Time: 2 weeks for fully working core. More time for geometry checking and debugging
Rewrite the line art triangle intersection and occlusion code with embree acceleration. The goal is for line art to run much faster, and potentially get rid of long hanging time when there's dense triangle concentrations at one point in image space.
Embree is supposed to be well accelerated than my own acceleration structure, but these two methods handles "potential collision" differently, embree in 3d, while line art original uses 2d, so depends on scene structure and camera viewing angle, performance may vary, needs testing after the code is done and see how much it really improves. A preliminary embree-based tri-tri intersection code is done, and it showed reasonable acceleration for intersection detection stage. So it shows promise.
Current embree (tri-tri intersection only) performance improvements:
Another great benefit of using embree is that the code can be more easily put on GPU, further speed up calculation (GPU embree line art not yet in the scope of this project).
A fully working new core should take no more than 2 weeks to code from current status (maybe add a little time for just doing math stuff). I could picture there being precision-related bugs that may need (way?)more time to track down, but there could also be very few to none of them, in my experience with legacy line art code, the image-space cutting function was pretty robust, but the triangle/line geometry side is always troublesome, I need to look at the situation after initial implementation.
Faster object loading
Time: 1 week or less for it to work.
Again this just a performance goal. @ZedDB did some work on this, and it's also promising. The main principle is to avoid converting to
BMesh
to get the adjacent info. This should be quick to integrate into lineart embree.Shadow casting and silhouette support
Time: 2.5(?) week or less for shadow to work, then should take about 2 weeks for silhouette stuff to work.
This is to use embree to support shadow casting. If embree turns out to be not beneficial, then I'll multi thread current shadow code. There's already a
lineart-shadow
branch that utilizes legacy line art algorithm to cast shadows. Works accurately (I only find very few missing lines in a city scape scene where there are a lot of buildings and overlapped edges), but not multi-threaded, so it's slow.Silhouette calculation in principle shares the same "shadow result" as if the light is at the camera position. So this has to be done after shadow casting support is working correctly.
Example of current shadow implementation, showing accurate projection result:
There's one problem on shadow/silhouette support, that is line art has to run two times, first time to project shadow (almost like creating a shadow buffer in real time graphics), then run it again from actual camera. So I think in terms of UI representation there needs some additional thoughts.
Maybe 4 weeks for these, likely to take less time, depending on how robust the code worked.
Update on 3/31:
It's possible to do a overall selection of "inside/outside shadow region", which means we can erase lines in lit/dark regions selectively. This can be done if I figured out a way to make sure the indices would match between two line art runs.
Stroke quality improvements
Sebastian has implemented a smooth contour modifier (for mesh) some time ago based on Pierre Bénard et.al.
If we successfully integrate this modifier, then we can remove some of those chain smooth options inside line art modifier, because those are more like a hack and doesn't solve the real problem in the geometry. Smooth contour modifier can also be beneficial to generating a smooth light/shadow separation line.
The actual algorithm for overlapping stroke reduction needs some further research, the necessity of implementing one depends on the result on the smooth contour modifier, if it gives good stroke quality with basic line art chaining, this overlapping reduction algorithm may or may not be needed.
Some "nice to have" features
These features are not in high priority, but will still benefit some special use cases. I'll have some notes updated down below as I go.
Now use thebGPDspoint::surface_normal- [x]
approach.Generate flattened 2D strokes directly from Line Art to avoid re-projection later on.(See below)Normal controlled thickness
Normal controlled thickness can be a great way to convey lighting direction in NPR renderings. (Sorry I don't have a screenshot right now but here's a mock up) should looks like this:
Directly output 2D strokes [?]
After some further discussion with Sebastian, we indeed settled down on not caring about 2D and use a dedicated reproject modifier for now. The main reason being line art modifier itself is already very cluttered, adding more features would make it even more complex.
Original description: (I thought I still just keep this option here so I don't forget this stuff)
Suggestive contour
Freestyle has this implemented, but this could make current line art core algorithm unnecessarily complex (due to handling line-on-surface situation), and it's hardly useful in meshes with medium to sparse triangle density. So maybe not needed at the moment.
Manga camera distortion
Manga camera distortion feature will utilize multiple stages of frustum in different FOV to distort perspective at different depths. Principally it should work like this:
A manually composited result (Link1 Link2 ) showing two-segmented FOV configuration, where the red segment (closer) has larger FOV and the green section has smaller FOV, ending up stretching the geometry closest to the camera:
Manual camera set up, with near/far clipping tuned to align with one another:
Note: this feature would be best if implemented into render engine level, but it can be done with line art efficiently in one go.
Added subscriber: @ChengduLittleA
Added subscriber: @antoniov
Not sure if you have included to improve the
In Front
problem in any of the points. If not, please, add it to the list because this is a critical feature.Added subscriber: @laurelkeys
Added subscriber: @GeorgiaPacific
Added subscriber: @bunny
Often use nested Collections to keep characters/scenes organized.
It would be great if Collections behaved the same as Objects with regard to the Line Art Usage parameter and inheritance, so that child Collections could override their parent Collection's lineart_usage setting the same way individual Objects can.
Humm... interesting, that's indeed some valid use. I'll see if I can make that happen.
Added subscriber: @newlifefoundationss
This comment was removed by @newlifefoundationss
This comment was removed by @newlifefoundationss
Added subscriber: @dr.sybren
Added subscriber: @zzt
This comment was removed by @zzt
Humm... I'll take a look
Removed subscribers: @dr.sybren, @newlifefoundationss
Removed subscriber: @laurelkeys
This issue was referenced by
6ad4b8b764
Changed status from 'Needs Triage' to: 'Confirmed'
Removed subscriber: @zzt
This issue was referenced by
1b07b7a068
This issue was referenced by
247abdbf41
This issue was referenced by
841df831e8
This issue was referenced by
3558bb8eae
This issue was referenced by
df7db41e1b
This issue was referenced by
d1e0059eac
This issue was referenced by
8e9d06f5a0
This issue was referenced by
c1cf66bff3
This issue was referenced by
80f7bc6d8e
This issue was referenced by
c3ef1c15f5
This issue was referenced by
efbd36429a
This issue was referenced by
ec831ce5df
Added subscriber: @brecht
Detaching task from a specific Blender release. In general this should only be used when the feature is being worked on and targeted for a specific release, rather than a general module task.
Added subscriber: @Garek
This issue was referenced by
40c8e23d48
This issue was referenced by
5ae76fae90
This issue was referenced by
579e8ebe79
This issue was referenced by
dde997086c
Added subscriber: @ZedDB
Added subscriber: @Sergey
The goals of the project and overall proposal in the development plan sounds good to me! There are few things which are related to Embree which would be very nice to clarify.
Currently Embree does not support GPU acceleration. Even if it comes there the timeframe and supported hardware and backend is unknown. To me it does not seem easy at all to put Embree onto GPU.
Embree does not need adjacency, so I am not really sure what you mean by integrating adjacency into lineart Embree.
This is my fault, I thought Embree had a GPU backend already, so this is misinformation from my part.
However, if we rewrite the core occlusion checks in LineArt to use a BVH structure and do standard tri x tri intersection checks, then it would probably be easier to port that code to run on the GPU than the current implementation.
That sentence could be clarified.
What it means is that the main goal of the object geometry loader rewrite is to skip the conversion to BMesh.
We used that conversion to get adjacency info that is needed to detect creases or other surface features.
The "This should be quick to integrate into lineart embree." is more of an off hand comment that if we do the Embree re-write, this shouldn't need any special adoption or rework as we don't need to adapt this change to the Embree rewrite.
Very interesting proposal. There are some points I would like to know if it's possible to implement or not.
When you bake a LineArt modifier, the real strokes are created and there are two possible improvements here:
Be able to keep all drawing flat (reprojected) in a plane. Sometimes the final use is a 2D flat drawing and to have a 3D strokes is not practical.
Related to point 1) is the option to determine and apply the thickness of the line relative to distance of the camera in reprojected flat drawing.
For example, if the drawing in 3D is far from camera, the thickness of the line would be thinner due perspective effect, but if we convert to flat, the thickness of the line would be the same and the perspective effect will be ruined.
This thinner line in flat reproject logic could be implemented in the reproject operator too.
Added subscriber: @frogstomp-4
@antoniov I see you are addressing the long standing request about stroke thickness when camera reproject is used, thank you :)
However I think this would better be solved in an existing operator like "Bake grease pencil animation to strokes".
The reasoning is, that this would allow to apply the same logic in a broader sense, not just with lineart.. you Might want to block out town, use grease pencil for line generation and also draw on surface of those block, then bake and join objects and reproject. There you'd want to thickness applied on reprojection, be it lineart generated or hand drawn.
The missing part in stroke reprojection with bake operator is still that in order to produce lineart for storyboarding from multiple angles, we would like to reproject to a single plane instead of reprojection plane moving with camera.
So long story short.. would rather see this functionality in an operator to cover more cases.
This was discussed when LineArt was first implemented as a modifier.
The conclusion then was that we already have a "flatten strokes" operator that we can reuse as a new modifier.
By having it as a modifier it can be reused in other non LineArt related tasks and would allow for much more options on how to flatten the strokes.
To me this is not really LineArt related as it is not the only case where you would want to flatten already drawn GP strokes.
I think this is an other feature for the "Flatten strokes" modifier/operator. This is because it is up to the flattening operator to handle any "data loss" like the actual depth of the strokes.
Ditto (but also as a modifier too as I stated). :)
Having these features as a modifier would be great, but also designing so that we can reuse the same
BKE_gpencil....
function to be reused in the reproject operator... I mean, have both modifier and bake operator options.Ahh I haven't been looking at this thread...
Yes, reproject modifier sounds most natural to me. Although there is already line results in 2d in line art, it's just not generated into strokes because there's only XY in framebuffer coordinates, so technically we don't really need a reproject modifier [if its sole purpose is flattening line art], maybe in line art we can specify a projection depth and then those strokes will appear at that distance from the camera in a plane.
Right, that will have to be in consideration.
For embree & gpu, I think if it doesn't run on GPU at all, we at least get the CPU side speed up, then maybe if we can port some long iterations onto GPU after embree generated pairs, that could also work (or maybe not, due to transfer bottle neck). The entire embree thing for line art is in experimental so I don't know what exactly the performance is gonna look like.
Added subscriber: @JSM
Added subscriber: @hzuika
Added subscriber: @okuma_10
Since there will be work on GP. Can I propose to expose or implement a way to assign a view bound texture coordinate for GP material's fill->texture feature.

At the moment each GP verts have UV coordinates that are generated at creation. Thus each new "shape" created with "fill" will have different oriented texture.
What I'm suggesting is to have the ability to also, use UV coordinates that are based on the view. Something like gl_FragCoord.xy in fragment shaders. Which will make the shapes appear as a cutout into a homogeneous texture.
Here are examples of what I mean
Krita's Fill layer uses pixar's SeExpr. The shader in the krita example is out of the box and oddly it uses the the document size for the dot generation, so it's more of a ellipse than a circle. Still it's a good example of what I am proposing.
Added subscriber: @mendio
@okuma_10 Hi! This is a quite interesting use case. I'd suggest @antoniov or @mendio to look at it or maybe move this to generic gpencil/rendering task?
Added subscriber: @fclem
I guess this is more for @fclem and the new Eevee implementation.
Added subscriber: @TinyNick
This issue was referenced by
03aba8046e
Added subscriber: @Hologram
Added subscriber: @Yuro
This issue was referenced by
2719869a2a
This issue was referenced by
369f652c80
This issue was referenced by
9f8254fd34
This issue was referenced by
6f00b1500c
This issue was referenced by
14a5a91e0e
Added subscriber: @RobertS
Is it possible to test the lineart-shadow branch without having to built it yourself? It apparently has performance issues, but it surely can't be worse than #102913?
The lineart shadow feature is already merged into master.
You don't need to use any special branch to use it.
Thank you for the information. What about the silhouette rendering of individual objects (including masking of partial occlusion)?
Is there updated documentation for this? I did not get any shadow rendering when I tried grease pencil line art on a collection.