Page MenuHome

LANPR line rendering (summer of code)
AbandonedPublic

Authored by YimingWu (NicksBest) on Aug 9 2019, 3:28 AM.
Tokens
"100" token, awarded by MARodionov."Love" token, awarded by Pipeliner."Love" token, awarded by captGuimbal."Love" token, awarded by Taiwofolu."Love" token, awarded by hitrpr."Yellow Medal" token, awarded by franMarz."Love" token, awarded by gaonirico."Love" token, awarded by Okavango."Love" token, awarded by mistajuliax."Love" token, awarded by belich."Love" token, awarded by samytichadou."Love" token, awarded by Way."Love" token, awarded by kynu."Like" token, awarded by HARDNAX."Manufacturing Defect?" token, awarded by momotron2000."Love" token, awarded by johantri.

Details

Summary

LANPR Patch

This is the patch for soc-2019-npr branch. Now modified as containing only LANPR changes

This patch doesn't include the following:

  • GPencil modifiers.
  • Smooth contour modifier.
  • SVG.
  • Affected UI scripts.
  • Freestyle changes.

Those above will be submitted in other diffs.

Update: The user manual can be accessed on the wiki page here: https://wiki.blender.org/wiki/User:Yiming/GSoC2019/LANPR_Document

Quick setup steps also included.

Diff Detail

Repository
rB Blender
Branch
lanpr-under-gp
Build Status
Buildable 9887
Build 9887: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
release/scripts/startup/bl_ui/properties_render.py
671

Python code style is to have two empty lines between top elements. and one line for other elements.

source/blender/draw/engines/lanpr/lanpr_all.h
81 ↗(On Diff #20031)

Bad names software

98 ↗(On Diff #20031)

bad naming. ms = multi sampling?

source/blender/draw/engines/lanpr/lanpr_cpu.c
254 ↗(On Diff #20031)

r.size is ignored?

265 ↗(On Diff #20031)

this seems like a hack. IMO the assert statement in DRW_view_create should be removed. Need to check with @Clément Foucault (fclem) and we should remove that BLI in master.

287 ↗(On Diff #20031)

Potential memory leak?

source/blender/draw/engines/lanpr/lanpr_dpix.c
94 ↗(On Diff #20031)

Use DRW_TEXTURE_FREE_SAFE

162 ↗(On Diff #20031)

Method is unused so can be removed.

202 ↗(On Diff #20031)

Naming is inconsistent. GPU Cache vs DPIX. It should be clear to the user what he needs to do.

source/blender/draw/engines/lanpr/lanpr_engine.c
143 ↗(On Diff #20031)

GPU_BATCH_DISCARD_SAFE

446 ↗(On Diff #20031)

unneeded

715 ↗(On Diff #20031)

Don't use 1, use true/false for booleans

source/blender/draw/engines/lanpr/shaders/lanpr_dpix_preview_geom.glsl
4 ↗(On Diff #20031)

bad naming? 0, 1 doesn't tell anything.

4 ↗(On Diff #20031)

use camelCasing for uniforms

20 ↗(On Diff #20031)

Redundant, they should be extracted from ProjectionMatrix

25 ↗(On Diff #20031)

These can be vec3 or vec4 and put the line thickness setting in the forth channel.

46 ↗(On Diff #20031)

don't use global variables. just add them to the parameters, makes the code more traceable.

50 ↗(On Diff #20031)

don't use global variables when not needed, just add as a parameter, color can be a vec3 as its alpha is ignored.

52 ↗(On Diff #20031)

We should move the get_view_z_from_depth to a common place and use that.

66 ↗(On Diff #20031)

extract the calculation of the depth factor to a separate function. do the mixing in the draw_line function.

71 ↗(On Diff #20031)

use bool

78 ↗(On Diff #20031)

is this the same as clamp(1.0 - alpha_crease_fading, 0.0, 1.0)

84 ↗(On Diff #20031)

use lowercase for variables.

85 ↗(On Diff #20031)

lowercase

104 ↗(On Diff #20031)

best to calculate once, and reuse the calculated values.

130 ↗(On Diff #20031)

use clamp

source/blender/draw/engines/lanpr/shaders/lanpr_dpix_project_clip_frag.glsl
1 ↗(On Diff #20031)

Use common_view_lib

7 ↗(On Diff #20031)

convert these to a single int and add defines to extract the specific flag.

source/blender/draw/engines/lanpr/shaders/lanpr_software_chain_geom.glsl
10 ↗(On Diff #20031)

Combine multiple booleans into a flag.

56 ↗(On Diff #20031)

Combine in a single vec3

182 ↗(On Diff #20031)

use true/false for boolean comparison

182 ↗(On Diff #20031)

inverse can be

float thickness = mix(normal_thickness_start, normal_thickness_end, normal_effect_inverse? r:1.0-r);

actually it feels like the inversion is inversed....

191 ↗(On Diff #20031)

use defines for 0, 1, 2 it is hard to tell what the modes mean and that it is correct.

206 ↗(On Diff #20031)

This seems like a switch statement or at least if else

230 ↗(On Diff #20031)

Why do we need to correct the camera scale? Not sure where the 4 comes from

269 ↗(On Diff #20031)

x_scale and y_scale seems to be constant and could be calculated on the CPU and send as a vec2 uniform.

275 ↗(On Diff #20031)

vectorize when possible.

vec2 scale = vec2(x_scale, y_scale); 
LL.xy *= scale;
source/blender/editors/include/ED_lanpr.h
83 ↗(On Diff #20031)

Why store an double. at is a bad name.

source/blender/makesdna/DNA_scene_types.h
1668

Perhaps find a better name, master mode does not say anything to developers.

1668

We typically add a comment which DNAStruct and field this enum belongs to.

1669

Bad naming, LANPR is fully software.

1670

What is DPIX supposed to mean (delta pixel?) But think that this option should be renamed totally something else or explicitly be part of a design.

1695

bad naming, does not say a thing to users or developers

source/blender/makesrna/intern/rna_scene.c
7101

Bad naming. It does not tell to the user what this means. What I have found so far is that changes the occlusion calculation. so better name it something containing occlusion

7212

I understand this property, but how are we going to solve this. If a shader does not compile we need to know and fix this. Now it seems to be hidden and we will never get the signal that it doesn't work.

We must at least support our minimum requirements. Currently unclear if we do.

source/blender/python/intern/bpy_app_build_options.c
29

Strange code formatting. If clang is doing this, perhaps turn off clang for this code block. Having the options in a single line improves the readability.

This revision now requires changes to proceed.Dec 17 2019, 12:16 PM

Up to date with latest origin/master

use temp-lanpr-review branch to compile.

I am now able to use the temp-lanpr-review with git. I noted that current builds from "Experimental Builds" are incremented to Blender 2.82.6 from the buildbot, but the builds from this LANPR Branch only reference Blender 2.82.4

Is this correct?? from your understanding?

Trying to keep the builds contemporary to development progress. Great to see all of the effort. Thank you one and all.

So, I've been trying to review this, but am unable to get LANPR to actually display any lines. I've tested it on several different Macs here and all I see is a blank viewport. And when I go to add a new line layer, I get a segfault 11 every time.

It's possible that the issue is OS-specific, or that there is some other issue. If anyone has a moment to check if LANPR works ok on Mac, it'd be much appreciated. Thanks.

Hi @YimingWu (NicksBest) could you please use arcanist to update this patch? At the moment I cannot even try to build it with I do arc patch D5442

@Jeroen Bakker (jbakker):

I tried the quick setup, but that only showed me a black rendered viewport

I believe you need to enable "Auto Update" (or manually update it).

That said I did not manage to get this working combined with EEVEE or Cycles. Even after enabling it in the Cycles and EEVEE panels.

Currently LANPR is a render engine choice, to be made 'first' before any of the options. It doesn't work with Cycles or EeVee, but is independent, not 'integrated' like Freestyle, which is a "Post-Render" extra render process. Current build only includes 2.82.4 Blender, and does not include many of the more "Artistic" features and integration of Freestyle elements. It is also 'under-documented' regarding what options need to be turned on for which effect. I was hoping that it would be prioritized for the 2.83 release cycles, with these elements corrected, but the most recent Developer Notes make no mention of LANPR.

Currently LANPR is a render engine choice, to be made 'first' before any of the options. It doesn't work with Cycles or EeVee, but is independent, not 'integrated' like Freestyle, which is a "Post-Render" extra render process. Current build only includes 2.82.4 Blender, and does not include many of the more "Artistic" features and integration of Freestyle elements. It is also 'under-documented' regarding what options need to be turned on for which effect. I was hoping that it would be prioritized for the 2.83 release cycles, with these elements corrected, but the most recent Developer Notes make no mention of LANPR.

Most functions work as expected but linking/appending scenes and collections causes the build to crash.

Currently LANPR is a render engine choice, to be made 'first' before any of the options. It doesn't work with Cycles or EeVee, but is independent, not 'integrated' like Freestyle, which is a "Post-Render" extra render process. Current build only includes 2.82.4 Blender, and does not include many of the more "Artistic" features and integration of Freestyle elements. It is also 'under-documented' regarding what options need to be turned on for which effect. I was hoping that it would be prioritized for the 2.83 release cycles, with these elements corrected, but the most recent Developer Notes make no mention of LANPR.

This may be the reason that William and others couldn't get the MAC build to display (assuming that there is a current build for MAC??), as they were not choosing the LANPR Render Engine 'first' before any of the options. This is also why a more comprehensive documentation, perhaps by someone else on the review team might help. It is disappointing to see this project 'slip' past the 2.83 window, and no 'Real Time' enhancements of Freestyle, or better integration of Freestyle artistic choices and current omissions:
GPencil modifiers.
Smooth contour modifier.
SVG.
Affected UI scripts.
Freestyle changes.

I've also tried to build this for Mac. I've used the temp-lanpr-review branch, which I guess contains all latest changes. However, just by adding LANPR layers (using the Default button) and trying to Update while in "Render preview" Viewport shading mode I get the following errors:

GPUShader: compile error:
ERROR: 0:388: Use of undeclared identifier 'gl_FragData'
ERROR: 0:389: Use of undeclared identifier 'gl_FragData'
ERROR: 0:392: Use of undeclared identifier 'gl_FragData'
ERROR: 0:406: Use of undeclared identifier 'gl_FragData'
ERROR: 0:407: Use of undeclared identifier 'gl_FragData'
ERROR: 0:408: Use of undeclared identifier 'gl_FragData'
ERROR: 0:422: Use of undeclared identifier 'gl_FragData'
ERROR: 0:423: Use of undeclared identifier 'gl_FragData'
ERROR: 0:424: Use of undeclared identifier 'gl_FragData'
ERROR: 0:447: Use of undeclared identifier 'gl_FragData'
ERROR: 0:448: Use of undeclared identifier 'gl_FragData'
ERROR: 0:449: Use of undeclared identifier 'gl_FragData'
ERROR: 0:475: Use of undeclared identifier 'gl_FragData'
ERROR: 0:477: Use of undeclared identifier 'gl_FragData'

LANPR: DPIX transform shader compile error.GPUShader: compile error:
ERROR: 0:14: Use of undeclared identifier 'gl_FragData'

LANPR: DPIX transform shader compile error.GPUShader: compile error:
ERROR: 0:14: Use of undeclared identifier 'gl_FragData'

GPUShader: compile error:
ERROR: 0:14: Use of undeclared identifier 'gl_FragData'

There is also a backtrace, although I'm not sure how useful it is:

# backtrace
0   Blender                             0x000000010aa9ff57 BLI_system_backtrace + 55
1   Blender                             0x0000000104a4a739 sig_handle_crash + 361
2   libsystem_platform.dylib            0x00007fff62b05b5d _sigtramp + 29
3   ???                                 0x0000000000000000 0x0 + 0
4   Blender                             0x0000000108d8ebb7 drw_shgroup_init + 55
5   Blender                             0x0000000108d8f3d9 DRW_shgroup_create + 105
6   Blender                             0x0000000108de1ea2 lanpr_software_draw_scene + 1762
7   Blender                             0x0000000108de122e lanpr_draw_scene_exec + 222
8   Blender                             0x0000000108d8a12d drw_engines_draw_scene + 173
9   Blender                             0x0000000108d894c7 DRW_draw_render_loop_ex + 1607
10  Blender                             0x000000010921ab8d view3d_main_region_draw + 125
11  Blender                             0x00000001090025ca ED_region_do_draw + 362
12  Blender                             0x0000000104ecad7b wm_draw_update + 1899
13  Blender                             0x0000000104ec89a0 WM_main + 48
14  Blender                             0x0000000104a46f76 main + 934
15  libdyld.dylib                       0x00007fff6291a3d5 start + 1
16  ???                                 0x0000000000000001 0x0 + 1

So, I've been trying to review this, but am unable to get LANPR to actually display any lines. I've tested it on several different Macs here and all I see is a blank viewport. And when I go to add a new line layer, I get a segfault 11 every time.

It's possible that the issue is OS-specific, or that there is some other issue. If anyone has a moment to check if LANPR works ok on Mac, it'd be much appreciated. Thanks.

Building and testing temp-lanpr-review branch on osx (on different macs) can confirm the issues. Clicking on render image will render out the image correctly including lanpr lines though.

Updating grease pencil target isn't working anymore.
Used to work on soc-2019-npr branch.

All other issues (not rendering lines in viewport and crashing using LANPR as main renderer in render view mode) were already present back then.

Disregard . . I just updated my SVN and CMAKE to the latest versions and it builds correctly.


I encountered an error two(2) days ago, while trying to do the Win64 build for GraphicAll.org. It was not able to find LLVMX86AsmPrinter.lib. Now I had a different error, it could not find clangToolRefactor.lib. I will try again tomorrow, as I am overdue to post a new build to the community, and I don't know how to correct these kind of errors. Any help? Thank you all for the continued development efforts.

YimingWu (NicksBest) updated this revision to Diff 27360.EditedAug 3 2020, 2:41 PM
YimingWu (NicksBest) edited the summary of this revision. (Show Details)

New version of Line Art. Patch submitted from arc, let me check for problematic files first.

YimingWu (NicksBest) marked 10 inline comments as done.Aug 3 2020, 2:47 PM

Looks like there are some files are affected with wrong modifications as well. Let me fix those.

  • LineArt: Cleanup extra modifications caused by merging and stuff.
release/scripts/startup/bl_ui/properties_render.py
79–81

I'm not sure why it did the line break, maybe a autopep8 issue?

  • LineArt: cleanup function names.
  • LineArt: use LISTBASE_FOREACH in lineart_chain.c
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • LineArt: Intersection lines can now be selected by different collections if fully contained.
  • LineArt: Guard more for very short cut situations.
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • LineArt: Memory sync fixes for animation rendering.
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • LineArt: Linked files now support collection-in-collection type of linking.
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • Line Art: file r/w pointer clean-up for collection->object_cache_instanced.
  • LineArt: enable/disable duplicated objects in line art.
  • LineArt: metaballs/texts/curves/surfaces support.
  • LineArt: Prevent lines showing inside text object surface, disable crease.
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • LineArt: Transparency mask data in Material.
  • LineArt: Transparency mask selection in modifier.
  • LineArt: "Match" option in modifier settings.
  • LineArt: Fix compiler warnings and clang format
  • LineArt: Move Linea Art mask panel as subpanel
  • LineArt: The line art panel in material is for mesh not for grease pencil.
  • Merge branch 'master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • LineArt: BKE_scene_graph_update_for_newframe() new api.
  • LineArt: Camera shifting aspect ratio fix.
  • LineArt: Support for edge split.
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • LineArt: guard for no camera situations.
  • LineArt: GPencil modifier flag change to mode (wrong use of variable).
  • LineArt: Remove debug print.
  • Merge branch 'master' into lanpr-under-gp
  • LineArt: "Intersection Only" flag for objects/collections
  • Merge branch 'master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • Merge branch 'master' into lanpr-under-gp
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • LineArt: Prevent crash when using any sort of moving operators.
  • LineArt: Disable line art object viewport selection by default.
  • LineArt: Back-transform strokes to allow gp to sit at other positions.
  • LineArt: Basic background task canceling.
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • LineArt: Prompt on baking finish.
  • LineArt: Splitting limit for dense triangle situations.
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • LineArt: Feature line compatible clipping.
  • LineArt: Better manuverability with quick cancel.
  • LineArt: More fluent viewport manipulation (canceling sequence optimization)
  • LineArt: Slope throw away threshold in lineart_LineIntersectTest2d()
  • Cleanup: spelling
  • Cleanup: use doxy sections in interface_panels.c
  • Fix T80135: Duplicate doesn't preserve active spline
  • Cleanup 'make vertex parent' operator code.
  • LineArt: Better desctiption for enable linked objects
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • LineArt: added ratio() after interp() functions in math lib.
  • Merge remote-tracking branch 'origin/master' into lanpr-under-gp
  • LineArt: Names clean up.
  • LineArt: DNA/RNA cleanup.

This revision is closed. Move to new revision for more clear view.