FieldLayerData is the base class for custom field layers (FieldLayer)

A new FieldLayerData based class is registered with RegisterFieldLayerPlugin().


In a FieldLayerData based class the following functions can be implemented:


A FieldLayerData based class has to be registered with RegisterFieldLayerPlugin(). The flags are:

Modifier layers are registered with FIELDLAYER_DIRECT.


// This example shows the implementation of a custom field layer.
// ------------------------------------------------------------------------------
// This example field layer shifts the hue of the sample color.
// ------------------------------------------------------------------------------
class HueShiftFieldLayer : public FieldLayerData
INSTANCEOF(HueShiftFieldLayer, FieldLayerData)
// ------------------------------------------------------------------------------
// Allocation of a new instance
// @return New HueShiftFieldLayer instance or nullptr.
// ------------------------------------------------------------------------------
static NodeData* Alloc()
iferr (NodeData * const result = NewObj(HueShiftFieldLayer))
return nullptr;
return result;
// store data for faster access during sampling
const BaseContainer& layerBc = layer.GetDataInstanceRef();
GeData data;
if (layerBc.GetParameter(FIELDLAYER_HUESHIFT_OFFSET, data) == false)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
_offset = data.GetFloat();
return maxon::OK;
virtual maxon::Result<void> Sample(const FieldLayer& layer, const FieldInput& inputs, FieldOutputBlock& outputs, const FieldInfo& info) const
// handle each input position
for (Int i = inputs._blockCount - 1; i >= 0; --i)
// get the color hue
const Vector color = outputs._color[i];
Vector hsv = RGBToHSV(color);
Float hue = hsv.x;
// hue shift
hue = FMod(hue + _offset, 1.0);
// store new color
hsv.x = hue;
outputs._color[i] = HSVToRGB(hsv);
return maxon::OK;
virtual void FreeSampling(FieldLayer& layer, const FieldInfo& info, FieldShared& shared)
// free internal data after sampling
virtual Bool IsEqual(const FieldLayer& layer, const FieldLayerData& comp) const
return true;
Float _offset = 0.0_f;
Py_ssize_t i
Definition: abstract.h:645
#define INSTANCEOF(X, Y)
Definition: c4d_baselist.h:38
Vector HSVToRGB(const Vector &col)
Vector RGBToHSV(const Vector &col)
Definition: c4d_basecontainer.h:47
Bool GetParameter(const DescID &id, GeData &t_data) const
Definition: c4d_basecontainer.h:628
const BaseContainer & GetDataInstanceRef() const
Definition: c4d_baselist.h:2344
Definition: c4d_fieldplugin.h:109
virtual Bool IsEqual(const FieldLayer &layer, const FieldLayerData &comp) const
Definition: c4d_fieldplugin.h:171
virtual maxon::Result< void > Sample(const FieldLayer &layer, const FieldInput &inputs, FieldOutputBlock &outputs, const FieldInfo &info) const =0
virtual maxon::Result< void > InitSampling(FieldLayer &layer, const FieldInfo &info, FieldShared &shared)
Definition: c4d_fieldplugin.h:126
virtual void FreeSampling(FieldLayer &layer, const FieldInfo &info, FieldShared &shared)
Definition: c4d_fieldplugin.h:162
Definition: c4d_fielddata.h:1148
Definition: c4d_gedata.h:83
Float GetFloat(void) const
Definition: c4d_gedata.h:439
Definition: c4d_nodedata.h:39
PyObject PyObject * result
Definition: abstract.h:43
maxon::Bool Bool
Definition: ge_sys_math.h:55
maxon::Float Float
Definition: ge_sys_math.h:66
maxon::Int Int
Definition: ge_sys_math.h:64
return OK
Definition: apibase.h:2667
Definition: memoryallocationbase.h:67
#define iferr(...)
Definition: errorbase.h:388
#define DebugStop(...)
Definition: debugdiagnostics.h:231
Float32 FMod(Float32 v1, Float32 v2)
Definition: apibasemath.h:183
#define NewObj(T,...)
Definition: newobj.h:108
_Py_clock_info_t * info
Definition: pytime.h:197
Thread local information for this field sample invocation.
Definition: c4d_fielddata.h:901
Definition: c4d_fielddata.h:534
Int _blockCount
The number of elements in the array to be processed (for this processing block, this should be treate...
Definition: c4d_fielddata.h:705
Definition: c4d_fielddata.h:339
maxon::Block< Vector > _color
The alpha value for color and direction at this point in space, only available when color or directio...
Definition: c4d_fielddata.h:459
Definition: c4d_fielddata.h:475
T x
Definition: vec.h:39
// This example registeres the given FieldLayerData plugin.
const Bool registerFieldLayerSuccess = RegisterFieldLayerPlugin(fieldLayerPluginID,
"Hue Shift Layer"_s,
"Changes the color hue."_s,
"Hue Shift Layer"_s,
if (registerFieldLayerSuccess == false)
return maxon::UnknownError(MAXON_SOURCE_LOCATION);
Bool RegisterFieldLayerPlugin(Int32 id, const maxon::String &name, const maxon::String &help, const maxon::String &pickInstruction, Int32 info, DataAllocator *g, const maxon::String &description, BaseBitmap *icon, Int32 disklevel, FieldLayerAcceptDragFunction *dragFunc=nullptr)
The FieldLayer will receive FieldOutputBlock data premultiplied by alpha values.
Definition: ge_prepass.h:972
The FieldLayer doesn't calculate rotational velocities.
Definition: ge_prepass.h:973
The FieldLayer will have access to directly manipulate the 'result' data in ModifyValues rather than ...
Definition: ge_prepass.h:965
The FieldLayer doesn't calculate values.
Definition: ge_prepass.h:967
The FieldLayer doesn't calculate directions.
Definition: ge_prepass.h:969

Further Reading