Page MenuHome

soc-2018-npr development
Needs ReviewPublic

Authored by YimingWu (NicksBest) on Jun 26 2018, 3:57 AM.



Patches for soc-2018-npr development.

  • Created LANPR engine. Added files for it
    • see lanpr_engine.c lanpr_dpix.c lanpr_snake.c lanpr_ops.c lanpr_util.c lanpr_all.h lanpr_util.h
  • Implemented DPIX and SNAKE algorithm for feature line extraction.
  • Implemented simple viewport drawing code for realtime line extraction. (now deprecated for new line layer structure)
  • Implemented offline render calculations, including intersection calculation. See lanpr_ops.c, may move to a seperate file later.

main problems

  • Hard coded DPIX data buffer, which is 2048X2048, and DPIX uses 7 of them in RGBA32f format. this is too big for many cards, will make the size into auto-decide.
  • Offline caculation now inoperative because there are many pieces of code is in it's old format (ported from my standalone application) and waiting to be corrected.
  • There are some structs also from my standalone application and I move most of them here because it makes it easier to make use of existing code.

Diff Detail

rB Blender
Build Status
Buildable 1899
Build 1899: arc lint + arc unit

Event Timeline

  • rename LANPR_LineStyle into LANPR_LineLayer.
YimingWu (NicksBest) retitled this revision from Made a switch under Scene, and added files for LANPR adoptation. to soc-2018-npr development.Jun 26 2018, 4:15 AM
YimingWu (NicksBest) edited the summary of this revision. (Show Details)


  • Modified GUI, using new sub panel API.
  • Redo some of the line layer structure.
  • Multisample viewport preview. (F12 not working currently)
  • Fixed software rendering bugs: including depth conversion, intersection calculation and so on.
  • Line type selection, also with object, material, collection selection. currently only OR logic.
  • Multithread for occlusion test.
  • Fixed GCC errors.

I've just gone through taking a general look through the code. Main points to resolve:

  • Replace most of the custom math/macro/type defines with the equivalents from our standard library
  • Don't store runtime data (and especially draw-engine related internal types) in SDNA
  • It'd be good to get feedback from the UI team regarding panel layouts, UI labels, etc.
  • Overall, there are many places where tweaks are needed to get the code to follow our code style guidelines still. This applies to both the .C/.H files, as well as the GLSL code
  • Ensure your files end with a newline

As in many other parts of Blender, it'd be a good idea to follow the standard ordering + grouping of includes (e.g. have all includes from the same module/with same prefix together). Doing so makes it easier to see what files you've included (avoiding duplicates), and also often helps avoiding include-order problems.


Use the defines/functions from our standard math library instead. See source/blender/blenlib/BLI_math.h


See BLI_utildefines.h


There should be existing equivalents for most of these functions in the BLI_math math library already. For anything that isn't it might be worth submitting a separate patch for review with just those changes, and assign to campbell or brecht.


Use the GPU_point_size() and GPU_line_width() calls instead. We're trying to deprecate the direct use of OpenGL calls so that in future we can introduce other backends (e.g. for Mac)


elif does this code compile right now, or is this just WIP or using some macros?


Use NULL for pointers. Only use 0 for ints (and 0.0f for floats)


It's better to have each group of flag/defines done using named/typedef'd enums, so that you can note in a comment beside each field which bunch of values/defines can be used with each property. This reduces the chance that the wrong values/defines get used with the wrong fields.


What's this for?


Typo - use_different_style


What's this?


Runtime data shouldn't be saved into SDNA structs directly. The current convention is to have a _runtime struct for runtime-only data (e.g. see the Object_Runtime struct in DNA_object_types.h).

From the looks of things, it may be a better idea here to do the following:

  1. Move all the DRWShadingGroup, Gwn_Batch, and any other runtime-only stuff to a separate struct (e.g. LANPR_LineLayer_Runtime), that's defined only in some of the LANPR draw engine headers (in source/blender/draw/...`).
  2. In this struct (LANPR_LineLayer), have a void *runtime_data; pointer that points to the instance of LANPR_LineLayer_Runtime used for this layer

snake_case only


Use another name for this.

  1. It may cause issues with the makesdna parser - Most likely it's fine, but this could still reveal some hidden bugs there.
  2. It's too easy to confuse this with the other size field (1471)

There's no need for the icons here, especially if you're only going to set them to all be the same


At some point, it would be good to get feedback from the UI team (@venomgfx and @William Reynish (billrey)) about the names/labels used in the interface. Currently, it's unclear to most users what "DPIX", "Snake", and "Lanpr" mean. But this is all stuff that we can easily work on.

  • Added some small functions since last patch.
  • F12 is working now. Software mode need a state tag to enable animation rendering.
  • Fixed many code styles.
  • Removed a lot of unused functions from my own code, now all list uses ListBase APIs.
  • And many other small fixes.
  • Merge remote-tracking branch 'remotes/origin/blender2.8' into soc-2018-npr
  • Adapted multisample functions.
  • Fixed software rendering intersection cache update
  • potentially fixed drawing command conflict error in F12
  • Uncrustify processed.
  • Fixed software triangle and render line culling bug. (crappy, but works correctly)
  • Adapted shader APIs to DRW_
  • Modified UI for background color display and line layer on DPIX. Added console warning for software rendering.
  • Python panel engine adaptations
  • Fixed shader variable naming style issue.
  • Fixed enum in modifier IDs (npr tess modifier and a merged new one)
  • Fixed lanpr field always NULL error. (caused by depsgraph scene copy)
  • Fixed engine compatible panel for camera and speaker data.

Now software/DPIX won't leak memory when rendering sequence.