Methods Signatures
Initialize a new |
Calls
ShaderData.Output() for the corresponding shader plugin. |
|
This function allows you to calculate bump mapping for a shader (and its children) with the same algorithm as Cinema 4D does.
|
|
Returns the bitmap of shaders of type Xbitmap, otherwise None. |
|
Calls ShaderData.GetRenderInfo() for the corresponding shader plugin.
|
|
Calls
ShaderData.InitRender() for the corresponding shader plugin. |
|
Frees all resources used by this shader, allocated by calling |
|
It checks if color management is disabled for shaders within bump, alpha, displacement or normal channels when linear workflow is enabled. |
|
Checks if this shader is similar to dst. |
|
Checks if the shader is supported by the GPU Renderer. |
Inheritance
Parent Class:
Child Class:
Methods Documentation
-
BaseShader.
__init__
(self, type)¶ Initialize a new
BaseShader
in memory.- Parameters
type (int) – The shader type : Shader Types.
- Return type
- Returns
The new shader.
-
BaseShader.
Sample
(self, cd)¶ - Calls
ShaderData.Output()
for the corresponding shader plugin.The channel color for the point cd.p is calculated.Note
This has to be done within a pair of
InitRender()
/FreeRender()
calls.- Parameters
cd (c4d.modules.render.ChannelData) – The channel data to use.
- Return type
- Returns
The calculated color.
-
BaseShader.
SampleBump
(self, cd, bumpflags)¶ - This function allows you to calculate bump mapping for a shader (and its children) with the same algorithm as Cinema 4D does.The function returns the delta vector that is added to the normal.The resulting normal is calculated by:
n_dst = not (n_src + SampleBump(SAMPLEBUMP_NONE)) # normalize result
where n_src is the original normal and n_dst is the bumped normal.
Note
This has to be done within a pair ofInitRender()
/FreeRender()
calls.Also theBaseVolumeData.ddu
andBaseVolumeData.ddv
vectors have to be initialized.- Parameters
cd (c4d.modules.render.ChannelData) – The channel data to use.
bumpflags (int) –
Flags:
SAMPLEBUMP_NONE
None.
SAMPLEBUMP_MIPFALLOFF
Additional bump change over distance is considered.
- Return type
- Returns
The delta normal.
-
BaseShader.
GetBitmap
(self)¶ Returns the bitmap of shaders of type Xbitmap, otherwise None.
Note
This has to be done within a pair of
InitRender()
/FreeRender()
calls.Here is an example.
material = doc.GetFirstMaterial() shader = material[c4d.MATERIAL_COLOR_SHADER] irs = render.InitRenderStruct() if shader.InitRender(irs) == c4d.INITRENDERRESULT_OK: bitmap = shader.GetBitmap() shader.FreeRender() if bitmap is not None: bitmaps.ShowBitmap(bitmap)
- Return type
- Returns
The bitmap.
Note
The returned bitmap must be accessed as read-only.
-
BaseShader.
GetRenderInfo
(self)¶ - Calls ShaderData.GetRenderInfo() for the corresponding shader plugin.This retrieves information about what the plugin requires from the raytracer and what it will return.
- Return type
int
- Returns
The return values are:
SHADERINFO_NONE
None.
SHADERINFO_TRANSFORM
Channel needs back-transformed data. (Required for
BaseVolumeData.back_p
.)SHADERINFO_BUMP_SUPPORT
Channel shader supports bump. This is strongly recommended for all shaders except simple 2D (UV) samplers.
SHADERINFO_ALPHA_SUPPORT
Channel shader supports alpha output.
SHADERINFO_REFLECTIONS
Channel shader computes reflections.
SHADERINFO_DUDVREQUIRED
Channel shader needs du/dv bump mapping data. See
BaseVolumeData.ddu
andBaseVolumeData.ddv
.SHADERINFO_DYNAMICSUBSHADERS
Channel shader has a dynamic list of sub-shaders in its description.
-
BaseShader.
InitRender
(self, is_)¶ - Calls
ShaderData.InitRender()
for the corresponding shader plugin.Note
Remember to callFreeRender()
afterwards.You aren’t allowed to callInitRender()
multiple times without callingFreeRender()
in between, even from multiple threads!- Parameters
is (c4d.modules.render.InitRenderStruct) – Information about the upcoming rendering.
- Return type
int
- Returns
Result of the initialisation:
INITRENDERRESULT_OK
Everything is OK, there was no error.
INITRENDERRESULT_OUTOFMEMORY
Not enough memory.
INITRENDERRESULT_ASSETMISSING
Assets (textures etc.) are missing.
INITRENDERRESULT_UNKNOWNERROR
Unknown error.
INITRENDERRESULT_USERBREAK
Changed in version R17.032: Was INITRENDERRESULT_THREADEDLOCK. Thread has been canceled.
-
BaseShader.
FreeRender
(self)¶ Frees all resources used by this shader, allocated by calling
InitRender()
.
-
BaseShader.
IsColorManagementOff
(self, doc)¶ It checks if color management is disabled for shaders within bump, alpha, displacement or normal channels when linear workflow is enabled.
- Parameters
doc (c4d.documents.BaseDocument) – The document containing the shader to check if linear workflow is disabled in it.
- Return type
bool
- Returns
True if color managment is disabled, otherwise False.
-
BaseShader.
Compare
(self, dst)¶ Checks if this shader is similar to dst.
- Parameters
dst (c4d.BaseShader) – The shader to compare to.
- Return type
bool
- Returns
True if the plugin shaders are the same, otherwise False.
-
BaseShader.
HasGPURendererSupport
(self)¶ Checks if the shader is supported by the GPU Renderer.
New in version R19.024.
- Return type
bool
- Returns
True if the shader is natively supported by the GPU Renderer, otherwise False.