[Bf-blender-npr] Intersections in freestyle

Tamito KAJIYAMA rd6t-kjym at asahi-net.or.jp
Mon Feb 10 15:45:00 CET 2014


Hi Paolo,

Your continued efforts on Freestyle development, and especially on the
face intersection detection are much appreciated. Since the work on
intersection lines is likely something massive and time-consuming, here
I would start with descriptions of Freestyle components and additional
random thoughts rather than organized suggestions.

Data structures:

- The key data structure that eventually feeds intersection lines to
stroke rendering is the ViewMap class, which is basically a set of
ViewEdges. A ViewEdge is a 2D/3D polyline (i.e., a sequence of straight
line segments) consisting of one or more FEdges representing feature
edges. Hence our goal here is to transform the detected intersection
lines into FEdges.

- There are two FEdge subclasses: FEdgeSharp and FEdgeSmooth. Actually
ViewEdges are composed of either FEdgeSharp instances only or
FEdgeSmooth instances only. FEdgeSharp corresponds to edges in the
imported mesh data. FEdgeSmooth represents additional edges that do
not exist in the original mesh geometry. Specifically, FEdgeSmooth is
used to represent smooth silhouettes, suggestive contours, and
ridges/valleys computed taking face smoothness into account.

- I guess intersection lines will be represented by FEdgeSmooth.

- Freestyle has been designed to work on edges of faces. Each edge is
assumed to have one or two faces on its sides. Edges without faces on
their sides, as well as edges shared by three or more faces are not
allowed at the moment.

Data processing:

- There are several stages of data processing, starting from the initial
mesh geometry (imported by BlenderFileLoader) up to the ViewMap:

1. WXEdgeBuilder generates WingedEdges from the imported mesh data;
2. FEdgeXDetector finds feature edges of interest from the WingedEdges
and annotates the identified feature edges with edge types and other
attributes;
3. ViewMapBuilder generates a ViewMap by converting the selected feature
edges into ViewEdges and computing line visibility.

- It is my impression that either FEdgeXDetector or ViewMapBuilder would
be a place to implement face-to-face and face-to-line intersection
algorithms, because intersection lines are high-level line components
built on top of low-level mesh geometry.

Additional thoughts:

- Adding intersection lines into ViewMap is likely to require major data
structure updates, since intersection lines are something completely new
in the Freestyle internal design. Careful review of the data processing
is necessary in light of intersection lines.

- Since the code updates may involve major refactoring, this task would
be a nice opportunity to consider supporting a few more additional input
scene components such as curves and grease pencil strokes requested
previously by Freestyle users. These geometry data types don't have
faces by definition, so Freestyle currently cannot handle them at all.
Making the internal data processing of Freestyle more flexible in view
of intersection lines would be more beneficial if it eventually allows
for faceless scene components in the future work.

That's it for now. Questions are very welcome.

Regards,
-- 
KAJIYAMA, Tamito <rd6t-kjym at asahi-net.or.jp>


On 10/02/2014 01:57, Paolo Acampora wrote:
> Hi, next missing feature we need so much is intersections. What I'm
> trying to do is detecting intersections during the parsing of objects,
> when we can inspect the shapes. I'm hacking the
> BlenderFileLoader::Load() function, in BlenderFileLoader.cpp, I can do a
> triangle intersection test for each two triangles and come out with
> point A and B of intersection segment in camera space. Now the hard
> part: how can we actually draw the line? I still don't know where
> freestyle handles this kind of stuff, maybe in the Controller or the
> EdgeDetector. If we feel hackish, we could just create a render object
> for the intersection lines, but I would not like to resort to this (and
> it's not that easy either anyway).
>
> I hope I can show some code soon, cheers!
>
> --
> Paolo Acampora, palucam at gmail.com <mailto:palucam at gmail.com>
> Thecnical Director at MAD entertainment, Naples (Italy)


More information about the Bf-blender-npr mailing list