In the previous blog article, we reported a crash in rendering complex scenes. The problem turned to be the consequence of an “out of memory” error during stroke rendering. When objects exist out of the view frustum and near the near clipping plane, feature edges in the 3D camera coordinate system are projected to an extremely far location out of the camera view in the 2D image space. These feature edges result in very long strokes with a large number of stroke vertices, which temporarily require a significant memory storage, possibly causing a fatal “out of memory” error. This problem was partially addressed by omitting unnecessary stroke vertices just before the stroke rendering. There is no user-visible negative side effect. Further memory usage improvements are possible on the users’ side (i.e., in a style module) by explicitly selecting feature edges within the camera view. This can be done by applying a custom edge selection predicate as follows:
import Freestyle
scene = Freestyle.getCurrentScene()
w = scene.render_data.resolution_x
h = scene.render_data.resolution_y
class WithinCameraViewUP1D(UnaryPredicate1D):
def getName(self):
return "WithinCameraViewUP1D"
def __call__(self, inter):
for v in [inter.A(), inter.B()]:
x = v.getProjectedX()
y = v.getProjectedY()
if 0 <= x <= w and 0 <= y <= h:
return 1
return 0
Operators.select(AndUP1D(WithinCameraViewUP1D(),
QuantitativeInvisibilityUP1D(0)))
If you have got a number of “strip vertex 0 non valid” warning messages followed by a crash, then try using the WithinCameraViewUP1D predicate to exclude those feature edges that do not appear in the rendering result. User-side memory consumption contol of this kind should substantially improve the stability of the renderer.
We then moved on to improvements of mesh importing. Now the Freestyle renderer can deal with mesh deforming modifiers including Curve, Mesh Deform, Cloth and Soft Body. Previously, mesh vertices imported from vlak nodes were transformed from the camera coordinate system to the object local coordinate system. This causes a difficulty in recovering mesh vertices in the object local coordinate system when mesh deforming modifiers have been applied. Now the view map creation is carried out based on mesh vertices in the camera coordinate system. This approach requires less transformation matrix operations and thus is faster and less affected by numerical errors.
We also fixed a bug in the handling of aspect ratio settings. The bug caused a strange Y-direction offset of strokes. Now the aspect ratio settings are properly respected.
Finally, we worked on orthographic camera support. Silhouette edge detection and view map creation have been enhanced, and now both perspective and orthographic cameras are supported. The following image is a test render for a comparison of the two camera modes.

Comments, problem reports, and any kind of feedback are welcome as usual. Have fun!