Commit Graph

32 Commits

Author SHA1 Message Date
Tamito Kajiyama
f0acdcf135 Fix for stroke rendering instability with stroke geometry shaders.
* Stroke::Resample(int nPoints) was not properly working when a wrong
value was returned from Stroke::getLength2D(), resulting in repeated
warning messages "Warning: incorrect points number" during stroke
rendering.  The main cause was that stroke geometry shaders did not
update the two-dimensional (2D) length (also referred to as curvilinear
abscissa) after they modified the 2D points of stroke vertices.  Now
all stroke geometry shaders make explicit calls for Stroke::UpdateLength()
that has been introduced for recomputing the 2D length.  Many thanks to
Josef who reported the problem together with sample .blend files for
reproducing the issue.

* Missing Python wrapper of Stroke::getLength2D() was added.
2011-10-30 16:00:35 +00:00
Tamito Kajiyama
f0ca79bccb Extended the set of conditions for feature edge selection by edge types.
In the Parameter Editor mode, each edge type check button in the Selection
by Edge Types has now an associated toggle button to exclude the edge type
from the feature edge selection.  This allows you to select, for instance,
those edges that are silhouette lines but not external contours.
2011-10-27 20:57:14 +00:00
Tamito Kajiyama
510c69368b New option for disabling the chaining of feature edges in the Parameter Editor mode. 2011-10-25 23:24:59 +00:00
Tamito Kajiyama
28cc31ba11 Stability improvements for the Face Smoothness option.
The instability considered here is due to a persistent failure of the
getFEdge() method in the Interface0D class and its subclasses in the
presence of smooth FEdges.  When the Face Smoothness option is
enabled, the view map is populated with not only sharp FEdges (i.e.,
edges in the original meshes) but also smooth FEdges (i.e., newly
built edges lying on triangular surfaces).  The failure of getFEdge()
caused many related issues because the method is widely used in other
predicates and functions that rely on it.  The most prominent example
of related user-visible problems is a constant failure of the built-in
MaterialF0D.

The main issue and related problems were addressed as follows:

* A bug in the construction of smooth FEdges was fixed.  Individual
smooth FEdges, even when they were detected as a series of smooth
FEdges that constitute one smooth ViewEdge, may have some irregular
geometry in the form of non-uniform OWXFaceLayer::order values.  The
OWXFaceLayer::order values were used in an inappropriate way, so that
resulting smooth ViewEdges may have an FEdge between two subsequent
SVertices that were indeed the same SVertex object.  This was an
unexpected situation that getFEdge() could not handle.

* Another issue in the construction of smooth FEdges was resolved.
When sharp FEdges are constructed, two SVertices at both ends of an
FEdge are generated only when no SVertex exists in a given 3D position
(this way, the original mesh topology is reconstructed from a bunch of
independent triangles that the BlenderFileLoader class passes to the
view map creation process).  This sharing of SVertices was used also
for the generation of SVertices at the two ends of each smooth FEdge,
causing the getFEdge() failure in the presence of smooth FEdges.  The
workaround implemented here is to simply suppress the sharing of
generated SVertices when smooth FEdges are created.

* In the Parameter Editor mode, the built-in MaterialF0D was replaced
with a better implementation that works well with Curves and Strokes.
MaterialF0D does not work with these 1D data types.
2011-10-10 19:57:06 +00:00
Tamito Kajiyama
f84e8e7640 Fine control of feature edge selection with mesh face and edge marks.
New "face marks" and "edge marks" have been introduced in mesh data
blocks.  In the edit mode of a mesh object, face marks can be put
to selected faces by choosing Mesh >> Faces >> Mark Freestyle Face
from the menu of a 3D View window or Ctrl-F >> Mark Freestyle Face
from the context menu.  Similarly, edge marks can be put to selected
edges by Mesh >> Edges >> Mark Freestyle Edge or Ctrl-E >> Mark
Freestyle Edge.  These marks should work fine with the Subdivision
surface modifier.

Moreover, two new conditions for feature edge selection have been
added to the Parameter Editor mode as described below:

1. The Selection by Edge Types option has now the new Edge Mark type,
which can be used to (de)select feature edges having edge marks.
This option can be used to add to (or remove from) the view map
arbitrary edges of mesh objects.

2. Selection by Face Marks option has been newly introduced, in which
face marks are used for feature edge selection in two ways.  One
option is called "One Face" which is to (de)select feature edges if
one of faces on the left and right of each feature edge has a face
mark.  The other option is "Both Faces" to (de)select feature edges
if both faces on the left and right have a face mark.
2011-10-06 02:04:43 +00:00
Tamito Kajiyama
c41e64b9da Changed the behaviour of the Perlin 1D geometry modifier. Now it distorts
strokes using the curvilinear abscissa of stroke vertices as the input of
the Perlin noise generator (instead, the Perlin 2D geometry modifier generates
noise using the 2D coordinates of stroke vertices in the image space as the
input of the noise generator).
2011-09-25 09:50:12 +00:00
Tamito Kajiyama
5582d9fac1 Rearranged the organization of chaining options in line styles.
New there are only two chaining types: plain and sketchy.  Both chaining types
have the "same object" option.  With this option enabled, only feature edges of
the same object are chained.  The sketchy chaining also has the "rounds" option
to specify the number of rounds in a sketchy multiple touch.

Also removed a temporary workaround (implemented by means of a custom chaining
rule) for infinite straight lines, which has resulted in much cleaner strokes.
2011-09-19 23:24:14 +00:00
Tamito Kajiyama
38f24637d4 Added new line style options for sketchy chaining of feature edges.
The default chaining option is now called "Natural", while the new chaining options
are "Sketchy: Topology Preserved" and "Sketchy: Topology broken".  The latter two
options allow for generating chains of feature edges with a sketchy multiple touch.
The "Sketchy: Topology Preserved" option takes account of the topology of objects
in the view map, while the "Sketchy: Topology broken" ignores the edge topology.
The "rounds" option specifies the number of rounds in sketchy strokes.
2011-09-19 22:40:44 +00:00
Tamito Kajiyama
513293a256 Added new line style options for selecting chains by min/max 2D lengths. 2011-09-18 22:59:51 +00:00
Tamito Kajiyama
6be21a9125 Implemented a calligraphic thickness modifier in the Parameter Editor mode.
Also fixed a typo in the docstring of the CalligraphicShader.
2011-09-11 19:57:38 +00:00
Tamito Kajiyama
edde9f2666 Added an 'angle' parameter to the Perlin Noise 1D and 2D geometry modifiers
to specify a displacement direction in degrees.
2011-08-30 00:29:12 +00:00
Tamito Kajiyama
f631d3aaa9 Fix for round and square tips not working. Bug reported by tungee, thanks! 2011-08-22 12:42:56 +00:00
Tamito Kajiyama
1a4b7f8195 Fix for deprecation warning regarding the reverse order of matrix-vector
multiplication operands.
2011-08-21 00:02:53 +00:00
Tamito Kajiyama
6bc5d5258f Stroke geometry modifiers
Added a set of stroke geometry modifiers to the Geometry tab of line styles
in the Parameter Editor mode.  Now the following stroke geometry modifiers are
available, each with a set of animateable parameters:
- Sampling: changes the resolution of stroke backbone polylines.
- Bezier Curve: replace stroke backbone with a Bezier approximation of the
  stroke backbone.
- Sinus Displacement: add sinus displacement to stroke backbone.
- Spatial Noise: add spatial noise to stroke backbone.
- Perlin Noise 1D: add one-dimensional Perlin noise to stroke backbone.
- Perlin Noise 2D: add two-dimensional Perlin noise to stroke backbone.
- Backbone Stretcher: stretch the beginning and the end of strokes.
- Tip Remover: remove a piece of stroke at the beginning and the end of strokes.

To branch users: When you have a .blend file with Freestyle options specified,
you may want to add a Sampling modifier with the 'sampling' value set to 5.
This value specifies a resolution of polylines for line drawing in Freestyle.
If no sampling modifier is specified, your line drawing will result in coarse
polylines.  Before geometry modifiers were introduced, this initial sampling
was automatically done.  Now the initial sampling is a tunable parameter that
can be omitted, allowing better control on polyline resolution.
2011-08-19 14:05:11 +00:00
Tamito Kajiyama
66950123f1 Added a proper getName() method to MaterialBoundaryUP0D. 2011-08-13 00:26:18 +00:00
Tamito Kajiyama
8e4e36874c Removed unnecessary debug print statements. 2011-08-13 00:19:58 +00:00
Tamito Kajiyama
5057810bda New line style option for splitting chains of feature edges at material boundaries. 2011-08-13 00:05:25 +00:00
Tamito Kajiyama
0a9094a8e3 New line style modifiers for changing line color, alpha transparency, and
line thickness based on object materials.  Accessible material attributes
are diffuse color, specular color, specular hardness, and alpha.
2011-07-24 23:29:19 +00:00
Tamito Kajiyama
4c3140004a Fixed a bug introduced in the last commit to address the issue
of cap shaders.
2011-07-03 07:48:19 +00:00
Tamito Kajiyama
5a516098fc Fixed cap shaders that failed with zero length strokes. 2011-07-02 16:27:52 +00:00
Tamito Kajiyama
3e11ad64d5 Fix for the Distance from Object modifier. The problem was
reported by ikeahloe.  Thanks!
2011-04-12 22:30:18 +00:00
Tamito Kajiyama
949a752ddd Made stroke rendering stability fixes, with the aim of addressing
occasional unexpected long lines.

1. The Parameter Editor mode was extended to prevent strokes from
doing quick U-turns that "enable" a known bug in strip creation
that generates unexpected long lines in question.

2. A verbose warning message was added to make the existence of
the strip creation bug visible to users.  When the bug affects the
stroke rendering, the following warning shows up in the console:

> Warning: problem in strip creation (the strip is most likely doing a U-turn).

3. The extrapolation option of CurveMapping (used in alpha and
thickness modifiers in the Parameter Editor mode) was identified
as another source of unexpected long lines.  Now the extrapolation
option is unconditionally disabled (even when users enable it
through the GUI).
2011-01-31 20:57:39 +00:00
Tamito Kajiyama
79547351fe Fix for a bug in the Distance from Object modifiers.
The bug was reported by Jonathan Hudson, thanks!
2010-12-04 09:58:58 +00:00
Tamito Kajiyama
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
Tamito Kajiyama
1bfcba31d2 New feature edge selection criterion based on object groups.
The Freestyle tab in the Render buttons has a couple of new
options "Group" and "Group Negation".  The Group option specifies
a group of objects (defined through the Groups tab in the Object
buttons), while the Group Negation value is either INCLUSIVE or
EXCLUSIVE.  If INCLUSIVE, feature edges belonging to some object
in the group are selected.  Otherwise, those feature edges not
belonging to any object in the group are selected.
2010-12-02 23:50:10 +00:00
Tamito Kajiyama
86e433728d Added support for dashed line in the Parameter Editor mode. 2010-10-23 20:42:26 +00:00
Tamito Kajiyama
cc77207ca4 Fix for missing toggle switches to enable/disable linesets. Also gave
uniform property name "use" to all toggle switches in Freestyle-related
options, according to recent RNA renaming.
2010-10-10 23:34:27 +00:00
Tamito Kajiyama
84f5a9a718 Added support for three types of stroke caps that determines the shape
of both ends of strokes.  The three cap types are: 1) butt caps (flat);
2) round caps (half-circle); and 3) square caps (flat and extended).
Also implemented an option to join those feature edges of the same
object.  These options are available in the "Stroke" tab of the
"Freestyle: Line Style" panel in the Render buttons.
2010-10-10 22:50:32 +00:00
Tamito Kajiyama
4cfdedbe61 Implemented "Distance from Object" color/alpha/thickness modifiers
in the new Parameter Editor mode.
2010-08-01 22:11:57 +00:00
Tamito Kajiyama
092313a89d Implemented "Distance from Camera" color/alpha/thickness modifier in
the new Parameter Editor mode.  Refactored shader class definitions
and the way of iteration over stroke vertices.
2010-08-01 16:02:34 +00:00
Tamito Kajiyama
a99a466fee * Made the Parameter Editor mode much more functional. Edge selection
criteria, as well as the color/alpha/thickness Along Stroke modifiers
now work.

* Added more curve blend types.  The default is set to "MIX".
2010-07-28 00:43:45 +00:00
Tamito Kajiyama
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