Python Sketch and Toon Material¶
Introduction¶
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.
See also
The important Threading Information.
Methods¶
-
main
() Override - Mandatory method, used to define the parameter value. It’s called for each sample of the
c4d.plugins.ShaderData
.
Variables¶
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):
op:
BaseObject
: The current object being sampled. It must be noted that it’s theBaseObject
stored in theVolumeData
, 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.
ScnPnt:
Vector
: Screen position currently sampled.wPnt:
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.
LineStart:
Vector
: Screen coordinates at the line starting point.LineEnd:
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.
LineNormal:
Vector
: The normal of the line currently draw, defined by (A->B)%(0,0,1).EdgeNormal:
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.
Color:
Vector
: Current color.Note
Python 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:
RAYBIT_NONE
None.
RAYBIT_REFLECTION
Ray chain contains a reflection ray.
RAYBIT_TRANSPARENCY
Ray chain contains a transparency ray (refractions are not contained).
RAYBIT_REFRACTION
Ray chain contains a refraction ray.
RAYBIT_CUSTOM
Ray chain contains a custom ray.
RAYBIT_CURR_REFLECTION
Current ray is a reflection ray.
RAYBIT_CURR_TRANSPARENCY
Current ray is a transparency ray.
RAYBIT_CURR_REFRACTION
Current ray is a refraction ray.
RAYBIT_CURR_CUSTOM
Current ray is a custom ray.
RAYBIT_VOLUMETRICLIGHT
Current ray is used to calculate a volumetric light.
RAYBIT_ALLOWVLMIX
Custom mixing of visible light sources allowed for the ray; bit must be deleted by shader if used.
RAYBIT_GI
Current ray is a Global Illumination ray.
RAYBIT_BLURRY
Current ray is a blurry ray.
RAYBIT_SSS
Current ray is a subsurface scattering ray.
RAYBIT_AO
Current ray is an Ambient Occlusion ray.
RAYBIT_COMPOSITING
Current ray is a compositing ray.
CosC: Float: The angle between ray vector and non-perturbed normal.
Normal:
Vector
: The surface phong normal.BumpNormal:
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.
RayPos:
Vector
: The rays position.RayDirn:
Vector
: The rays direction vector.SurfPnt:
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.