Python Sketch and Toon Material¶
Python code can be executed from a Sketch And Toon Material to control the Color, Thickness and the Opacity. In all of these three channels, it’s possible thick Python checkbox to enable it.
The Color channel expects a
c4d.Vector to be returned while Thickness and Opacity channel expect a float.
The important Threading Information.
Override - Mandatory method, used to define the parameter value. It’s called for each sample of the
The following variables are defined in the main function of the Python Sketch and Toon (they are all read-only, modifying these values will have no effect):
BaseObject: The current object being sampled. It must be noted that it’s the
BaseObjectstored in the
VolumeData, an optimized version of the BaseObject used by the render engine. Not all data are copied (e.g. UserData are lost).
sPosition: Float: Distance from LineStart to the current sampled point of the actual line sampled.
sNormalisedP: Float: Distance from LineStart to the current sampled point of the actual line sampled normalized between 0 and 1.
ToLine: Float: Distance from the original Line.
LineOff: Float: Percent of the point sampled depending on the total the total line.
thickness: Float: Line thickness at the sampling point.
StrokeLength: Float: Total length of the actual line sampled.
Vector: Screen position currently sampled.
Vector: World position currently sampled.
Time: Float: Current time rendered in seconds.
Frame: Int: Current frame rendered.
FPS: Int: Frame rate per second of the document rendered.
Vector: Screen coordinates at the line starting point.
Vector: Screen coordinates at the line ending point.
JoinAngleA: Float: Angle of the current line and previous lines drawn.
JoinAngleB: Float: Angle of the current line and next lines drawn.
Vector: The normal of the line currently draw, defined by (A->B)%(0,0,1).
Vector: The normal of the line currently draw, defined from the polygon angles.
LinePosA: Float: Position of A from the actual line sampled.
LinePosB: Float: Position of B from the actual line sampled.
PntA: Int: Point id of the StartLine.
PntB: Int: Point id of the EndLine.
PolyA: Int: Polygon id of the StartLine.
PolyB: Int: Polygon id of the EndLine.
Vector: Current color.
NotePython Sketch and Toon layer is always evaluated after all others modifiers.Only available in the color channel of the Sketch and Toon material.
RayBits: Int: Ray information, these values are:
Ray chain contains a reflection ray.
Ray chain contains a transparency ray (refractions are not contained).
Ray chain contains a refraction ray.
Ray chain contains a custom ray.
Current ray is a reflection ray.
Current ray is a transparency ray.
Current ray is a refraction ray.
Current ray is a custom ray.
Current ray is used to calculate a volumetric light.
Custom mixing of visible light sources allowed for the ray; bit must be deleted by shader if used.
Current ray is a Global Illumination ray.
Current ray is a blurry ray.
Current ray is a subsurface scattering ray.
Current ray is an Ambient Occlusion ray.
Current ray is a compositing ray.
CosC: Float: The angle between ray vector and non-perturbed normal.
Vector: The surface phong normal.
Vector: The surface phong and bump normal.
Dist: Float: Distance between SurfPnt and Ray.p, i.e. the ray length.
PolyHit: Int: The polygon index at the sampling point.
Vector: The rays position.
Vector: The rays direction vector.
Vector: The surface point.
RendLeft: Int: Left offset for the marquee render.
RendTop: Int: Top offset for the marquee render.
RendRight: Int: Right offset for the marquee render.
RendBottom: Int: Bottom offset for the marquee render.
ObjLeft: Int: Left object screen bounds.
ObjTop: Int: Top object screen bounds.
ObjRight: Int: Right object screen bounds.
ObjBottom: Int: Bottom object screen bounds.