BaseShader Class Reference

#include <c4d_basechannel.h>

Inheritance diagram for BaseShader:

Detailed Description

Represents a shader in the shader tree of a channel. Call BaseChannel::GetShader() to retrieve an instance.

Note
Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Private Member Functions

 BaseShader ()
 
 ~BaseShader ()
 

Alloc/Free

static BaseShaderAlloc (Int32 type)
 
static void Free (BaseShader *&ps)
 

Navigation

BaseShaderGetNext (void)
 
BaseShaderGetPred (void)
 
BaseShaderGetUp (void)
 
BaseShaderGetDown (void)
 
BaseShaderGetDownLast (void)
 

Init/Free Render

INITRENDERRESULT InitRender (const InitRenderStruct &is)
 
void FreeRender (void)
 

Sample

Vector Sample (ChannelData *cd)
 
Vector SampleBump (ChannelData *cd, SAMPLEBUMP bumpflags)
 

Miscellaneous

BaseBitmapGetBitmap (void)
 
SHADERINFO GetRenderInfo (void)
 
Bool Compare (BaseShader *dst)
 
Bool IsColorManagementOff (BaseDocument *doc)
 
BaseShaderGetSubsurfaceShader (Float &bestmpl)
 
Bool HasGPURendererSupport () const
 
Bool BakeShaderIntoBaseBitmap (BaseBitmap &outBmp, BaseDocument &doc, BaseThread *parentThread, Bool doAlpha, Int32 colorSpace, Bool linearworkflow, Bool useHDR, Int xmin, Int xmax, Int ymin, Int ymax)
 

Extended OpenGL mode

void DestroyGLImage (BaseDocument *doc)
 
void InvalidateGLImage (BaseDocument *doc)
 
void ProcessEditorPreviewImage (const ProcessEditorPreviewImageFn &fn)
 

Additional Inherited Members

- Public Member Functions inherited from BaseList2D
void SetBit (Int32 mask)
 
Bool GetBit (Int32 mask) const
 
void DelBit (Int32 mask)
 
void ToggleBit (Int32 mask)
 
Int32 GetAllBits () const
 
void SetAllBits (Int32 bits)
 
void SetBitEx (Int32 mask, Int32 flags)
 
const CharGetViewportRenderId (VIEWPORT_RENDER_ID typeId) const
 
BaseList2DGetNext ()
 
BaseList2DGetPred ()
 
BaseContainer GetData ()
 
void SetData (const BaseContainer &bc, Bool add=true)
 
const BaseContainerGetDataInstance () const
 
BaseContainerGetDataInstance ()
 
const BaseContainerGetDataInstanceRef () const
 
BaseContainerGetDataInstanceRef ()
 
String GetName () const
 
void SetName (const maxon::String &name)
 
String GetBubbleHelp ()
 
Bool TransferGoal (BaseList2D *dst, Bool undolink)
 
Bool TransferMarker (BaseList2D *dst) const
 
Bool Scale (Float scale)
 
Bool Edit ()
 
void GetIcon (IconData *dat)
 
GeListHeadGetNLARoot ()
 
BaseList2DAnimationLayerRemap (BaseObject **layer=nullptr)
 
String GetTypeName ()
 
BaseList2DGetMain () const
 
void InsertTrackSorted (CTrack *track)
 
Bool AddEventNotification (BaseList2D *bl, NOTIFY_EVENT eventid, NOTIFY_EVENT_FLAG flags, const BaseContainer *data)
 
Bool RemoveEventNotification (BaseDocument *doc, BaseList2D *bl, NOTIFY_EVENT eventid)
 
Bool FindEventNotification (BaseDocument *doc, BaseList2D *bl, NOTIFY_EVENT eventid)
 
Bool SetDescIDState (const DescID &id, DESCIDSTATE descidstate)
 
DESCIDSTATE GetDescIDState (const DescID &id, Bool tolerant) const
 
GeListHeadGetOverrideRoot ()
 
BaseOverrideGetFirstOverride ()
 
GeListHeadGetShaderRepositoryRoot ()
 
GeListHeadGetHiddenShaderRoot ()
 
maxon::NimbusForwardRef GetNimbusRef (const maxon::Id &spaceId) const
 
maxon::Result< maxon::NimbusForwardRefPrivateGetOrCreateNimbusRef (const maxon::Id &spaceId)
 
void RemoveNimbusRef (const maxon::Id &spaceId)
 
maxon::Result< maxon::HashMap< maxon::Id, maxon::NimbusForwardRef > > GetAllNimbusRefs () const
 
Bool IsNodeBased () const
 
void GetMarkerStampEx (UInt32 *l1, UInt32 *l2)
 
const GeMarkerGetMarker () const
 
void SetMarker (const GeMarker &m)
 
Bool AddUniqueID (Int32 appid, const Char *const mem, Int bytes)
 
Bool FindUniqueID (Int32 appid, const Char *&mem, Int &bytes) const
 
Int32 GetUniqueIDCount () const
 
Bool GetUniqueIDIndex (Int32 idx, Int32 &id, const Char *&mem, Int &bytes) const
 
Bool SetAnimatedParameter (CTrack *track, const DescID &id, const GeData &t_data1, const GeData &t_data2, Float mix, DESCFLAGS_SET flags)
 
Bool GetAnimatedParameter (const DescID &id, GeData &t_data1, GeData &t_data2, Float &mix, DESCFLAGS_GET flags)
 
BaseShaderGetFirstShader () const
 
void InsertShader (BaseShader *shader, BaseShader *pred=nullptr)
 
void ClearKeyframeSelection ()
 
Bool FindKeyframeSelection (const DescID &id)
 
Bool SetKeyframeSelection (const DescID &id, Bool selection)
 
Bool KeyframeSelectionContent ()
 
LayerObjectGetLayerObject (BaseDocument *doc)
 
Bool SetLayerObject (LayerObject *layer)
 
const LayerDataGetLayerData (BaseDocument *doc, Bool rawdata=false)
 
Bool SetLayerData (BaseDocument *doc, const LayerData &data)
 
GeListHeadGetCTrackRoot ()
 
CTrackGetFirstCTrack ()
 
CTrackFindCTrack (const DescID &id)
 
- Public Member Functions inherited from GeListNode
GeListNodeGetNext ()
 
GeListNodeGetPred ()
 
GeListNodeGetDown ()
 
GeListNodeGetUp ()
 
GeListNodeGetDownLast ()
 
void InsertBefore (GeListNode *bl)
 
void InsertAfter (GeListNode *bl)
 
void InsertUnder (GeListNode *bl)
 
void InsertUnderLast (GeListNode *bl)
 
void Remove ()
 
GeListHeadGetListHead ()
 
Int32 GetNodeID (Int32 index=0) const
 
template<typename CAST >
const CAST * GetNodeData (Int32 index=0) const
 
template<typename CAST >
CAST * GetNodeData (Int32 index=0)
 
void SetCustomData (GeListNode *node)
 
GeListNodeGetCustomData ()
 
BaseDocumentGetDocument ()
 
Int32 GetBranchInfo (BranchInfo *info, Int32 max, GETBRANCHINFO flags)
 
Bool IsDocumentRelated ()
 
Int32 GetInfo () const
 
Bool GetNBit (NBIT bit) const
 
UInt32 GetNBitMask (Int32 index) const
 
Bool ChangeNBit (NBIT bit, NBITCONTROL bitmode)
 
- Public Member Functions inherited from C4DAtom
Int32 GetType () const
 
Int32 GetRealType () const
 
Int32 GetDiskType () const
 
Bool IsInstanceOf (Int32 id) const
 
Int32 GetClassification () const
 
Bool Message (Int32 type, void *data=nullptr)
 
Bool MultiMessage (MULTIMSG_ROUTE flags, Int32 type, void *data)
 
C4DAtomGetClone (COPYFLAGS flags, AliasTrans *trn)
 
Bool CopyTo (C4DAtom *dst, COPYFLAGS flags, AliasTrans *trn)
 
Bool Read (HyperFile *hf, Int32 id, Int32 level)
 
Bool Write (HyperFile *hf)
 
Bool ReadObject (HyperFile *hf, Bool readheader)
 
Bool WriteObject (HyperFile *hf)
 
Bool GetDescription (Description *description, DESCFLAGS_DESC flags)
 
Bool GetParameter (const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
 
Bool SetParameter (const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
 
DynamicDescriptionGetDynamicDescription ()
 
Bool GetEnabling (const DescID &id, const GeData &t_data, DESCFLAGS_ENABLE flags, const BaseContainer *itemdesc)
 
Bool TranslateDescID (const DescID &id, DescID &res_id, C4DAtom *&res_at)
 
UInt32 GetDirty (DIRTYFLAGS flags) const
 
void SetDirty (DIRTYFLAGS flags)
 
UInt32 GetHDirty (HDIRTYFLAGS mask) const
 
void SetHDirty (HDIRTYFLAGS mask)
 
- Static Public Member Functions inherited from BaseList2D
static BaseList2DAlloc (Int32 type)
 
static void Free (BaseList2D *&bl)
 
- Static Public Attributes inherited from BaseList2D
static const Int32 SETBIT_FLAG_NODIRTY
 
static const Int32 SETBIT_FLAG_REMOVE
 

Constructor & Destructor Documentation

◆ BaseShader()

BaseShader ( )
private

◆ ~BaseShader()

~BaseShader ( )
private

Member Function Documentation

◆ Alloc()

static BaseShader* Alloc ( Int32  type)
static

Allocates a shader. Destroy the allocated shader with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in]typeThe shader type: Shader Types
Returns
The allocated shader, or nullptr if the allocation failed.

◆ Free()

static void Free ( BaseShader *&  ps)
static

Destructs shaders allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in]psThe shader to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ GetNext()

BaseShader* GetNext ( void  )

Gets the next shader in the list. Convenience version of GeListNode::GetNext() returning a BaseShader*.

Returns
The next shader, or nullptr if there is none. Cinema 4D owns the pointed shader.

◆ GetPred()

BaseShader* GetPred ( void  )

Gets the previous shader in the list. Convenience version of GeListNode::GetPred() returning a BaseShader*.

Returns
The previous shader, or nullptr if there is none. Cinema 4D owns the pointed shader.

◆ GetUp()

BaseShader* GetUp ( void  )

Gets the parent shader of the list node. Convenience version of GeListNode::GetUp() returning a BaseShader*.

Returns
The parent shader, or nullptr if there is none. Cinema 4D owns the pointed shader.

◆ GetDown()

BaseShader* GetDown ( void  )

Gets the first child shader of the list node. Convenience version of GeListNode::GetDown() returning a BaseShader*.

Returns
The first child shader, or nullptr if there is none. Cinema 4D owns the pointed shader.

◆ GetDownLast()

BaseShader* GetDownLast ( void  )

Gets the last child shader of the list node. Convenience version of GeListNode::GetDownLast() returning a BaseShader*.

Returns
The last child shader, or nullptr if there is none. Cinema 4D owns the pointed shader.

◆ InitRender()

INITRENDERRESULT InitRender ( const InitRenderStruct is)

Calls ShaderData::InitRender() for the corresponding shader plugin.

Warning
It is mandatory to call this method before any Sample(), SampleBump() or GetBitmap() functions.
Parameters
[in]isA struct with information about the upcoming render. The caller owns the pointed struct.
Returns
The result of the initialization: INITRENDERRESULT

◆ FreeRender()

void FreeRender ( void  )

Frees all resources used by this shader that were allocated by calling InitRender().

◆ Sample()

Vector Sample ( ChannelData cd)

Calls ShaderData::Output() for the corresponding shader plugin. The channel color for the point cd->p is calculated.

Note
This method has to be called within a pair of /@ref FreeRender() calls.
Parameters
[in]cdA pointer to a channel data struct to use for the sampling. The caller owns the pointed ChannelData.
Returns
The calculated color.

◆ SampleBump()

Vector SampleBump ( ChannelData cd,
SAMPLEBUMP  bumpflags 
)

This function allows you to calculate bump mapping for a shader (and its children) with the same algorithm as Cinema 4D does.
The method returns the delta vector that is added to the normal. The resulting normal is calculated by

n_dst = !(n_src + SampleBump(SAMPLEBUMP _0)); // Normalize result
Vector SampleBump(ChannelData *cd, SAMPLEBUMP bumpflags)
Definition: c4d_basechannel.h:138
SAMPLEBUMP
Definition: ge_prepass.h:5019

where n_src is the original normal and n_dst is the bumped normal.

Note
This method has to be called within a pair of /@ref FreeRender() calls.
Also, the BaseVolumeData::ddu and BaseVolumeData::ddv vectors have to be initialized. Use VolumeData::GetDUDV() or set them manually.
Parameters
[in]cdA pointer to a channel data struct to use for the sampling the bump. The caller owns the pointed ChannelData.
[in]bumpflagsThe flags: SAMPLEBUMP
Returns
The delta normal.

◆ GetBitmap()

BaseBitmap* GetBitmap ( void  )

Gets the bitmap for shaders of type Xbitmap.

Note
This method has to be called within a pair of /@ref FreeRender() calls.
Returns
The bitmap of shaders of type Xbitmap, otherwise nullptr.
Warning
The return bitmap must be accessed as read-only.

◆ GetRenderInfo()

SHADERINFO GetRenderInfo ( void  )

Calls ShaderData::GetRenderInfo() for the corresponding shader plugin. This retrieves information about what the plugin requires from the raytracer and what it will return.

Returns
The return values are: SHADERINFO

◆ Compare()

Bool Compare ( BaseShader dst)

Checks if *this is similar to *dst.

Parameters
[in]dstThe shader to compare with. The caller owns the pointed shader.
Returns
true if the shaders are the same, otherwise false.

◆ IsColorManagementOff()

Bool IsColorManagementOff ( BaseDocument doc)

Checks if color management is disabled for shaders within reflectance, bump, alpha, displacement or normal channels when linear workflow is enabled.

Parameters
[in]docThe document to check color management. The caller owns the pointed document.
Returns
true if color management is disabled, otherwise false.

◆ GetSubsurfaceShader()

BaseShader* GetSubsurfaceShader ( Float bestmpl)

Gets the best SSS shader.

Note
If the shader uses subshaders it is crucial to call their GetSubsurfaceShader() method override so if any subshaders are in fact SSS shaders they are used and initialized properly.
See also
ShaderData::GetSubsurfaceShader()
Parameters
[in]bestmplThe current best (smallest) Median Path Length.
Returns
The best SSS shader.

◆ HasGPURendererSupport()

Bool HasGPURendererSupport ( ) const

Checks if the shader is supported by the GPU Renderer.

Since
R19
Returns
true if the shader is natively supported by the GPU Renderer, otherwise false.

◆ BakeShaderIntoBaseBitmap()

Bool BakeShaderIntoBaseBitmap ( BaseBitmap outBmp,
BaseDocument doc,
BaseThread parentThread,
Bool  doAlpha,
Int32  colorSpace,
Bool  linearworkflow,
Bool  useHDR,
Int  xmin,
Int  xmax,
Int  ymin,
Int  ymax 
)

Bakes the shader into a BaseBitmap

Since
R21
Parameters
[out]outBmpThe BaseBitmap that is baked into.
[in]docThe document.
[in]parentThreadThe parent thread used to check for interruption The caller owns the pointed BaseThread.
[in]doAlphaPass true if alpha should be considered.
[in]colorSpaceThe documents colorspace.
[in]linearworkflowPass true when LWF is enabled.
[in]useHDRPass true when HDR should be considered.
[in]xminThe min in x.
[in]xmaxThe max in x.
[in]yminThe min in y.
[in]ymaxThe max in y.
Returns
true if baking succeeded, otherwise false.

◆ DestroyGLImage()

void DestroyGLImage ( BaseDocument doc)

Extended OpenGL mode. This mode is not documented. See c4d_gl.h for definitions.

◆ InvalidateGLImage()

void InvalidateGLImage ( BaseDocument doc)

Extended OpenGL mode. This mode is not documented. See c4d_gl.h for definitions.

◆ ProcessEditorPreviewImage()

void ProcessEditorPreviewImage ( const ProcessEditorPreviewImageFn fn)

Extended OpenGL mode. This mode is not documented. See c4d_gl.h for definitions.