c4d.modules.render.VolumeData

Definition

class c4d.modules.render. VolumeData

Inheritance

Members

VolumeData. GetObjCount ( )

Returns the overall number of objects.

Return type: int
Returns: The total number of objects.
VolumeData. GetSkyCount ( )

Returns the number of skies.

Return type: int
Returns: The number of skies.
VolumeData. GetCurrentCPU ( )

Returns the current CPU on which the shader is executed.

Return type: int
Returns: The running CPU id.
VolumeData. GetCPUCount ( )

Returns the CPU count the renderer is utilizing.

Note

The value returned here can differ from the global GeGetCPUCount() as the renderer can utilize a different number of CPUs than are available.

Return type: int
Returns: The number of CPUs.
VolumeData. OutOfMemory ( )

Notify Cinema 4D that a (severe) out-of-memory condition occured. Cinema 4D will stop as soon as possible, but there is no guarantee when exactly. It is possible that your shader could still be called several times, so it has to be programmed to handle this and to be crash-proof.

VolumeData. SkipRenderProcess ( )

Skips the render process. (Useful for custom renderers.)

VolumeData. ScreenToCamera ( p )

Transform screen to camera coordinates. During QTVR rendering same point is returned.

Parameters: p ( c4d.Vector ) – The screen coordinate.
Return type: c4d.Vector
Returns: The camera coordinate.
VolumeData. CameraToScreen ( p )

Transform camera to screen coordinates. During QTVR rendering same point is returned.

Parameters: p ( c4d.Vector ) – The camera coordinate.
Return type: c4d.Vector
Returns: The screen coordinate.
VolumeData. StatusSetText ( str )

Set the status bar text during initialization of your shader or videopost effect. If an empty string is passed the status bar will be cleared.

Parameters: str ( str ) – The status text to display.
VolumeData. StatusSetBar ( percentage )

Set the progress bar during initialization of your shader or videopost effect.

Note

The value passed will only be displayed if it is bigger than the previous one. To reset the bar call StatusSetText (“”).

VolumeData. StatusSetSpinMode ( on )

Set the render progress bar spinning. Use this to indicate that your plugin is still processing even if the progress bar is not increasing.

Parameters: on ( bool ) – True to set the progress bar spinning, False to stop it.
VolumeData. GetLightCount ( )

Returns the overall number of lights.

Return type: int
Returns: The number of lights.
VolumeData. GetLight ( index )

Get the given lightsource.

Parameters: index ( int ) – The index of the light source to return.
Return type: ptr
Returns: The light source.
VolumeData. CalcArea ( light , nodiffuse , nospecular , specular_exponent , ray_vector , p , bumpn , orign , raybits )

If you code custom illumination models (e.g. different specular function) you can do this for standard lightsources easily. For area lights you’ll usually want to fall back to the default illumination model though, as otherwise you’d have to rebuild the sample code of area lights!

Parameters:
  • light ( ptr ) – The area light to calculate.
  • nodiffuse ( bool ) – True if the diffuse value should not be calculated, otherwise False .
  • nospecular ( bool ) – True if the specular value should not be calculated, otherwise False .
  • specular_exponent ( float ) – Specular exponent to use.
  • ray_vector ( c4d.Vector ) – Ray vector.
  • p ( c4d.Vector ) – The surface point.
  • bumpn ( c4d.Vector ) – The bump normal.
  • orign ( c4d.Vector ) – The original normal.
  • raybits ( int ) –

    The ray bits:

    RAYBIT_0 None.
    RAYBIT_REFLECTION Ray chain contains a reflection ray.
    RAYBIT_TRANSPARENCY Ray chain contains a transparency ray (note: refractions are not contained).
    RAYBIT_REFRACTION Ray chain contains a refraction ray.
    RAYBIT_CUSTOM Ray chain contains a custom ray.
    RAYBIT_CURR_REFLECTION Current ray is a reflection ray.
    RAYBIT_CURR_TRANSPARENCY Current ray is a transparency ray.
    RAYBIT_CURR_REFRACTION Current ray is a refraction ray.
    RAYBIT_CURR_CUSTOM Current ray is a custom ray.
    RAYBIT_VOLUMETRICLIGHT Current ray is used to calculate a volumetric light.
    RAYBIT_ALLOWVLMIX Custom mixing of visible light sources allowed for this ray; bit must be deleted by shader if used.
    RAYBIT_GI Current ray is a GI ray.
    RAYBIT_BLURRY Current ray is a blurry ray.
    RAYBIT_SSS Current ray is a subsurface ray.
    RAYBIT_AO Current ray is an AO ray.
Return type:

tuple( Vector , Vector )

Returns:

The diffuse and specular components.

VolumeData. CalcShadow ( l , p , bumpn , phongn , orign , rayv , transparency , hitid , raybits )

Compute a shadow.

Parameters:
  • l ( ptr ) – The illuminating light source.
  • p ( c4d.Vector ) – The point in global coordinates.
  • bumpn ( c4d.Vector ) – The bump normal.
  • phongn ( c4d.Vector ) – The phong normal.
  • orign ( c4d.Vector ) – The original normal.
  • rayv ( c4d.Vector ) – The ray vector.
  • transparency ( bool ) – True if transparencies/alphas for inbetween objects should be evaluated.
  • hitid ( ptr ) – The global RayHitID for the surface intersection (to avoid self shadowing), or RayHitID() if you are not on a surface or do not wish to make use of this avoidance.
  • raybits ( int ) –

    The ray bits:

    RAYBIT_0 None.
    RAYBIT_REFLECTION Ray chain contains a reflection ray.
    RAYBIT_TRANSPARENCY Ray chain contains a transparency ray (note: refractions are not contained).
    RAYBIT_REFRACTION Ray chain contains a refraction ray.
    RAYBIT_CUSTOM Ray chain contains a custom ray.
    RAYBIT_CURR_REFLECTION Current ray is a reflection ray.
    RAYBIT_CURR_TRANSPARENCY Current ray is a transparency ray.
    RAYBIT_CURR_REFRACTION Current ray is a refraction ray.
    RAYBIT_CURR_CUSTOM Current ray is a custom ray.
    RAYBIT_VOLUMETRICLIGHT Current ray is used to calculate a volumetric light.
    RAYBIT_ALLOWVLMIX Custom mixing of visible light sources allowed for this ray; bit must be deleted by shader if used.
    RAYBIT_GI Current ray is a GI ray.
    RAYBIT_BLURRY Current ray is a blurry ray.
    RAYBIT_SSS Current ray is a subsurface ray.
    RAYBIT_AO Current ray is an AO ray.
Return type:

c4d.Vector

Returns:

The returned shadow value. If there is no shadow, 0.0 will be returned. 1.0 is the maximum shadow value for each component.

VolumeData. IlluminanceAnyPoint ( p , flags , raybits )

Calculates the light intensity for a given point p . This routine can calculate the illumination for any point in space and is widely used for transparent volumetric shaders (gases, clouds etc.).

Parameters:
  • raybits ( int ) – The global coordinate point to calculate the illumination for.
  • flags ( int ) –

    The illuminate flags:

    ILLUMINATEFLAGS_0 None.
    ILLUMINATEFLAGS_SHADOW Full shadow calculations.
    ILLUMINATEFLAGS_NOENVIRONMENT Shadow calculations are enabled but no environment shading will be calculated.
    ILLUMINATEFLAGS_DISABLESHADOWMAP_CORRECTION Shadow maps evaluate the normal at a surface point, to avoid the problem of self-shadowing (that is otherwise inherent due to the way the algorithm works). If you sample a free point in space (where no surface is) this correction has to be disabled though, otherwise you get wrong results.
    ILLUMINATEFLAGS_DISABLESHADOWCASTERMP_CORRECTION Private.
  • raybits

    The ray bits:

    RAYBIT_0 None.
    RAYBIT_REFLECTION Ray chain contains a reflection ray.
    RAYBIT_TRANSPARENCY Ray chain contains a transparency ray (note: refractions are not contained).
    RAYBIT_REFRACTION Ray chain contains a refraction ray.
    RAYBIT_CUSTOM Ray chain contains a custom ray.
    RAYBIT_CURR_REFLECTION Current ray is a reflection ray.
    RAYBIT_CURR_TRANSPARENCY Current ray is a transparency ray.
    RAYBIT_CURR_REFRACTION Current ray is a refraction ray.
    RAYBIT_CURR_CUSTOM Current ray is a custom ray.
    RAYBIT_VOLUMETRICLIGHT Current ray is used to calculate a volumetric light.
    RAYBIT_ALLOWVLMIX Custom mixing of visible light sources allowed for this ray; bit must be deleted by shader if used.
    RAYBIT_GI Current ray is a GI ray.
    RAYBIT_BLURRY Current ray is a blurry ray.
    RAYBIT_SSS Current ray is a subsurface ray.
    RAYBIT_AO Current ray is an AO ray.
Return type:

c4d.Vector

Returns:

The returned color.

Note

The returned color components can exceed values of 1.0!

VolumeData. IlluminateSurfacePoint ( )

This function is used for custom illumination models. You can calculate the intensity of incoming light for a given light and surface point.

Parameters:
  • rl ( ptr ) – The illuminating light.
  • p ( c4d.Vector ) – The surface point.
  • bumpn ( c4d.Vector ) – The bump normal.
  • phongn ( c4d.Vector ) – The phong normal.
  • orign ( c4d.Vector ) – The original normal.
  • ray_vector ( c4d.Vector ) – The ray vector.
  • flags ( int ) –

    The illuminate flags:

    ILLUMINATEFLAGS_0 None.
    ILLUMINATEFLAGS_SHADOW Full shadow calculations.
    ILLUMINATEFLAGS_NOENVIRONMENT Shadow calculations are enabled but no environment shading will be calculated.
    ILLUMINATEFLAGS_DISABLESHADOWMAP_CORRECTION Shadow maps evaluate the normal at a surface point, to avoid the problem of self-shadowing (that is otherwise inherent due to the way the algorithm works). If you sample a free point in space (where no surface is) this correction has to be disabled though, otherwise you get wrong results.
    ILLUMINATEFLAGS_DISABLESHADOWCASTERMP_CORRECTION Private.
  • hitid ( ptr ) – The global RayHitID for the surface intersection (to avoid self shadowing), or RayHitID() if you are not on a surface or do not wish to make use of this avoidance.
  • raybits ( int ) –

    The ray bits:

    RAYBIT_0 None.
    RAYBIT_REFLECTION Ray chain contains a reflection ray.
    RAYBIT_TRANSPARENCY Ray chain contains a transparency ray (note: refractions are not contained).
    RAYBIT_REFRACTION Ray chain contains a refraction ray.
    RAYBIT_CUSTOM Ray chain contains a custom ray.
    RAYBIT_CURR_REFLECTION Current ray is a reflection ray.
    RAYBIT_CURR_TRANSPARENCY Current ray is a transparency ray.
    RAYBIT_CURR_REFRACTION Current ray is a refraction ray.
    RAYBIT_CURR_CUSTOM Current ray is a custom ray.
    RAYBIT_VOLUMETRICLIGHT Current ray is used to calculate a volumetric light.
    RAYBIT_ALLOWVLMIX Custom mixing of visible light sources allowed for this ray; bit must be deleted by shader if used.
    RAYBIT_GI Current ray is a GI ray.
    RAYBIT_BLURRY Current ray is a blurry ray.
    RAYBIT_SSS Current ray is a subsurface ray.
    RAYBIT_AO Current ray is an AO ray.
Return type:

c4d.Vector

Returns:

True if the light illuminates the objects surface point.

VolumeData. CalcVisibleLight ( ray , maxdist )

Returns the mixed color of all visible lights on a given ray span.

Parameters:
  • ray ( c4d.Vector ) – The ray span.
  • maxdist ( float ) – The maximum distance for the lights.
Return type:

tuple( Vector , Vector )

Returns:

The mixed color of the lights and a value indicating if some light sources have a dust effect (!= 0 in this case).

VolumeData. GetRS ( hitid , p )

Calculates the R/S parameters for a point.

If you want to calculate weighted data (e.g. based upon a color for each polygon point) you can do this the following way:

r, s = GetRS(hitid, p)
result = [color a] * (1.0-r-s) + [color d]*r + [color c]*s
							
Parameters:
  • hitid ( ptr ) – The global RayHitID.
  • p ( c4d.Vector ) – The point.
Return type:

tuple(bool, float, float)

Returns:


If the polygon is a quadrangle then the first value holds True for the second part (a-c-d) of the quadrangle or False for the first part (a-b-c). If the polygon is a triangle then this is the same as the first part of a quadrangle (a-b-c). The 2nd and 3rd values are the R and S parameters for point p .

VolumeData. GetWeights ( hitid , p )

Returns barycentric coordinates for a point on the surface of a polygon. Cinema 4D uses enhanced interpolation routines for quadrangles, so you’ll get a higher quality using it instead of considering a quadrangle as two triangles. The routine works for any type of polygon, including triangles and non-coplanar quadrangles.

The function returns a tuple with the weight factors for the global polygon with ID hitid at p . Works similar to GetRS() , but has a higher quality.

Parameters:
  • hitid ( ptr ) – The global RayHitID.
  • p ( c4d.Vector ) – Point on polygon.
Return type:

tuple(float, float, float, float)

Returns:

A tuple with the respective weight factors for points A, B, C and D.

VolumeData. GetSmoothedNormal ( hitid , p )

Returns the phong normal for a point.

Parameters:
  • hitid ( ptr ) –

    The global RayHitID.

    Note

    Must be a valid RayHitID.

  • p ( c4d.Vector ) –

    The point for the phong normal.

    Note

    The point must be within the surface boundaries of the polygon.

Return type:

c4d.Vector

Returns:

The phong normal.

VolumeData. GetXY ( )

Returns the current X/Y pixel position in render resolution. Render resolution is the screen resolution multiplied by ‘scale’.

Return type: tuple(int, int, int)
Returns: The X, Y pixel positions and render scale.

Note

X/scale and Y/scale is the screen position.

VolumeData. SetXY ( x , y )

Sets the current X/Y pixel position in render resolution. Render resolution is the screen resolution multiplied by ‘scale’.

Note

X/scale and Y/scale is the screen position.

Note

Some Shaders use the screen pixel position. Plugins (like the Baker for instance) can change this position without having to render an image.

Parameters:
  • x ( float ) – The X pixel position to set.
  • y ( float ) – The Y pixel position to set.
VolumeData. CalcFgBg ( foreground , x , y , subx , suby )

Calculates the foreground or background color and alpha at ( x , y ).

Parameters:
  • foreground ( bool ) – True to calculate the foreground color. Otherwise the background color is calculated.
  • x ( int ) – X coordinate.
  • y ( int ) – Y coordinate.
  • subx ( int ) – Sub pixel X position. (0 <= subx <= 15)
  • suby ( int ) – Sub pixel Y position. (0 <= suby <= 15)
Return type:

tuple( Vector , float)

Returns:

The background/foreground color and alpha.

VolumeData. GetLightFalloff ( )

Calculate the light falloff function (light intensity for a distance).

Parameters:
  • falloff ( int ) –

    The light type:

    RT_FALLOFF_NONE No light falloff.
    RT_FALLOFF_LINEAR Linear light falloff.
    RT_FALLOFF_INVERSE_CLAMPED Clamped inverse light falloff.
    RT_FALLOFF_SQUARE_CLAMPED Clamped square light falloff.
    RT_FALLOFF_INVERSE Inverse light falloff.
    RT_FALLOFF_SQUARE Square light falloff.
    RT_FALLOFF_STEP Step light falloff.
  • inner ( float ) – The inner falloff value.
  • outer ( float ) – The outer falloff value.
  • dist ( float ) – The distance for the intensity to be calculated at.
Return type:

float

Returns:

The light falloff.

VolumeData. GetRay ( x , y , ray )

Generate the view ray for a position.

This function does not set Ray.pp [0..2], Ray.vv [0..2], Ray.transport and Ray.ior .

Parameters:
  • x ( float ) – The X position for the view ray in screen space coordinates.
  • y ( float ) – The Y position for the view ray in screen space coordinates.
  • ray ( c4d.modules.render.Ray ) – The view ray.
VolumeData. GetVideoPost ( nth )

Returns the n-th video post effect for this render process.

Return type: c4d.BaseList2D
Returns: The video post, or None if the index is too large.
VolumeData. FindVideoPost ( id )

Returns a video post effect for this render process by ID.

Parameters: id ( int ) – The video post effect ID.
Return type: c4d.BaseList2D
Returns: The found video post, or None if it doesn’t exist.
VolumeData. Init ( from )

Initializes this VolumeData object with the data from the from object. Only the most essential parts are copied over, including the render instance.

Parameters: from ( c4d.modules.render.VolumeData ) – Source object.
VolumeData. CopyTo ( dst )

Copy this to another VolumeData .

Parameters: dst ( c4d.modules.render.VolumeData ) – The destination VolumeData.

Table Of Contents