ShaderData Class Reference

#include <c4d_shaderdata.h>

Inheritance diagram for ShaderData:

详细描述

A data class for creating shader (channel shader) plugins.
Shader plugins appear in the popup menu of the channels in the Material Manager.

使用 RegisterShaderPlugin() to register a scene hook plugin.

Here are some general comments on the shader API:

Draw

virtual Bool   Draw ( BaseShader *sh, BaseObject *op, BaseTag *tag, BaseDraw *bd, BaseDrawHelp *bh)

Init/Free Render

virtual INITRENDERRESULT   InitRender ( BaseShader *sh, const InitRenderStruct &irs)
virtual void  FreeRender ( BaseShader *sh)

输出

virtual 向量   输出 ( BaseShader *sh, ChannelData *cd)

杂项

virtual SHADERINFO   GetRenderInfo ( BaseShader *sh)
virtual BaseShader GetSubsurfaceShader ( BaseShader *sh, Float &bestmpl)

OpenGl Mode

virtual UInt32   GlMessageDummy ( BaseShader *sh, Int32 type, void *msgdata)
virtual Int32   InitGLImage ( BaseShader *sh, BaseDocument *doc, BaseThread *th, BaseBitmap *bmp, Bool alpha, Int32 doccolorspace, Bool linearworkflow)
virtual void  DestroyGLImage ( BaseShader *sh, BaseDocument *doc)
virtual void  InvalidateGLImage ( BaseShader *sh, BaseDocument *doc)
virtual Bool   GetGLImageSize ( BaseShader *sh, BaseDocument *doc, Int32 s, Bool noScale, Int32 &w, Int32 &h)

Additional Inherited Members

-  Public Member Functions inherited from NodeData
  NodeData ()
GeListNode Get (void) const
virtual Bool   消息 ( GeListNode *node, Int32 type, void *data)
virtual void  GetBubbleHelp ( GeListNode *node, maxon::String &str)
virtual BaseDocument GetDocument ( GeListNode *node)
virtual Int32   GetBranchInfo ( GeListNode *node, BranchInfo *info, Int32 max, GETBRANCHINFO flags)
virtual Bool   IsInstanceOf (const GeListNode *node, Int32 type) const
virtual Bool   IsDocumentRelated (const GeListNode *node, Bool &docrelated) const
virtual Bool   Init ( GeListNode *node)
virtual void  Free ( GeListNode *node)
virtual Bool   读取 ( GeListNode *node, HyperFile *hf, Int32 level)
virtual Bool   Write ( GeListNode *node, HyperFile *hf)
virtual Bool   CopyTo ( NodeData *dest, GeListNode *snode, GeListNode *dnode, COPYFLAGS flags, AliasTrans *trn)
virtual Bool   GetDDescription ( GeListNode *node, 描述 *description, DESCFLAGS_DESC &flags)
virtual Bool   GetDParameter ( GeListNode *node, const DescID &id, GeData &t_data, DESCFLAGS_GET &flags)
virtual Bool   SetDParameter ( GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_SET &flags)
virtual Bool   GetDEnabling ( GeListNode *node, const DescID &id, const GeData &t_data, DESCFLAGS_ENABLE flags, const BaseContainer *itemdesc)
virtual Bool   TranslateDescID ( GeListNode *node, const DescID &id, DescID &res_id, C4DAtom *&res_at)
-  Public Member Functions inherited from BaseData
  BaseData ()
virtual  ~BaseData (void)
void  Destructor (void)
-  Protected Attributes inherited from NodeData
GeListNode private_link

成员函数文档编制

◆  Draw()

virtual Bool Draw ( BaseShader sh ,
BaseObject op ,
BaseTag tag ,
BaseDraw bd ,
BaseDrawHelp bh  
)
virtual

Called to draw additional information for the shader in the editor's view.

参数
[in] sh The BaseShader connected with the ShaderData instance. Equal to static_cast < ShaderData *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed shader.
[in] op The active object. Cinema 4D owns the pointed object.
[in] tag The active tag. The caller owns the pointed tag.
[in] bd The editor's view. The caller owns the pointed view.
[in] bh The helper for the editor's view. The caller owns the pointed base draw helper.
返回
true if successful, otherwise false .

◆  InitRender()

virtual INITRENDERRESULT InitRender ( BaseShader sh ,
const InitRenderStruct irs  
)
virtual

Called to initialize resources for the render.

参数
[in] sh The BaseShader connected with the ShaderData instance. Equal to static_cast < ShaderData *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed shader.
[in] irs A struct with information about the upcoming rendering.
返回
The result of the initialization: INITRENDERRESULT

◆  FreeRender()

virtual void FreeRender ( BaseShader sh )
virtual

Called to free any resources allocated in InitRender .

参数
[in] sh The BaseShader connected with the ShaderData instance. Equal to static_cast < ShaderData *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed shader.

◆  Output()

virtual 向量 输出 ( BaseShader sh ,
ChannelData cd  
)
virtual

Called for each point of the visible surface of a shaded object to calculate and return the channel color for the point cd -> p .

注意
This function is called in a thread context. See the important information about threading.
参数
[in] sh The BaseShader connected with the ShaderData instance. Equal to static_cast < ShaderData *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed shader.
[in] cd The channel data to use and/or modify. The caller owns the pointed channel data.
返回
The calculated color.

◆  GetRenderInfo()

virtual SHADERINFO GetRenderInfo ( BaseShader sh )
virtual

Called to get information about what the shader plugin requires from the render and what it will return.

注意
This function is called in a thread context. See the important information about threading.
参数
[in] sh The BaseShader connected with the ShaderData instance. Equal to static_cast < ShaderData *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed shader.
返回
The shader info: SHADERINFO

◆  GetSubsurfaceShader()

virtual BaseShader * GetSubsurfaceShader ( BaseShader sh ,
Float bestmpl  
)
virtual

Called to return the best SSS sub-shader for the shader.

注意
If the shader uses sub-shaders it is crucial that it calls their GetSubsurfaceShader() method override so if any sub-shaders are SSS shaders they are used and initialized properly.
For example here is the implementation of GetSubsurfaceShader from SLA (which uses 2 sub-shaders: Texture and Distorter): BaseShader * CSLADistorter::GetSubsurfaceShader( BaseShader *sh, Float &bestmpl) { BaseShader *pBestShader = nullptr ; if (m_pTexture != nullptr ) { BaseShader *pShaderTexture = m_pTexture-> GetSubsurfaceShader (bestmpl); if (pShaderTexture != nullptr ) pBestShader = pShaderTexture; } if (m_pDistorter != nullptr ) { BaseShader *pShaderDistorter = m_pDistorter-> GetSubsurfaceShader (bestmpl); if (pShaderDistorter != nullptr ) pBestShader = pShaderDistorter; } return pBestShader; }
参数
[in] sh The BaseShader connected with the ShaderData instance. Equal to static_cast < ShaderData *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed shader.
[in] bestmpl The current best (smallest) Median Path Length found so far.
This value should never be changed by the code; it is auto adjusted only by the SSS shader and should be passed directly to the subshaders (see example code above).
返回
The best SSS shader found so far.

◆  GlMessageDummy()

virtual UInt32 GlMessageDummy ( BaseShader sh ,
Int32   type ,
void *  msgdata  
)
virtual

To ensure SDK compatibility Private .

◆  InitGLImage()

virtual Int32 InitGLImage ( BaseShader sh ,
BaseDocument doc ,
BaseThread th ,
BaseBitmap bmp ,
Bool   alpha ,
Int32   doccolorspace ,
Bool   linearworkflow  
)
virtual

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

◆  DestroyGLImage()

virtual void DestroyGLImage ( BaseShader sh ,
BaseDocument doc  
)
virtual

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

◆  InvalidateGLImage()

virtual void InvalidateGLImage ( BaseShader sh ,
BaseDocument doc  
)
virtual

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

◆  GetGLImageSize()

virtual Bool GetGLImageSize ( BaseShader sh ,
BaseDocument doc ,
Int32   s ,
Bool   noScale ,
Int32 w ,
Int32 h  
)
virtual

Called before the preview image for the shader is calculated.

参数
[in] sh The BaseShader connected with the ShaderData instance. Equal to static_cast < ShaderData *> Get() . Provided for speed and convenience. Cinema 4D owns the pointed shader.
[in] doc The host document of the shader. Cinema 4D owns the pointed document.
[in] s The exponent of the maximum texture size chosen in the 首选项 or the Material Editor tab. ( 2 ^ s = maximum preview size)
[in] noScale true if the user has selected the "No Scaling" option in the material.
[in] w Assign the width for the preview image.
[in] h Assign the height for the preview image.
返回
true to set the preview image size to the assigned ( w , h ).
BaseShader
定义: c4d_basechannel.h:35
Float
maxon::Float Float
定义: ge_sys_math.h:64
BaseShader::GetSubsurfaceShader
BaseShader * GetSubsurfaceShader(Float &bestmpl)
定义: c4d_basechannel.h:180