I'm gonna continue refactoring the code and keeping the reviewing process going. Thanks for the support everyone! :)
Finally into code review!
All about code reviewing. I'll try to attend the 10:00 CEST meeting and see what developers are thinking.
I will also include patches for other accessory modules for LANPR, including GPencil modifiers, smooth contour modifier, SVG functions and UI fixes. These patches will likely be generated upon LANPR for continuity.
LANPR's GPencil modifier doesn't have vertex weight support yet, there's only a stub on the UI. Should implement that soon, likely after LANPR is done reviewing.
deformStroke()) to make MultiStroke modifier more tolerant to multiple deform/generation modifier in the stack.
It's been a tough week for me the last few days. Thank god things finally cleared up on Monday :/ Next week should have a very free time frame.
Follow these steps:
The file will suffer from ratio differences, way-off stroke width, filled regions, and uniform stroke pressure.
It's under way...
Workflow reasons. Easy connect different software.
Here discusses the format that the proposed SVG exporter follows:
<?xml version="1.0" standalone="no"?> <svg width="4cm" height="4cm" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" version="1.1"> <title>Example triangle01- simple example of a 'path'</title> <desc>A path that draws a triangle</desc> <rect x="1" y="1" width="398" height="398" fill="none" stroke="blue" /> <path d="M 100 100 L 300 100 L 200 300 z" fill="#FFFFFF" stroke="#FFFFFF" stroke-width="3" /> </svg>
The main thing here is the
d describes the points. The leading characters in the
d string represent following meanings: (The table only includes the commands that are used in our exporter)
|L/l||X Y||Absolute/Relative line to (Actually draws stuff)|
|M/m||X Y||Absolute/Relative move to|
How to fill the
An example of this can be like the following, please note that you can insert new lines as space for visual clarity.
<path d="M 123 123 L 123 123 L 123 123 Z" />
To minimize the file size, the space between a command and a value can be omitted. For example, this is perfectly ok:
<path d="M123 123L123 123L123 123Z" />
Please note that the space between argument values can not be omitted.
stroke part, they both describes color. If the tag is not present, then the path won't have such property.
In Blender, Grease pencil width value is measured 1000 as 1 Blender Unit, which is the size of a default viewport floor grid.
In SVG, if the unit is not specified, then values are all treated as
px. We should follow this standard throughout the exporting process. In order to achieve DPI scale, we can specify
height in the SVG header alone with viewbox property. If you have a 1000px wide viewbox, with a
width set to 5 inch, then tis SVG file will be interpreted as a 200 dpi file (in width direction).
LANPR is a versatile module that could potentially have much greater extensive use in the future, its development goal grows along with the project itself now. It's not very realistic to do everything in a short period of time. So we need to distinguish what needs to be down in this stage (GSoC and shortly after), and what is reserved for the future. Here in this passage I'll propose my plan.
Propose to include these parts into the first merge, which is supposed to happen within the GSoC time frame:
Lower priority, if not able to then put into the next stage:
Striken out lines are done.
deformeStroke()are in separate steps.
Actually, there's not much there left to do. I'm gonna spend most of my time making sure that those functions work in a stable state, in the mean time, I'll continue clean up the code to better meet BF's standard.
For LANPR auto update, it's only available for post frame change. When using GPencil as output, because the lack of drawing callback, auto update is ineffective. Currently I'm working on a workaround, a more "blender standard" way will be implemented in the future, and any help is welcomed. (It seems that the current method have some access conflict risk as it is probably running in another thread by depsgraph)
Thickness problem is solved. (Yeah!)
Stroke sample function bug is fixed.
We could update this part as things go along.
In order to use LANPR alone, you need to switch to LANPR engine first, in LANPR, everything is drawn by LANPR. You may find the overlay stuff a bit obscure, you can disable it.
When using LANPR engine, line styles are controlled by line layers. You can add/remove line layers using +/- buttons on the side. One line layer controls one set of occlusion levels. By default you can have a single level layer, which starts from 0 (Means visible), and increases incrementally (means multiple levels of occlusion). Same as QI Range in Freestyle. To use QI range, click the "Onion skin" icon on the left, which lets you select a visibility range. "Default" button creates 3 layers, which let you see the internal structures. However just click the "+" once if you only want to use visible lines.
By default, all the line types uses the same line style. If you would like to specify different styles for different types of lines, uncheck "Same Style".
When you are ready, click "Update" at the top of LANPR panel. It will calculate the lines and prepare data for drawing. If you choose "Auto Update", LANPR will automatically run once you moved a frame.
When switched to viewport render mode, you should be able to see the result immediately. If not, click the viewport once.
Chaining You can disable chaining in CPU mode. There are two thresholds that controls the chaining, default value is pretty optimal, but there have been a slight problem within image-space chaining, you may notice some wiggly lines here and there.
You need at least one line layer to be able to draw in GPU mode. It's always the first layer in the CPU mode.
Clicking the "Auto Update" will automatically update the intersection buffer (which should be quicker than CPU mode calculation).
If you are going to export strokes, you need to stay in other engines. There you can see a checkbox beside LANPR panel. Check it to enable. And currently only CPU mode is accepted.
You don't need to add line layers in LANPR in order to export its calculation result as GPencil strokes. The UI is removed now.
Go to collection tab (which is a strange lonely tab in the middle...), Select the GPencil target object, Go back to Render🡲LANPR, click "Update GPencil Targets". Now you should be able to see the strokes. "Auto Update" should do the same thing when you change the frame but it's not working yet. If you want to replace existing frame, turn on "Override".
When you have a Feature Line modifier for one of your object, When you update GP stroke, It will go into its own target. Collection target is updated lastly, all the lines (you selected) who hasn't been touched by Feature Line modifier will be added into collection target. You should also be able to use child-collection. Link duplicated collection/object reportedly doesn't work, but you could try out yourself.
Intersection lines are not associated with any objects at the moment, thus can only be added from collection target.
In the collection tab and object tab, you can find LANPR usage flag (Include(Inherent)/Exclude/Occlusion Only). By default they are all in "Include(Inherent)" mode.
Select "Exclude" or "Occlusion Only" will do the effect as the name implies. This will affect all the object in this collection unless the object has a object modifier, which will be included no matter what the collection tells it. If you check "Force", then objects with Feature Line modifier will also become "Excluded" or "Occlusion Only".
By default it's in Inherent mode. That means object usage will follow collection control. You can also override by selecting "Exclude" or "Occlusion Only".
This flag is also effective in LANPR engine, in both CPU/GPU modes.
Tasks from the last week are all done except the remaining optimization of the Chaining algorithm.
LANPR doesn't automatically update it's data cache by default, because it's a computation-heavy task. For lighter scenes, you can enable auto update by clicking the "Auto Update" button under LANPR's mode selector, or you can manually update everything by clicking "Update" button on the right. In GPU mode, LANPR will only do Intersection cache updates to save time. If auto update is enabled, you should be able to view the result directly in your viewport when the frame is changed.
When not in LANPR engine (which means you are using GPencil objects as the result target), there's another option "Overwrite", by default it is disabled, so you can safely edit the strokes after updating. If you messed up a frame, you can re-genereate this frame by enabling "overwrite" and clicking the update button.