「利用者:Kjym3/DevFundProject/2014」の版間の差分
(→Freestyle memory optimization) |
細 (1版 をインポートしました) |
(相違点なし)
|
2018年6月29日 (金) 06:07時点における最新版
目次
- 1 Weekly Reports
- 1.1 Week 27: 29th-30th September
- 1.2 Week 26: 22nd-28th September
- 1.3 Week 25: 15th-21st September
- 1.4 Week 24: 8th-14th September
- 1.5 Week 23: 1st-7th September
- 1.6 Week 22: 25th-31st August
- 1.7 Week 21: 18th-24th August
- 1.8 Week 20: 11th-17th August
- 1.9 Week 19: 4th-10th August
- 1.10 Week 18: 28th July-3rd August
- 1.11 Week 17: 21st-27th July
- 1.12 Week 16: 14th-20th July
- 1.13 Week 15: 7th-13th July
- 1.14 Week 14: 30th June-6th July
- 1.15 Week 13: 23rd-29th June
- 1.16 Week 12: 15th-22nd June
- 1.17 Week 11: 9th-15th June
- 1.18 Week 10: 2nd-8th June
- 1.19 Week 9: 26th May-1st June
- 1.20 Week 8: 19th-25th May
- 1.21 Week 7: 12th-18th May
- 1.22 Week 6: 5th-11th May
- 1.23 Week 5: 28th April-4th May
- 1.24 Week 4: 21st-27th April
- 1.25 Week 3: 14th-20th April
- 1.26 Week 2: 7th-13th April
- 1.27 Week 1: 1st-6th April
Weekly Reports
Week 27: 29th-30th September
New targets for Blender 2.73 release
Now that a release candidate of Blender 2.72 was release last week and the development cycle has moved on to the BCon1 phase, it's time to define development targets for the next Blender 2.73 release. Here's a list of 2.73 targets that have involved me since a while:
- Freestyle memory consumption optimization (results of the BF funded project).
- Freestyle integrated SVG export (patch D785).
- Blender Windows IME support (patch D765).
Small additions and updates to Freestyle line rendering options are also foreseen.
Development tasks
- Fixes (unreported)
- Fix for a build error with VS 2013. 516dbaeb7333fbf
- Patch review
Acknowledgement
This week concludes the present BF funded project. All the financial and management supports provided to me are duly acknowledged. Special thanks go to Ton Roosendaal and Anja Vugts-Verstappen for their dedicated support for the project.
Week 26: 22nd-28th September
Bug hunting still continued
The final release of Blender 2.72 is yet expected in the middle of the next week, most work hours of the week were addressed to bug fixes and cleaning of pending tracker items.
Some hours were hence spent to further investigate the old report of wrong line visibility in Freestyle (T36350). After a few attempts following the previous debugging trials documented earlier, it turned out that the wrong assumption of linearity in the projected spherical grid space is found everywhere in the code base for line visibility computations. In fact, a major fraction of the line visibility code has been shared by another grid data structure called BoxGrid for orthographic cameras. The BoxGrid data structure relies on a linear grid space, so that the assumption of linearity in line visibility computations is valid. However, the shared use of the same code basis also for the spherical grid data structure seems almost impossible as of this writing. A major revision of the line visibility code for perspective cameras is foreseen as soon as time permits.
Development tasks
- Fixes (unreported)
- Fix for missing initialization of Freestyle RenderData parameters for new scenes. 2854b9320254f99
- Freestyle: minor docstring revision of Operators.reset(). 99ef213dcbab68d
- Patches
- D713: correct error /w braces (freestyle). d342f46682a7def
- D779: Fix for Freestyle crash in bordered animation rendering. ef0883bc2b70f60
- D802: Freestyle: Expose the Operators.reset() function to Python. c900cd3bd8ab060
- Patch review
- D745: Improvements to the cpp-defined Freestyle stroke shading.
- D765: Blender input method editor support for windows.
- D801: Freestyle: remove old and unused stroke shaders.
Week 25: 15th-21st September
Bug hunting continued
In view of the upcoming Blender 2.72 release, major revisions were made to the Freestyle Python API documentation. Unfortunately the Freestyle section of the Blender API reference manual was missing due to the reorganization of Freestyle Python modules done in Blender 2.70. It is recalled that the majority of the API reference manual including the Freestyle section is auto-generated by a Blender Python script executed within a release build of the program. The missing Freestyle section was hence recovered this week by relevant code revisions and docstring updates in Freestyle-specific Python modules.
The updated Freestyle Python API manual is found in http://www.blender.org/documentation/blender_python_api_2_72_0/freestyle.html.
Development tasks
- Fixes (unreported)
- Fix for missing Freestyle sections in the Blender Python API documentation. f87ca5f1c314f67
- Fix for a run-time error in sphinx_doc_gen.py on Windows. cf0ce0afc7b79cc
- Freestyle: Python API documentation updates. 64ade99ecc0e9bd
- Freestyle: Fix for irrelevant docstring showing up in Python API docs. 1c8d9cc4a923c0b
- Patch review
- D785: Freestyle integrated SVG export.
Week 24: 8th-14th September
Bug hunting continued
Still in the BCon3 phase, most work hours of the week were spent to address a few reported bugs (some of them related to the 2.72 new feature of Freestyle line rendering in Cycles). Since one of the bugs was traced to an issue outside Freestyle, a patch was submitted for code review (D779).
Windows IME support
During the week some effort was also made for UI review of patch D765 for Windows input method editor (IME) support in Blender. A proper support of Windows IME has been a missing feature long awaited by blenderheads willing to type Chinese, Japanese and Korean text in Blender. A test build for 64-bit Windows was prepared to reach a wider range of testers relying on Windows IME for composite text editing.
Development tasks
- Fixes (reported)
- Fix T41800: Freestyle + Cycles panoramic camera not compatible, renders are incorrect. e5b2e9cdd34f071
- Fixes (unreported)
- Freestyle: Fix for missing quality control on line rendering in Cycles. 507af0085519542
- Patch submission
- D779: Fix for Freestyle crash in bordered animation rendering.
- Patch review
- D765: Blender input method editor support for windows.
- D787: Cycles: Add per Render Layer "Film Transparent" Override.
Week 23: 1st-7th September
Bug hunting continued
In the beginning of the week, hours were spent to address a newly identified issue related to the previous solution (commit eb8964f) for the T41464 material boundary bug. The new issue was coming from a combination of old and new forms of iterations (loops over vertices) in Freestyle. Specifically, the Freestyle Python API contains conventional C++-like iterator classes having .increment() and .decrement() methods, as well as a complementary support for the Python iterator protocol based on iter() and next() built-in functions. We concluded that this is a documentation issue and it is up to users to avoid error-prone combinations of old and new Freestyle iterator constructs.
The rest of the week was mostly addressed to the issue T36350 on incorrect line visibility in the case of a perspective camera. Since the issue has been traced down to a design problem of a spherical grid data structure, a revision of the grid structure was attempted. Simple test cases confirmed the effectiveness of the revision, while some complex scenes still resulted in wrong line visibility. Further development in this direction is foreseen in the following weeks.
Development tasks
- Fixes (reported)
- Better fix for T41464: Material Boundary bug in Freestyle. f6b4b1296125d43
- Fixes (unreported)
- Fix for line style shader nodes also shown in the Add menu of other shader types. 28cce475f2c7ff0
- Patch review
- D752: Freestyle: further fixes for iterators.
Week 22: 25th-31st August
Bug hunting continued
This week some work hours were spent for patch reviews. The rest of the weekdays were mostly addressed to the continued work on T36350. After lots of code reading and many attempts to fix the bug, the cause of the reported issue was finally identified in a wrong assumption of linearity in the spherical coordinate system used for the SpherialGrid data structure. The finding has been reported in the task comment T36350#12 in detail. The documented problem turned out to require a major revision of the spherical grid data structure. Further development of the task is foreseen in the next week.
Development tasks
- Fixes (unreported)
- Freestyle: Fix for missing and unnecessary property update notifications. 42404255e98614a
- Patch review
- D745: Improvements to the cpp-defined Freestyle stroke shading.
- D752: Freestyle: further fixes for iterators.
- D765: Blender input method editor support for windows.
Week 21: 18th-24th August
Bug hunting
BCon3 bug hunting started on the 17th of August, so most work hours were directed to fixing bugs. Task T41464 absorbed quite a lot of time and efforts to trace down the real causes of the reported issue. Part of the committed fix for T41464 led to a discussion of a better solution (D752) involving a revision of the Freestyle Python API in view of improved support for the Python iterator protocol (i.e., Python's iter() and next() built-in functions).
In addition, some work hours were spent for a one-year-old bug report (T36350: Freestyle renders extra lines). The reported problem is that some hidden Freestyle lines are not properly occluded by large faces. This issue is only seen with a perspective camera, so the cause seems to be in a grid data structure called SphericalGrid in Freestyle that is used to optimize ray-casting line visibility computations. Initial steps for addressing the bug involved lots of code reading and naive testing to better understand what is going on in the spherical grid data structure.
Development tasks
- Fixes (reported)
- Fix T41464: Material Boundary bug in Freestyle. eb8964fb7f19463
- Fixes (unreported)
- Fix for line style shader/texture types showing up in the node editor when Freestyle is disabled at compile time. 05cb63ecf750954
- Patch review
- D752: Freestyle: further fixes for iterators.
Week 20: 11th-17th August
Freestyle memory optimization
Work hours were mostly spent for the ongoing work on reduced memory consumption in Freestyle. Many attempts to optimize Freestyle memory consumption were made, including:
- Remove unused tesselated forms of silhouettes for displaying in the UI.
- Less memory-consuming and faster stroke rendering by avoiding repeated merging of mesh custom data.
- Further internal switch from double to float.
Some efforts were also addressed to additional optimization for speed:
- Avoid copying vertex coordinates where possible.
- Avoid float-to-double conversion in the camera-to-grid space transformation.
After these optimization attempts, preliminary performance tests showed appreciable space-time trade-offs (between memory consumption and rendering time) with regard to the code changes for memory optimization. Specifically, the following portions of the optimized code turned out to be run-time speed bottlenecks:
- Using std::map (instead of std::vector) to compress a set of pointers to 3D vectors in grid data structures for line visibility computations.
- Computing 3D bounding box coordinates of triangular faces on the fly when needed (instead of storing the minimum and maximum bounding box coordinates into vectors).
Experimental results below show performance comparisons among (a) the non-optimized baseline version, (b) faster optimized version excluding the time-consuming code changes listed above, and (c) less memory-consuming optimized version including all optimization attempts. Table 1 compares the peak memory consumption in units of megabytes, whereas Table 2 highlights differences in overall rendering time in seconds. All results concerned the full rendering of an input test scene including both Blender Internal and Freestyle render components.
Test case (#verts, #faces) | (a) Baseline | (b) Opt. faster | (c) Opt. less memory |
---|---|---|---|
ichiotsu (75K, 121K) | 320.33M (100%) | 291.45M (91.0%) | 273.51M (85.4%) |
ramskull (370K, 741K) | 1616.9M (100%) | 1409.3M (87.2%) | 1309.0M (81.0%) |
lily (460K, 749K) | 1550.8M (100%) | 1361.8M (87.8%) | 1206.0M (77.8%) |
Test case (#verts, #faces) | (a) Baseline | (b) Opt. faster | (c) Opt. less memory |
---|---|---|---|
ichiotsu (75K, 121K) | 6.93 sec (100.0%) | 7.50 sec (108.2%) | 7.93 sec (114.4%) |
ramskull (370K, 741K) | 35.6 sec (100.0%) | 37.0 sec (104.1%) | 41.6 sec (117.0%) |
lily (460K, 749K) | 14.5 sec (100.0%) | 17.6 sec (121.3%) | 18.8 sec (129.6%) |
Further attempts to balance the documented space-time trade-offs are foreseen in the next weeks.
Freestyle for Cycles
The review process of the patch D632 was finalized and the merge of code changes into Git master was approved by Sergey Sharybin. After the merge has been done, the Freestyle section of Blender 2.72 release notes was duly prepared to introduce the new line rendering solution in Cycles, as well as to describe additional new Freestyle features and improvements.
Week 19: 4th-10th August
Freestyle memory optimization
Work hours during the week were spent for optimizing Freestyle for less memory consumption. Memory optimization attempts that led to a significant reduction of memory consumption include:
- Less memory-consuming stroke rendering by packing stylized strokes into the minimum number of mesh objects.
- Compression of a set of pointers to 3D vectors in grid data structures used for line visibility computations.
- Internal switch from double to float in the grid data structures.
Development tasks
- Fixes (unreported)
- Fix for double freeing of MEM_guardedalloc'ed memory originating from BLF_lang_set(). f0259d0a5396ebe
Week 18: 28th July-3rd August
Freestyle memory optimization
In this week most work hours were addressed to Freestyle memory optimization. Careful code revisions were made up on experimental renders for evaluating performance improvements and checking visual consistency before and after the code updates. Performance optimization attempts made during the week include:
- Internal switch from double to float (except for curvature computations) in the FEdgeXDetector class used for view map building.
- Optimization for space in the WXFaceLayer class used for silhouette detection.
Considering three test cases (named ichiotsu, ramskull, and lily), performance improvements so far are within the range from 6% to 9% with respect to the peak memory consumption of the baseline (unoptimized) version.
Test case (#verts, #faces) | Baseline | Optimized |
---|---|---|
ichiotsu (75K, 121K) | 320.33M (100%) | 296.75M (92.6%) |
ramskull (370K, 741K) | 1616.9M (100%) | 1520.5M (90.8%) |
lily (460K, 749K) | 1550.8M (100%) | 1408.1M (94.0%) |
Development tasks
The code review of the patch (D632) for Freestyle line rendering in Cycles was ongoing during the week and some patch revisions were also made in reply to review comments.
Week 17: 21st-27th July
Freestyle memory optimization
The patch for Freestyle line rendering in Cycles (D632) was submitted for code review by core Blender developers in the beginning of the week. Hence development focus was moved on to Freestyle performance optimization for less memory consumption. It is recalled that the Freestyle rendering process is divided into several steps as follows:
- Mesh loading - Input scene data is received from Blender and cleaned up.
- Winged edge building - A graph data structure (called winged edges) for bidirectional traversing of edges is created.
- Silhouette detection - Silhouette lines and other feature edges are identified based on winged edges.
- View map building - A 2D representation of the input scene (called a view map) is created from winged edges.
- Stroke drawing - A set of stylization options is applied to identified feature lines by Python scripting.
- Stroke rendering - A raster image of stylized lines is rendered.
Individual rendering steps are implemented in a modular manner, which permits step-by-step performance optimization for space. Several memory optimization attempts were made during the week, including:
- std::string was replaced by a pointer to a const char array where possible, to avoid string duplicates.
- Concerning the mesh importing up to the silhouette detection, several class member variables were removed (at the cost of computing their values when retrieved) or changed to a type of smaller size.
- Redundant instantiation of vector objects was removed.
- Internal switch from double to float in mesh loading and construction of winged edges.
Memory consumption has been evaluated using the MEM_guardedalloc library with the WITH_CXX_GUARDEDALLOC build option enabled. A couple of helper functions for memory consumption evaluation were implemented to this end.
Freestyle Python API updates
Also in this week, the implementation of the Freestyle Python API was updated with an emphasis on code readability and performance for speed in close collaboration with flokkievids (Folkert de Vries).
Development tasks
- Fixes (reported)
- T41180: Crash when using motion blur with Freestyle. 698a9a2434ac3a4
- D675: Fix inconsistent use of print_error() and fprintf(stderr, ...) in MEM_guarded_printmemlist_internal(). af585e843b0a013
- Fixes (unreported)
- Freestyle: minor revisions of Python API docstrings and comments. d5d540615b7ddbf
- General tasks
- D668: Extended mathutils.Vector.orthogonal() to accept a 2D vector. 8d3bfef538c6393
- D623: Freestyle Python API: Updates and speedups for the parameter editor. b408d8af31c9fba
- A follow-up to Patch D623: minor code updates and style cleanup. 1819fa2b5aab703
Week 16: 14th-20th July
Freestyle for Cycles
Node-based line style textures were worked out and finished in this week. A new UV Along Stroke shader node (in line with the UV Map node) was introduced to allow users to feed to the UV input of texture nodes the UV maps that will be defined on the fly along Freestyle strokes. It is noted that the conventional UV Map node cannot be used for this purpose, since users never see the mesh objects that are auto-generated to represent Freestyle 2D strokes, and thus users are unable to select a UV map name that has to be already defined as part of mesh data. By the end of the week the code updates were almost done and tested to get updates of Patch D632 ready for code review with a view to inclusion in Blender 2.72 release.
Development tasks
- General tasks
- Renamed CTX_data_linestyle_from_scene() to BKE_get_linestyle_from_scene(). 647969f9b617b0e
- Follow-up to code cleanup in rB415af0b: Keep compound terms as they are. a798e01dc3ffa21
- Freestyle: Fix for UI text of the "use_tips" line style property. 8cf2b3879a7f89c
- Freestyle: added a note on #include "DNA_material_types.h". aa7f9197c7f9d30
Week 15: 7th-13th July
Freestyle for Cycles
This week most work hours were spent for addressing the design issues related to Freestyle line rendering for Cycles as documented in the last weekly report.
As to the issue of material color/alpha/thickness modifiers, a new per-material line color property was introduced. This line color property is available regardless of rendering engines so as to provide a reliable standard way for material-based stylization of Freestyle stokes.
For what concerns the texture UI design issue, it was decided to implement a node-based texturing framework, instead of relying on the conventional texture mapping and influence panels. Specifically, line styles were extended to include a shader node tree for defining textures that will be mapped onto strokes. The output of the node tree is a Line Style Output shader node which gives Freestyle access to colors and alpha transparency of the textures as well as influence factors for mapping to the base color and transparency of Freestyle strokes. The core part of line style shader nodes was finished by the end of the week.
Development tasks
- General tasks
- Per-material line color settings for Freestyle. 7915d7277ac8c60
- Fixes (unreported)
- Freestyle: fix for crash in the constructor of freestyle.types.StrokeVertexIterator. 02eb03f8687c30f
- Freestyle: minor docstring fixes. c7ba6eaacc0d283
- Patch review
- D623: Freestyle Python API: Updates and speedups for the parameter editor
Week 14: 30th June-6th July
Freestyle for Cycles
The initial patch set of Freestyle for Cycles was finalized and extensively tested. In the meantime, investigations of Cycles' integration into Blender were continued to address a design issue related to a proper support of material colors and textures. There are two related problems on the Freestyle side.
One is concerned with Freestyle's builtin Material color/alpha/thickness modifiers. These modifiers allow users to modify line color and other line properties based on materials' diffuse color, alpha transparency and so forth. In the Blender Internal (BI), these material properties are static (unless nodes are in use) and fairly easy for Freestyle to retrieve their values. In Cycles, however, most material properties are embedded in shader node trees and are difficult to retrieve relevant values from within Freestyle.
The other issue concerns textured strokes. Freestyle relies on the legacy texture mapping and influence panels for the BI to allow users to stylize textured strokes. In Cycles, textures are first defined in shader node trees, and the textures' properties then appear in Cycles-specific option panels in the UI. It seems that a fixed set of UI components (e.g., based on texture slots) is suitable for stroke texturing in Freestyle since stroke rendering is done by generating on the fly a temporary scene which users will never see and interact with. These contradictory UI requirements make UI design for Freestyle textured strokes uneasy.
The code reading during the week concluded that evaluating shader node trees outside the Cycles render pipeline is not easy and hence Freestyle won't be capable of information retrieval from node-based materials any soon. The texture UI issue also requires further development. Different approaches to a proper support of material colors and textures in Freestyle for Cycles will be studied in the next week.
The work-in-progress patch set D632 for Freestyle line rendering in Cycles was posted to the bf-blender-npr mailing list with the aim to call for testers (link to the posted message).
Development tasks
- Fixes (reported)
- Fix T40833: Crash when rendering with freestyle. ea3c2eb15d276bd 6c6fa749f6ee0ff
- Fix T40065: Pressing Esc in separate render result window does not focus main window. fef946312380683
- Fixes (unreported)
- Follow-up to rBcc1372546ad5: Fix for segmentation fault in pipeline (freestyle/wm related). 3f1ed437c103ce0
- Fix for a wrong threads count shown in Freestyle debug mode (--debug-freestyle). 944e576717c1b65
- Patch submission
- D632: Freestyle line rendering in Cycles
Week 13: 23rd-29th June
New targets for Blender 2.72 release
Discussions with Blender NPR stakeholders were held on the bf-blender-npr mailing list, and new development targets for the next Blender 2.72 release were selected as shown below in the descending order of priority:
- Freestyle performance tuning for space and time.
- Freestyle integration into Cycles.
- Adding Z depth information to rendered Freestyle lines.
- built-in SVG export.
As stated in the summary message posted to the mailing list, "The first item takes the highest priority since that is a specific request from the Gooseberry project which is going to use Freestyle for film production. However, performance tuning efforts may just fail and there is no guarantee of a success, so I will try to make sure some of the other targets will be delivered to 2.72 so that the funded project will be justified by deliverables visible to end users."
Freestyle for Cycles
For the aforementioned reasons, this week's development focus was put on Freestyle integration into Cycles. By the end of the week a working version of Freestyle for Cycles was developed, where the Blender Internal (BI) is used for Freestyle line rendering. An attempt to use Cycles for that purpose was also made, which turned out to be successful to some extent. Specifically, most line stylization options are available even when Cycles are used for stroke rendering, but a proper support for material colors and textures is missing because Freestyle is not capable of accessing node-based material setups. Further code refinements and investigations of Cycles shader nodes are foreseen in the next week.
Development tasks
- General tasks
- Freestyle: Progress bar updates during mesh loading. e7c92f11453e58a
- Freestyle: use bool instead of int. 252eaed483ca8c0
- Freestyle: use mathutils_array_parse() instead of its own helper functions. 9563bde9a5457a3
- D319: Freestyle Python scripts update. ce729677db3e993
- Fixes (unreported)
- Freestyle: Fix for a couple of missing names in freestyle.chainingiterators.__all__. dd96be356d82390
- Freestyle: Fix for "cast shadows only" materials not handled properly. ccfe845ff4b7415
- D605: Fixes for proper handling of wchar_t paths in MinGW. 77f357728f708dd
- D620: Fix for DeviceScene::attributes_uchar4 not released properly. 0a0e4e0e698eb49
Week 12: 15th-22nd June
Degenerate triangles
Bug hunting efforts were continued from Week 11 and hours were spent for focused development of the edge traversal algorithm for Freestyle intended to address incorrect face normals due to degenerate triangles coming from Ngons. Initial coding and tests have been done, although the algorithm development needs further fixes and tuning.
Non-ASCII, MBCS-compatible paths on Windows
In the meantime, some hours were used to improve support for non-ASCII paths with characters of a multi-byte character set (MBCS) on Windows. A few related patches (D603, D604, and D605) were submitted for code review. With all these patches applied, Blender can start from a path with non-ASCII characters on Windows when the system locale is set to an MBCS code page (such as Chinese, Japanese and Korean). The patches are still under review.
Development tasks
- General tasks
- Freestyle: removed WOEdge::getVec3r() which in effect was a duplicate of WOEdge::GetVec() 70b8a8daf86bcc1
- Freestyle: Python API docstring updates. 8365cebe32089dc
- D545: Freestyle Python API: new methods for Stroke and StrokeVertexIterator. 840891e22a12c7b
- Fixes (unreported)
- Fix for weak floating-point number comparison (causing assertion failures in MinGW-w64) f0a3ea54f86256c
- Fixes (reported)
- Additional fix for T35176: Python failure with .blend files loaded from paths including non-ASCII characters f325ddb0d7f8765
- Patch review
- D319: Freestyle Python scripts update
- Patch submission
- D603: Better support for loading OCIO configuration from a path with non-ASCII chars on Windows
- D604: Fix for incomplete retrieval of system/user resource paths due to a Blender installation path with non-ASCII chars
- D605: Fixes for proper handling of wchar_t paths in MinGW
Week 11: 9th-15th June
Bug fixes continued
The week started with the BCon4 phase of the Blender 2.71, so most work hours were spent for bug fixes. A patch for fixing T40065 was submitted as patch D594 (still under review).
Also a relatively old bug report T40163 was further investigated. The problem is that Ngons tend to have degenerate triangles when tessellated and cause unwanted lines in Freestyle renders. An issue coming from degenerate faces is incorrect face normals (no way to reliably compute it since the area of a degenerate face nearly equals to zero). To address the face normal issue, a new idea has been developed. Basically degenerate faces cause mesh edges overlapping with each other. The idea is then to traverse overlapping edges and identify a non-degenerate face that is "visually adjacent" to a degenerate face. If such a non-degenerate adjacent face is found, then its face normal is used as that of the degenerate face. Hours were spent for the development of the edge traversal algorithm.
Development tasks
- Patch review
- D319: Freestyle Python scripts update
- Patch submission
- D594: Fix T40065: Pressing Esc in separate render result window does not focus main window
Week 10: 2nd-8th June
Bug fixing continued
Most of work hours were spent for bug fixing and related actions. A highlight of this week is the fix for viewport render not updating with changes of Freestyle settings (269b14f184bc). Now that all parameter changes in the Freestyle GUI will be immediately visualized in the view port render, this is going to be the most intuitive way for artists to try out different line stylization options in Freestyle starting from Blender 2.71.
Some hours were also spent to look into the open issue T40163 concerning unwanted Freestyle lines due to degenerate faces coming from Ngons. In-depth discussions in the task T40163 explored different approaches (including an experimental patch of mine) to fix the issue, but none of them turned out to be a general solution. It is my impression that degenerate faces coming from Ngons should be addressed in the first place through a better tessellation algorithm. Addressing degenerate faces much later in Freestyle is a very tricky exercise.
Additional efforts were directed to patch review so as to be able to close associated open tasks as soon as the Blender 2.71 has been out:
- Patch D319: Freestyle Python scripts update (T37565: Freestyle API changes and further scripting integration).
- Patch D545: Freestyle Python API: new methods for Stroke and StrokeVertexIterator (T37839: Iterator incremented() and decremented() methods)
RGB-to-grayscale conversion schemes
A bug fix for a wrong formula used for RGB to grayscale conversion (de280ffa32e4) raised a concern (again) that Blender has multiple RGB-to-grayscale conversion schemes, and different methods are used here and there for some unknown reasons. This seems a bigger issue than it appears that needs to be addressed from a general perspective of color management in Blender.
Development tasks
- Fixes (unreported)
- Fix for missing visits of ID's within SceneRenderLayer in BKE_library_foreach_ID_link(). 96f81242bdbd24b
- Fix for missing visits of Freestyle-related ID data blocks in BKE_library_foreach_ID_link(). 00f722042c07e84
- Freestyle: Fix for viewport render not updating with changes of Freestyle settings. 269b14f184bc93a
- Freestyle: Fix for operator error messages with no active line set and associated line style. 70e98a21e0db11c
- Freestyle: Fix for Interface0DIterator.object docstring with additional notes. 4ac5d3245dbecb3
- Freestyle: Fix for a wrong formula used for RGB to grayscale conversion. de280ffa32e48f1
- Freestyle: Fix for a potential infinite loop in stroke resampling by vertex count. 812515b623be917
- Patches
- D545: Freestyle Python API: new methods for Stroke and StrokeVertexIterator.
Week 9: 26th May-1st June
Bug hunting continued
Still in BCon4, bug hunting efforts were continued to reduce the number of open bugs in the Blender bug tracker. A couple of days in the beginning of the week were spent for addressing the issue T40315: Boolean modifier with Freestyle edges. After many hours of code reading about boolean and subsurf modifiers as well as the depsgraph, a patch set D558 was proposed to fix the issue. Discussions with Sergey showed that the proposed fix was trying to address a bigger problem in the depsgraph, so that a different approach focusing only on the Freestyle stuff was taken in the end.
Development tasks
- Fixes (reported)
- T40315: Boolean modifier with Freestyle edges. edfd989e864f2c8
- T36425: freestyle edge marks not working.
- Fixes (unreported)
- Fix for thinning strokes at intersections between visible and background hidden lines. fce731a1753a9aa
- Fix for a missing code update in my commit rB08528f577dcb. 4c38e826dc4c5cb
Week 8: 19th-25th May
Bug hunting
Because of the BCon4 phase in the Blender release cycle, most hours were specifically spent for bug fixes.
One of old Freestyle bugs was addressed. The problem was that visible lines may suffer from sudden thinning of stroke width at intersections with background hidden lines. A description of the problem is found in the comment #19 of T36425. Since initial attempts to properly fix the issue were unsuccessful, a temporary solution was introduced by an old commit in August 2013 (2a5b6d9c8f16). After many further attempts with a fresh look into the problem, this time the causes of the bug were finally identified in an algorithm that tries to prevent stroke vertices from overlapping at the same coordinates (this kind of singularity may become annoying sources of visual artifacts in stroke rendering). A partial fix was then done during this week.
Development tasks
- General tasks
- Freestyle: Added utility function SilhouetteGeomEngine::CameraToImage(). 01ac74e4ad223b0
- Fixes (reported)
- Fix T40307: Crash with freestyle and particle hair. 97d047a3e9a52d9
- Fixes (unreported)
- Freestyle: Partial fix for thinning strokes due to flipping stroke directions at TVertices. 08528f577dcb47f
- Freestyle: Fix for versioning code not working properly with new texture options. 77153b303264a6a
- Fix for a regression in rBe84732858590. 0516071a865c150
- Freestyle: Fix for Z normalization in SilhouetteGeomEngine. 13c92a77d3646f6
- Freestyle: Fix for returned references to auto variables. f6e774552ccba0d
- Freestyle: Fix for GetOccludeeF1D returning a one-element list containing None when it is supposed to return an empty list. 6c136a69b0bb097
Week 7: 12th-18th May
Freestyle Python API updates
As foreseen in the last weekly report, further Freestyle Python API updates were done with regard to collection property types. Specifically, conventional .new() and .remove() methods were added to collection types of line style modifiers and Python style modules.
The collection of Python style modules is an ordered list whose elements are processed from top to bottom. The order of Python style modules will determine the stacking order of lines drawn by Freestyle. Hence Freestyle provides a couple of operators to manipulate the place of modules in the list. It was then observed that the Blender Python API does not have a general way to re-order elements in a collection. This observation was confirmed by a discussion in the bf-python mailing list. It is still an open question as of this writing whether an element reordering method (like a .move() method) can be added to individual collection types or should be done at a higher level of the API. No decision was made in this regard at the moment.
Filled caps of 2D extruded curves
Many hours were then spent to address a problem report T39669. The original problem was a number of Freestyle warnings about edge duplicates in a 2D extruded curve, but a closer look into the issue showed that there was a bug in automatic curve-to-mesh conversion carried out in the beginning of rendering (a convincing visualization of the problem). The conversion output was inconsistent with that of manual curve-to-mesh conversion. After a lot of code reading and several attempts to fix the problem, a proposed fix D532 was reviewed and accepted.
Screen-space coordinates in the operator redo panel
Through personal communications a usability issue was identified and posted to the bf-committers mailing list. The problem is that since Blender 2.69 screen-space coordinates are not shown in the operator redo panel. For instance, the Weight Gradient tool has four parameters specifying the start and end points of a straight line segment in screen-space coordinates. These parameters were available in the redo panel up to Blender 2.68a, allowing artists to manually refine the line segment along which vertex weights are updated. No reply was offered to the post in the list. Additional actions are foreseen most likely after the upcoming Blender 2.71 release.
Development tasks
- General tasks
- Freestyle: Added .new() and .remove() to the collection type of Python style modules. 19b82be61e47cd3
- Freestyle: Added .new() and .remove() methods to collection types of line style modifiers. a31962287a543c0
- Freestyle: Removed redundant flipping of UV coordinates. ae00a2b3fd0680f
- Freestyle: Fix for RNA aliases of FreestyleConfig and FreestyleModuleConfig. c08f025fe1111a6
- Freestyle: Added a piece of debug code for checking the consistency of face normals. 4958aff780a3ef6
- Fixes (reported)
- Fix T39669: Freestyle: Curve with extrude>0 causes warnings in console. f8554ed61a427e0
- Fixes (unreported)
- Freestyle: Fix for texture spacing reset to a non-default value on load of old .blend files. 980c1a98e9c6504
Week 6: 5th-11th May
Textured strokes in Freestyle
Since the patch for Freestyle textured strokes was merged into Git master, further testing and bug fixes were done in collaboration with the patch author Paolo Acampora.
The use of textured strokes in Python scripting was also investigated. Different implementations for providing access to line style texture slots in Python style modules were discussed with Paolo. An example Python style module was implemented to demonstrate the use of textured strokes in Python scripting.
An illustrated description of textured strokes and demo files were added to the Freestyle section of Blender 2.71 release notes.
Performance optimization
Based on a crash report through personal communications, an attempt was made to optimize memory requirements in Freestyle stroke rendering.
It is recalled that a stroke may consist of alternate visible and invisible segments. Previously temporary mesh objects were created for individual visible stroke segments. This could result in an excessive memory consumption in stroke rendering when strokes are composed of many short visible segments (for instance by means of dashed lines and/or blueprint geometry modifiers). Now mesh objects represent individual strokes instead of stroke segments, which tends to reduce the number of generated mesh objects by an order of magnitude.
Freestyle Python API improvements
Motivated by an online discussion, revisions of the Freestyle Python API have been started. The discussed problem was that the Freestyle Python API did not follow the general data creation/removal convention of the Blender Python API. Specifically, there was no easy and reliable way to add/remove a data element to/from the collection of line sets defined as part of scene render layer settings.
Now that Freestyle has been increasingly adopted, automated workflows by Python scripting are more likely. Hence Python API revisions towards Freestyle line rendering automation are considered an urgent task. As a first step, the aforementioned issue concerning the collection of line sets has been addressed. Further API revisions are foreseen in the next days.
Development tasks
- General tasks
- Freestyle: time/space optimization in stroke rendering without textures. fe0236be78bf1ab
- Freestyle: removed the dummy implementation of a texture manager. a351ff7264558c2
- Freestyle: added more conditions to be able to switch to the line style texture properties context. a6f92cd29ad4585
- Freestyle: Stroke rendering optimization. 40520d549d50bb2
- Freestyle: debug statistics on stroke rendering. dfe800b4a80a39e
- Freestyle: Added .new() and .remove() methods to the Linesets collection type. bbd611362c9ae0b
- Patch D513: Removed a Freestyle hack for DAG updates introduced in commit rBae58968e0a61. 75d49b7f559aae2
- Fixes (reported)
- Fix T40020: Freestyle: dashed lines crashes blender. 047c3aa728a4bb9
- Fixes (unreported)
- Fix for an occasional crash in Freestyle stroke rendering. 1064b74196dc50b
- Freestyle: Fix for dashed lines when applied to invisible stroke segments. 3a0be8a0d6b50cc
- Freestyle: Fix for a wrong interpolation of stroke segment visibility. c4e277d53b29c33
- Freestyle: hide line styles from a scene in the Outliner when WITH_FREESTYLE build flag is off. bebcd4d5c57af3d
- Freestyle: hide the Line Style tab from the Texture properties context when WITH_FREESTYLE build flag is off. 34bc1e528e32e69
Week 5: 28th April-4th May
Textured strokes in Freestyle
Many hours were spent for revisions of Patch D246 through personal communications with the patch author Paolo Acampora. Code development elements included:
- Pinning of line style ID datablocks in the properties window.
- Support for node-based textures in line styles.
- Fix for visual artifact in the tail tip of strokes (due to a bug in the calculation of UV texture coordinates).
- Fix for line style textures in the Outliner.
The patch set was reviewed by Brecht and me, and finally merged into Git master for inclusion in the upcoming Blender 2.71 release.
Preview rendering in the 3D viewport
A crash report T39941 related to Freestyle preview rendering in the 3D viewport was addressed by a fix in commit 182e97a2cd4b. Upon a comment to the fix, a detailed description was posted to document how the 3D viewport preview rendering works when primary and/or other scene render layers are deactivated. This led to a better solution of the observed preview rendering glitch (6ec2d72eca61).
Development tasks
- Patches
- Patch D246: Texture Marks for freestyle strokes, written and contributed by Paolo Acampora. b7f085d9c128f31
- Fixes (reported)
- Fix T39941: Freestyle: Rendered preview crashes when non-primary render layer is selected and disabled. 182e97a2cd4bdca
Week 4: 21st-27th April
Textured strokes in Freestyle
Patch D246 was revised on my side to address some bugs identified by independent tests. Some texture settings worked fine, while some other did not. Hours were spent for in-depth debugging and code revisions related to UV loops. A revised patch set was then sent to Paolo for evaluation and inclusion into D246. Additional UI fixes for Freestyle textured strokes were done independently on my side.
Also hours were spent for unsuccessful attempts to figure out the cause of an annoying issue that the texture preview window for Freestyle textured strokes was not properly updated when tabs in the Properties context window were switched (for example from Render Layers to Texture, and vice versa). This problem seems due to fact that the preview window is not in the Texture tab.
In the meantime, a request for UI design review was sent to the Blender UI team, and Brecht kindly offered prompt UI review comments. According to his suggestion, Freestyle texture settings will be moved to the Texture tab of the Properties window to keep the UI consistent with existing texture options in other parts of Blender.
Documentation
The Freestyle section of the Blender 2.71 release notes was worked out to document the new set of sorting options. Example renders were created to demonstrate the new features.
Link/Append workflows with Freestyle-enabled assets
A new discussion has been ongoing in the bf-blender-npr mailing list to address the issue that there is no easy way to Link/Append animation character assets together with Freestyle settings. Some thoughts were fed to the discussion to gather ideas for Blender/Freestyle improvements to address the issue.
Development tasks
- General tasks
- Freestyle: minor UI improvements. ece64c7ffdc82cd
- Added missing bpy.data.linestyles.is_updated property. 0e6b28e04b291df
- Freestyle: quiet BMESH validator warnings of zero normals. 59b94f2193d50e9
- Problem report T39902 was filed together with Patch D484 to make it easy to keyframe object data properties (e.g., mesh edge/face flags) using keying sets in the edit mode.
- Fixes (reported)
- Fix T37452: More descriptive tooltips for freestyles settings. 95eb5fb72776d9d f6da871d9de1e3d
- Fix T39902: Keyframe insertion by a Keying Set fails in the edit mode when keyframing object data properties. 2aa9d33404ca96e
Week 3: 14th-20th April
Freestyle demo at a meet-up in Tokyo
A local meet-up event was held on Monday, 14th April in Tokyo for 3D CG artists working on cel-look (cartoon) rendering and its applications. It was a small meeting of about 20 participants including professionals, students and amateurs. A demo of Freestyle for Blender was presented with the aim to showcase selected Freestyle applications (movie clips, still renders, and breakdown slides) and inform potential stakeholders of recent advances in the development of Freestyle and Blender NPR capabilities. The artists contributing to the demo included Light BWK (Malaysia), Lee Posey (USA) and mclelun (Malaysia). The demo turned out to be a big success, since many questions about the presented visual results and feature requests to Freestyle were asked during and after the demo session. This clearly indicates lots of enthusiasm for Freestyle and Blender emerged on the side of the presentation audience. The event was also quite motivating to me.
New options for sorting Freestyle lines
New options for sorting lines were added to line style IDs to arrange their stacking order in a render (f60a66f). These options give artists more control to determine which lines should be drawn on top of others.
Freestyle edge/face marks in the Outliner
A lot of code reading was done to address a known issue (not filed in the bug tracker) that Freestyle edge/face mark properties in Mesh data were not shown in the Outliner in the Datablocks display mode. The cause of the issue was missing RNA property definitions of these Freestyle-specific flags (cad4bfe). Now Freestyle edge/face marks can be keyframed through the outliner, as well as by means of keying sets.
Python scripting integration into Freestyle GUI
Some hours were also spent for code reading to investigate different options for better Python scripting integration into the Freestyle interactive GUI in Blender. The idea is to allow artists to write Python expressions to build custom line styles. Two solutions were analyzed:
- A name space is introduced to register user-defined style components (predicates, functions and stroke shaders) written in Python. The registered components are then used in Python expressions embedded in line styles. This approach is in line with Python drivers for animation (user-defined functions and variables are added to bpy.app.driver_namespace).
- bpy.utils.register_class() is used to make user-defined style components accessible from within line styles. In this case, base classes for defining predicates, functions and stroke shaders have to be exposed as RNA types that can be derived by inheritance and registered to the bpy.types namespace.
More API design work is foreseen during the project.
Development tasks
- General tasks
- Freestyle: New options for sorting to arrange the stacking order of lines. f60a66f41784de3
- Freestyle: minor changes to the UI layout of line style options. 5a3fbc8af7645c8
- Freestyle: Added logical operators for binary predicates for 1D elements. 6a94e73a854286f
- Revised freestyle.predicates.pyZBP1D so that the constructor accepts an integration type. a86d8bceb50b996
- Fixes (unreported)
- Freestyle: Added missing mesh property definitions for Freestyle Edge/Face marks. cad4bfe653e12bb
- Freestyle: Fix for VC++ warnings about 'hypot' macro redefinitions.
- part 1 5db8da81055be7f
- part 2 5d4a6a94ef40f8a
- part 3 77b37fa4615dc1e
- part 4 01a4a09f29974ff
- Note: These commits involved a number of code changes in C++. Since they were tested only with MSVC 2008, they broke compilation on Linux. A development environment using MinGW32 was hence set up on my side to better test C++ code updates not only with VC++ but also using GCC.
Week 2: 7th-13th April
Discussions in the bf-blender-npr mailing list
The proposal document was transformed into a personal Wiki page (wiki.blender.org) to inform general audience with the planned development work. An announcement was sent to the bf-blender-npr mailing list to make people aware of this project.
Discussions were started in the bf-blender-npr mailing list to check priority tasks in the planned Freestyle development and talk about ideas of Freestyle improvements. Preliminary coding was done to show a proof-of-concept implementation of ideas that came up through the discussions.
- Crease angle dependent line thickness. The idea is to determine crease line thickness as a function of the angle between the two faces on both sides of the crease line. A quick video clip (vimeo.com/91306354) was made to demonstrate the idea.
- Curvature dependent line thickness. Another Freestyle issue discussed in detail was sudden vanishing and appearance of contour lines along with camera movement. This kind of visual artifact leads to a distraction from the animation flow. It was agreed that what we want was a real number that quantifies the closeness of a contour to a vanishing point. We came to the idea of using radial curvatures to address this problem. An experimental line thickness shader was then implemented and a quick test video clip (vimeo.com/91383521) was created to prove the concept.
The implemented experimental code is presented in a blog post. These features are expected to be part of future Freestyle development (likely to be targets for the 2.72 release).
Development tasks
- General tasks
- Problem report T39669 revealed a data inconsistency between manual and render-time curve-to-mesh conversion (the latter occurs in Freestyle). Additional investigation was asked to Campbell, since the issue is related to different ways of curve-to-mesh conversion and not directly to Freestyle.
- Patch review
- Patch D246: Texture Marks for freestyle strokes.
- Fixes (unreported)
- Fix for Freestyle Python API modules not found in the Python Console. b7b4f94e782f7e7
- Fix for Sinus Displacement and 2D Offset stroke geometry modifiers. 716803c0a0cc99c
- Fix for typos in Freestyle Python API docstrings. dfbd994aaf6f95d
Week 1: 1st-6th April
Freestyle performance improvements
To start with the planned development for improved Freestyle performance, initial attempts were made to reduce memory consumption during Freestyle line rendering.
It is remarked that Freestyle extensively uses double-precision floating-point numbers for internal data structures. Hence, initial code updates were intended to achieve reduced memory consumption by using float (instead of double) for internal data elements.
Simple performance tests showed that the use of float led to a 10% reduction of memory consumption when compared with that of the 2.70 release, but in the case of a test model, the rendering time got approximately a 20% increase. The cause of this slow down was traced to a failure of inverse perspective projection transformation (IPPT) from 2D to 3D. Since both data elements and operations on them were in single precision, Freestyle was more prone to numerical errors due to rounding.
It is noted that Freestyle involves a lot of geometry calculations in the 2D image coordinate system whose extent is defined by the dimensions of the image being rendered. When the render size is large (e.g., 5000-by-5000 pixels), 2D vertex coordinates are likely to suffer of insufficient sub-pixel precision during geometry calculations since single-precision floating-point values have at most 7 significant decimals.
Further code updates were done to use double precision for the IPPT algorithm, which turned out to work fine in most cases. The rendering time is now comparable with the 2.70 release. There are a few cases where IPPT fails. This remaining problem needs to be further addressed.
Course material review
An international team of Blender artists is working on a self-tutoring course on line art with Freestyle and Blender. The course consists of 15 stages covering Freestyle basics, all aspects of the interactive GUI controls, and advanced topics. The course material is full of Freestyle tips and pieces of advice for newcomers.
The course authors asked me to review the recorded audio of course scripts. The audio material for all the 15 stages was duly reviewed from a technical perspective, and a few remarks on the audio and written scripts were sent back to the authoring team.
Development tasks
- Fixes (unreported)
- Freestyle: Fix for debug information about sweep line intersection detection. 75c0ced840aa0ef
- Freestyle: Fix for class definitions of 0D/1D functions (functors). 685d785c98c9b1e
- Freestyle: Removed SVertex _curvatureFredo and _directionFredo and their getter/setter methods. 62bf22e27b47fd9