c4d.BaseShader

New in version R13.016.

Represents a shader in the shader tree of a channel.

Inheritance

Members

BaseShader.__init__(type)

Initialize a new BaseShader in memory.

Parameters: type (int) – The shader type : Shader Types.
Return type: 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 (ChannelData) – The channel data to use.
Return type: 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 (ChannelData) – The channel data to use.
  • bumpflags (int) –

    Flags:

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

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: 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.
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 (InitRenderStruct) –

New in version R13.029.

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_THREADEDLOCK Thread lock.
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 (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 (BaseShader) – The shader to compare to.
Return type: bool
Returns: True if the plugin shaders are the same, otherwise False.

Table Of Contents