c4d.BaseShader

Represents a shader in the shader tree of a channel.

Definition

class c4d. BaseShader

Inheritance

Members

BaseShader. __init__ ( type )

Initialize a new BaseShader in memory.

Parameters: type ( int ) – The shader type : Shader Types .
Return type: c4d.BaseShader
Returns: The new shader.
BaseShader. Sample ( 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: c4d.Vector
Returns: The calculated color.
BaseShader. SampleBump ( 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 = !(n_src + SampleBump(SAMPLEBUMP_0)) // 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 of InitRender() / FreeRender() calls. Also the BaseVolumeData.ddu and BaseVolumeData.ddv vectors have to be initialized. Use GetDUDV() or set them manually.

Parameters:
  • cd ( c4d.modules.render.ChannelData ) – The channel data to use.
  • bumpflags ( int ) –

    Flags:

    SAMPLEBUMP_0 None.
    SAMPLEBUMP_MIPFALLOFF Additional bump change over distance is considered.
Return type:

c4d.Vector

Returns:

The delta normal.

BaseShader. GetBitmap ( )

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: c4d.bitmaps.BaseBitmap
Returns: The bitmap.

Note

The returned bitmap must be accessed as read-only.

BaseShader. GetRenderInfo ( )

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_0 None.
SHADERINFO_TRANSFORM Channel needs back-transformed data. (Required for back_p.)
SHADERINFO_BUMP_SUPPORT Channel shader supports the new bump system. This is strongly recommended for all shaders but 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.
SHADERINFO_DYNAMICSUBSHADERS Channel shader has a dynamic list of subshaders in its description.
BaseShader. InitRender ( is )

Calls ShaderData.InitRender() for the corresponding shader plugin. You have to do this before you can use the Sample() , SampleBump() or GetBitmap() functions.

Note

Remember to call FreeRender() afterwards. You aren’t allowed to call InitRender() multiple times without calling FreeRender() 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 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 ( )

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

BaseShader. IsColorManagementOff ( doc )

It checks if color managment 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 ( 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 ( )

New in version R19.024.

Checks if the shader is supported by the GPU Renderer.

Return type: bool
Returns: True if the shader is natively supported by the GPU Renderer, otherwise False .

Table Of Contents