Commit Graph

48 Commits

Author SHA1 Message Date
f06335e12f Fix for view map cache not flushed by updates of edge detection options.
This fix should be considered for inclusion in the 2.73 release, since
it concerns a new feature of Freestyle introduced in 2.73.
2015-01-03 15:40:07 +09:00
3fea13ed6c Freestyle: Fix for view map caching not flashed properly in view port rendering. 2014-11-26 23:26:20 +09:00
6308c16675 Refactor: BLI_path_util (split out app directory access)
This module is intended for path manipulation functions
but had utility functions added to access various directories.
2014-11-23 18:42:18 +01:00
e99919f713 Freestyle: For until c++11 is accepted only static members could b initialized in-lined 2014-10-02 19:24:16 +06:00
c47682d6ab Freestyle: Fix for destructive view map modifications during chaining operations.
The view map is mostly treated as a read-only data structure by line stylization
operations (i.e., selection, chaining, splitting, sorting and stroke creation).  The
only exception is the chaining operation in some cases where insertion of extra
FEdge objects is necessary to ensure the continuity of underlying FEdges from
which a chain is constructed.

The present revision addresses the removal of extra FEdges so to keep the view
map clean and suitable for reuse in subsequent render frames.
2014-10-02 17:52:16 +09:00
dd9c53b312 Freestyle: View map caching.
New render layer option named "View map cache" is added to reuse a
previously computed view map for subsequent rendering.  The cache is
automatically updated when the mesh geometry of the input 3D scene has
been changed.

This functionality offers a major performance boost for Freestyle
animation rendering when camera-space mesh geometry is static, as well
as for repeated still renders with updates of line stylization options.

Although the "View map cache" toggle is a render layer option, the cache
memory is shared by all render layers and scenes.  This means that if
Freestyle is used for two or more render layers (possibly in different
scenes through the compositor), then the cached view map for one render
layer is replaced by a new view map for another render layer and hence
no performance gain is expected.
2014-10-02 17:52:13 +09:00
b65a022892 Freestyle: Removed the stored bContext from the Controller class.
The stored context object was used for creation of shade nodes.  A closer look at the
node system showed that the context is not actually used when shader nodes are
added to a shader node tree.  Relying on this fact, now a NULL pointer is passed to
nodeAddStaticNode() instead of the stored bContext pointer.
2014-08-12 10:10:55 +09:00
34c133a488 Freestyle: an improved workflow of line style shading nodes.
Removed the previous changes for passing a line style through the Controller, and
revised the BlenderTextureShader to assign the shader node tree of a line style
(if specified) to strokes.  This way the assignment of shading nodes can be done
through both the Freestyle GUI and Python scripting.
2014-08-12 10:10:36 +09:00
c38e80d632 WIP commit just for a record of a working snapshot of code revisions for node-based textured strokes. 2014-08-12 10:10:35 +09:00
fc85446c50 Freestyle: Added preliminary support for textured strokes in Cycles.
Now the shader node tree of a line style ID datablock is used to define textures
as well as their mapping and influence.

TODO: Textures alpha channel mapping and influence.
TODO: Blend mode in the Output Line Style shader node.
2014-08-12 10:10:20 +09:00
f75d87bd76 Initial implementation of Cycles materials for Freestyle stroke rendering. 2014-08-12 10:10:06 +09:00
97d047a3e9 Fix T40307: Crash with freestyle and particle hair.
The scene file provided by the problem report has many degenerate faces coming from
a particle system.  These zero-area faces were not expected in the ray-casting line visibility
algorithms of Freestyle.  Now degenerate faces are properly excluded from the imported
mesh data and not fed to the line visibility algorithms.
2014-05-22 23:18:47 +09:00
dfe800b4a8 Freestyle: debug statistics on stroke rendering. 2014-05-07 23:16:22 +09:00
68aea619f5 Replaced assert() with BLI_assert(). 2014-04-17 14:37:11 +09:00
77b37fa461 Freestyle: Fix for VC++ warnings about 'hypot' macro redefinitions (Part 3).
(See commit e1771e72fbbf828dbf5bed871b814288389f3611 for more detail of
the problem).

Made changes to intern/view_map/Interface0D.h and intern/python/Director.h to
avoid #include <Python.h> and keep non-Python header files independent of it.
2014-04-17 14:37:08 +09:00
b7b4f94e78 Fix for Freestyle Python API modules not found in the Python Console.
Addition of the path to the Freestyle Python API modules to 'sys.path' was delayed until
the first Freestyle rendering, so that any import attempt of the modules in the Python
Console always failed.  Now the update of 'sys.path' is done at Blender start-up.
This allows the Freestyle-specific modules to be imported without running Freestyle,
facilitating quick interactive testing in the Console.
2014-04-11 16:36:49 +09:00
41e563594d Code Cleanup: int pointer comparison 2013-11-22 08:39:13 +11:00
248e3d74a0 Fix for [#36374] Read unitialized memory in Freestyle.
A variable keeping a bounding box was referenced after it was flagged as empty.
2013-08-24 11:42:00 +00:00
5520331215 Fix #35561: freestyle + read full sample layers = crash.
Now add_freestyle() in pipeline.c takes a second argument to enable/disable
stroke rendering.  When stroke rendering is disabled, the function allocates
data structures but does not perform stroke rendering.  The allocated data
structures (mostly left unpopulated with data elements) are intended to allow
for the Read Full Sample Layers (Shift-R) command in the compositor.
2013-06-11 02:32:01 +00:00
5e4139c50a More fix for memory leaks in the Freestyle module. 2013-05-15 01:30:03 +00:00
04cbb3ad14 Fix for [#35116] Freestyle StringUtils::toAscii breakes non-ascii path values.
Just removed all calls of StringUtils::toAscii() as well as the function definitions.
2013-05-01 13:34:56 +00:00
800f86c845 Attempt to fix a potential name conflict between Freestyle and the compositor.
A crash in the Freestyle renderer was reported by Ton on IRC with a stack trace
below.  Note that #2 is in Freestyle, whereas #1 is in the compositor.  The problem
was observed in a debug build on OS X 10.7 (gcc 4.2, openmp disabled, no llvm).

----------------------------------------------------------------------
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
[Switching to process 72386 thread 0xf303]
0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43
43			delete (this->m_outputsockets.back());
Current language:  auto; currently c++
(gdb) where
#0  0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43
#1  0x0000000100c29066 in Node::~Node (this=0x10e501c80) at COM_Node.h:49
#2  0x000000010089c273 in NodeShape::~NodeShape (this=0x10e501c80) at NodeShape.cpp:43
#3  0x000000010089910b in NodeGroup::destroy (this=0x10e501da0) at NodeGroup.cpp:61
#4  0x00000001008990cd in NodeGroup::destroy (this=0x10e5014b0) at NodeGroup.cpp:59
#5  0x00000001008990cd in NodeGroup::destroy (this=0x114e18da0) at NodeGroup.cpp:59
#6  0x00000001007e6602 in Controller::ClearRootNode (this=0x114e19640) at Controller.cpp:329
#7  0x00000001007ea52e in Controller::LoadMesh (this=0x114e19640, re=0x10aba4638, srl=0x1140f5258) at Controller.cpp:302
#8  0x00000001008030ad in prepare (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:302
#9  0x000000010080457a in FRS_do_stroke_rendering (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:600
#10 0x00000001006aeb9d in add_freestyle (re=0x10aba4638) at pipeline.c:1584
#11 0x00000001006aceb7 in do_render_3d (re=0x10aba4638) at pipeline.c:1094
#12 0x00000001006ae061 in do_render_fields_blur_3d (re=0x10aba4638) at pipeline.c:1367
#13 0x00000001006afa16 in do_render_composite_fields_blur_3d (re=0x10aba4638) at pipeline.c:1815
#14 0x00000001006b04e4 in do_render_all_options (re=0x10aba4638) at pipeline.c:2021
----------------------------------------------------------------------

Apparently a name conflict between the two Blender modules is taking place.
The present commit hence intends to address it by putting all the Freestyle C++
classes in the namespace 'Freestyle'.  This revision will also prevent potential
name conflicts with other Blender modules in the future.

Special thanks to Lukas Toenne for the help with C++ namespace.
2013-04-09 00:46:49 +00:00
fcf137dbd7 style cleanup 2013-04-08 04:39:09 +00:00
829a2cc1b0 remove blender foundation copyright from freestyle files.
this can be added back on case-by-case basis, but better not assume ownership of another projects work by default.
2013-03-31 01:11:07 +00:00
4a92d82626 A big code clean-up patch from Bastien Montagne, many thanks! 2013-03-07 23:17:23 +00:00
6645551aed Removed paths to a browser command and help index that are no longer used in Freestyle for Blender.
Review comment from Campbell.
2013-03-02 18:31:32 +00:00
ec78eb353f New command-line option --debug-freestyle to enable verbose debug messages
on the console during Freestyle rendering.  The debug prints are turned off
by default now.  Errors are still printed on the console.

A patch set implementing this functionality was provided by Bastien Montagne.
Many thanks! :)
2013-01-03 23:27:20 +00:00
10f0f66560 Another big code clean-up patch by Bastien Montagne (GPL headers, indentation,
spaces around operators, and so forth).  Many thanks!
2012-12-18 00:51:25 +00:00
6569902081 Fix for svn:executable.
Reported by Bastien Montagne, thanks!
2012-12-11 23:01:21 +00:00
cdc1e5a716 Split time measurement for temporary scene generation from that for stroke rendering. 2012-10-06 14:08:26 +00:00
5a581c1fd1 Better handling of the ESC key during Freestyle rendering.
This commit is meant to improve the response of the ESC key for stopping Freestyle rendering
throughout the rendering process.  The rendering with Freestyle consists of several steps
including: (1) mesh data loading, (2) winged edge construction, (3) silhouette edge detection,
(4) view map construction, and (5) stroke drawing.  All these steps have been extended to
frequently check if the ESC key is pressed, so that users can abort time-consuming rendering
at any point of time.
2012-07-16 23:29:12 +00:00
cb4f662927 Fix for an uninitialized member variable. 2011-10-05 21:10:23 +00:00
4569f9ae4e Optimized view map calculation by Alexander Beels.
* View map calculation has been intensively optimized for speed by
means of:

1) new spatial grid data structures (SphericalGrid for perspective
cameras and BoxGrid for orthographic cameras; automatically switched
based on the camera type);

2) a heuristic grid density calculation algorithm; and

3) new line visibility computation algorithms: A "traditional"
algorithm for emulating old visibility algorithms, and a "cumulative"
algorithm for improved, more consistent line visibility, both exploiting
the new spatial grid data structures for fast ray casting.

A new option "Raycasting Algorithm" was added to allow users to choose
a ray casting (line visibility) algorithm.  Available choices are:

- Normal Ray Casting
- Fast Ray Casting
- Very Fast Ray Casting
- Culled Traditional Visibility Detection
- Unculled Traditional Visibility Detection
- Culled Cumulative Visibility Detection
- Unculled Cumulative Visibility Detection

The first three algorithms are those available in the original
Freestyle (the "normal" ray casting was used unconditionally, though).
The "fast" and "very fast" ray casting algorithms achieve a faster
calculation at the cost of less visibility accuracy.

The last four are newly introduced optimized options.  The culled
versions of the new algorithms will exclude from visibility
calculation those faces that lay outside the camera, which leads to a
faster view map construction.  The unculled counterparts will take all
faces into account.  The unculled visibility algorithms are useful
when culling affects stroke chaining.

The recommended options for users are the culled/unculled cumulative
visibility algorithms.  These options are meant to replace the old
algorithms in the future.

Performance improvements over the old algorithms depend on the scenes
to be rendered.

* Silhouette detection has also been considerably optimized for speed.

Performance gains by this optimization do not depend on scenes.

* Improper handling of error conditions in the view map construction
was fixed.
2011-03-14 00:36:27 +00:00
ad608f30e0 Made a change as to when the view map data structure is released,
with the aim of less memory consumption in stroke rendering.
2010-12-05 13:12:55 +00:00
a9e50bde82 A few attempts to reduce the amount of memory consumption in Freestyle.
* Made changes to the Controller so that dynamically allocated
memory areas (e.g. imported mesh data, winged edges, and a view map)
are released soon after they become unnecessary.

* Added a new feature edge selection criterion based on image border.

When the "Selection by Image Border" option is enabled, feature edges
are selected only if they are within the border of the image being
rendered.  The border is defined either by the frame size or a border
region (specified by the Shift-B key in a 3D View window).  When large
scenes are rendered, this clipping by the image border leads to less
memory consumption.

* Enabled the "Silhouette", "Border", and "Crease" edge types of
the Selection by Edge Types option by default.

When no edge types are specified, all feature edges including "Ridge",
"Valley" and "Suggestive Contour" are detected at the cost of extra
memory consumption.  Disabling these three edge types and enabling
some other edge type leads to less memory consumption.  This change
is intended to help new Freestyle users by providing a typical, low
memory consumption default setting.

* Slightly rearranged the UI controls for feature edge selection.
2010-12-03 23:17:49 +00:00
90b69a13a7 Fix for a bug that style modules from wrong scene render layers
were executed.  The bug was reported by Dazzle in the BA Freestyle
thread, thanks!
2010-10-17 14:36:07 +00:00
25ce805a58 * Implemented the basic stroke rendering functionality for the new
Parameter Editor mode.  This is a WIP commit.  Only the base line
color, base alpha transparency, and base line thickness are respected.
More additions are anticipated to account for other parameters.

* Added FRS_finish_stroke_rendering() to clean Freestyle-related
temporary resources after stroke rendering.

* Some functions in FRS_freestyle.cpp are now declared as static
functions, so as not to mess up the program-wide name space.

* Made the StyleModule class inheritable, and defined new subclass
BlenderStyleModule that takes a Text object instead of a file name.
2010-07-26 01:23:27 +00:00
7d377478c3 New option to specify the angular threshold for detecting crease edges.
An entry "Crease Angle" has been added to the Layers tab of the Render
buttons, to allow users to specify an angle (between 0 and 180) used for
crease edge detection.  An edge is considered a crease edge if the angle
between two faces sharing the edge is smaller than the threshold.  The
default value is 134.43 degrees (for backward compatibility).  Be aware
that a larger threshold leads to a larger number of feature edges and
thus a larger memory consumption.
2010-05-22 23:56:42 +00:00
b85985535d New option for detecting feature edges at material boundaries.
A checkbox "Material Boundaries" has been added to the Freestyle
options in the Layers tab of the Render buttons.  By enabling the
option, any edge between two faces with different materials is
detected as a feature edge.  In style modules, edges at material
boundaries can be tested with pyNatureUP1D(Nature.MATERIAL_BOUNDARY).
2010-05-22 22:21:15 +00:00
840ba8e8e7 Fixed the full sample anti-aliasing support in Freestyle.
The render pipeline has been extended to better work with
Freestyle stroke rendering.  Struct Render has a new member
ListBase freestyle_renders to keep Render instances generated
through stroke rendering in Freestyle.  The number of
elements (LinkData instances with LinkData::data pointing to a
Render instance) in freestyle_renders is the same as the scene
render layers of the scene being rendered.  When the k-th scene
render layer has the Freestyle option enabled, the k-th element
of freestyle_renders refers to a Render instance that holds
Freestyle render results for the scene layer.  This association
between the scene render layer and the Render instance is used to
merge the Freestyle render results into the corresponding render
results for the scene render layer.
2010-03-28 17:46:10 +00:00
39ea873a8b Fixed bugs in AppCanvas::readColorPixels() and
AppCanvas::readDepthPixels() that caused a crash when
the aspect ratio was not 1:1.
2010-02-16 21:44:18 +00:00
903cc89e30 Added support for pixel-based density and Z depth information.
Availability of pixel-based density and Z depth information depends
on passes of a render layer being rendered.

- Density information is available if the diffuse pass of the render
layer is enabled.  It is accessible through the DensityF0D and
DensityF1D functions provided by the Freestyle Python API.  These
functions return 0 if the diffuse pass is disabled.

- Z depth information is available if the Z pass is enabled.  It can
be accessed through LocalAverageDepthF0D and LocalAverageDepthF1D.
These functions return 0 if the Z pass is disabled.
2010-02-14 03:17:52 +00:00
1b3948f9aa Further consolidation of the view map creation.
Made Controller::_EPSILON constant with the value 1e-6.  Previously,
the _EPSILON value was computed based on the minimum edge size within
the scene being rendered (in some cases, the computed value resulted
in zero).  This does not seem to make sense, because _EPSILON has been
used as a tolerance threshold of floating-point arithmetic errors
throughout the view map creation.  Since Blender uses single-precision
real values for mesh data representations, the new constant _EPSILON
value looks more adequate.
2010-02-12 23:24:59 +00:00
107667d20a Added support for orthographic camera.
The FEdgeXDetector class for silhouette edge detection and the
ViewMapBuilder class for view map creation are enhanced.  All changes
are related to view point handling (i.e., the camera location).  In
the perspective projection, the visibility of feature edges and edge
types (e.g., borders and crease lines) are computed based on a fixed
view point, whereas the view point in the orthographic projection is
an arbitrary point on the XY plane at the origin and is determined so
that a line segment from the view point to a point in the 3D space is
perpendicular to the XY plane.  All view point related portions of the
class definitions were modified so as to deal with the two different
camera modes.
2010-01-31 22:56:19 +00:00
51efe7de27 Improved context handling. Previously FRS_initialize() was used for both
initializing Freestyle and specifying contexts, making the API a bit messy.
Now FRS_initialize() is only for initialization, and contexts are specified
by new FRS_set_context() function just before starting rendering.
2009-11-10 00:03:31 +00:00
Maxime Curioni
dc81204c91 TK's patch to correct the PythonInterpereter 2009-10-15 03:32:53 +00:00
Maxime Curioni
896a5fccef fixed headers and SConscript to have successful build 2009-10-05 01:27:35 +00:00
Maxime Curioni
e3e6e3ff0c renamed folders 2009-10-05 00:37:30 +00:00