VolumeData Struct Reference

#include <c4d_tools.h>

Inheritance diagram for VolumeData:

Public Member Functions

void CalcArea (const RayLight *light, Bool nodiffuse, Bool nospecular, Float specular_exponent, const Vector64 &ray_vector, const Vector64 &p, const Vector64 &bumpn, const Vector64 &orign, RAYBIT raybits, Bool ignoreLightColor, Vector *diffuse, Vector *specular)
 
Vector CalcShadow (const RayLight *l, const Vector64 &p, const Vector64 &bumpn, const Vector64 &phongn, const Vector64 &orign, const Vector64 &rayv, Bool transparency, const RayHitID &hitid, RAYBIT raybits)
 
Bool IlluminateSurfacePoint (const RayLight *rl, Vector *col, Vector64 *light_vector, const Vector64 &p, const Vector64 &bumpn, const Vector64 &phongn, const Vector64 &orign, const Vector64 &ray_vector, ILLUMINATEFLAGS flags, const RayHitID &hitid, RAYBIT raybits, Bool cosine_cutoff)
 
Bool IlluminateAnyPoint (const RayLight *rl, Vector *col, Vector64 *light_vector, const Vector64 &p, ILLUMINATEFLAGS flags, RAYBIT raybits)
 
void IlluminanceSurfacePoint (IlluminanceSurfacePointData *f, Vector *diffuse, Vector *specular)
 
Vector IlluminanceAnyPoint (const Vector64 &p, ILLUMINATEFLAGS flags, RAYBIT raybits)
 
void IlluminanceSimple (Vector *diffuse, Vector *specular, Float exponent, IlluminationModel *model, void *data)
 
Int32 GetCurrentCPU () const
 
Int32 GetCPUCount () const
 
Int32 Obj_to_Num (const RayObject *obj) const
 
const RayObjectGetObj (Int32 index) const
 
Int32 GetObjCount () const
 
void GetUVW (const RayObject *op, Int32 uvwind, Int32 local_id, PolyVector *uvw) const
 
void GetNormals (const RayObject *op, Int32 local_id, PolyVector *norm) const
 
TexDataGetTexData (const RayObject *op, Int32 index) const
 
Vector64 GetNormal (const RayObject *op, Int32 polygon, Bool second) const
 
Int32 GetRayPolyState (const RayObject *op, Int32 local_id) const
 
Int32GetUniqueID (const RayObject *op, Int32 &length) const
 
Vector64 GetSmoothedNormal (const RayHitID &hitid, const Vector64 &p) const
 
Bool GetRS (const RayHitID &hitid, const Vector64 &p, Float *r, Float *s) const
 
void GetWeights (const RayHitID &hitid, const Vector64 &p, RayPolyWeight *wgt) const
 
const RayLightGetLight (Int32 index) const
 
Int32 GetLightCount () const
 
Int32 Light_to_Num (const RayLight *light) const
 
const void * GetRayData (Int32 i) const
 
const RayCameraGetRayCamera () const
 
const RayParameterGetRayParameter () const
 
const RayEnvironmentGetRayEnvironment () const
 
const RayObjectGetRaySky () const
 
const RayObjectGetRayForeground () const
 
const RayObjectGetRayBackground () const
 
void GetRay (Float x, Float y, Ray *ray) const
 
Vector64 ScreenToCamera (const Vector64 &p) const
 
Vector64 CameraToScreen (const Vector64 &p) const
 
Vector CalcHardShadow (const Vector64 &p1, const Vector64 &p2, CALCHARDSHADOW flags, const RayHitID &last_hit, Int32 recursion_id=0, void *recursion_data=nullptr)
 
Vector GetPointUVW (const TexData *tdp, const RayHitID &hit, const Vector64 &p) const
 
Bool ProjectPoint (const TexData *tdp, const RayHitID &hit, const Vector64 &p, const Vector64 &n, Vector *uv) const
 
void StatusSetText (const maxon::String &str) const
 
void StatusSetBar (Float percentage) const
 
void StatusSetSpinMode (Bool on) const
 
Vector CalcVisibleLight (const Ray *ray, Float maxdist, Vector *trans) const
 
void GetXY (Int32 *x, Int32 *y, Int32 *scale) const
 
void SetXY (Float x, Float y)
 
MinMax GetSceneBoundaries () const
 
void CopyTo (VolumeData *dst) const
 
void Init (VolumeData *from)
 
void OutOfMemory ()
 
Bool CalcFgBg (Bool foreground, Int32 x, Int32 y, Int32 subx, Int32 suby, Vector *color, Float *alpha) const
 
Float GetLightFalloff (Int32 falloff, Float inner, Float outer, Float dist) const
 
Bool TestBreak ()
 
BaseVideoPostGetVideoPost (Int32 nth) const
 
BaseVideoPostFindVideoPost (Int32 id) const
 
const VPFragment ** GetFragments (Int32 x, Int32 y, Int32 cnt, VPGETFRAGMENTS flags) const
 
Bool AddLensGlow (const LensGlowStruct *lgs, Vector *lgs_pos, Int32 lgs_cnt, Float intensity, Bool linear_workflow) const
 
Bool SampleLensFX (const VPBuffer *rgba, const VPBuffer *fx, BaseThread *bt) const
 
Int32 TranslateObjIndex (Int32 index, Bool old_to_new) const
 
Bool TranslatePolygon (const RayObject *op, Int32 local_index, Vector *previous_points) const
 
Vector TraceColor (Ray *ray, Float maxdist, const RayHitID &last_hit, SurfaceIntersection *si)
 
Vector TraceColorDirect (Ray *ray, Float maxdist, Int32 raydepth, RAYBIT raybits, const RayHitID &last_hit, Vector64 *oldray, SurfaceIntersection *si)
 
Bool TraceGeometry (const Ray *ray, Float maxdist, const RayHitID &last_hit, SurfaceIntersection *si) const
 
Bool TraceGeometryEnhanced (const Ray *ray, Float maxdist, const RayHitID &last_hit, Int32 raydepth, RAYBIT raybits, Vector64 *oldray, SurfaceIntersection *si) const
 
void GetSurfaceData (SurfaceData *cd, Bool calc_illum, Bool calc_shadow, Bool calc_refl, Bool calc_trans, Ray *ray, const SurfaceIntersection &si)
 
Vector CentralDisplacePointUV (const RayObject *op, Int32 local_id, Int32 uu, Int32 vv) const
 
Vector CentralDisplacePointFromUVPoint (const RayObject *op, Int32 local_id, Bool bFirst, Float l1, Float l2, const Vector &uv, const UVWStruct &uvw) const
 
Vector CalcDisplacementNormals (Float par_u, Float par_v, Int32 u0, Int32 v0, Int32 u1, Int32 v1, Int32 u2, Int32 v2, const Vector &a, const Vector &b, const Vector &c, const RayObject *op, Int32 polynum) const
 
Vector CentralDisplaceUVGetNormal (const RayObject *op, Int32 local_id, Int32 uu, Int32 vv) const
 
Vector CentralDisplaceGetSurfaceNormalFromUVPoint (const RayObject *op, Int32 local_id, Bool bFirst, Float par_u, Float par_v, const Vector &uv, const UVWStruct &uvw) const
 
Vector CentralDisplaceGetShadingNormalFromUVPoint (const RayObject *op, Int32 local_id, Bool bFirst, Float par_u, Float par_v, const Vector &uv, const UVWStruct &uvw) const
 
Bool CentralDisplacePointUVGetBarycentric (const RayObject *op, Int32 &local_id, Int32 &uu, Int32 &vv, RayPolyWeight &bary, Bool &displaceQuad) const
 
Bool GetDisplaceInfo (const RayObject *op, DisplaceInfo &info) const
 
Int32 GetDisplaceNeighbor (const RayObject *op, Int32 local_id, Int32 side) const
 
void CorrectLocalID (const RayObject *op, Int32 &local_id) const
 
Vector CalcBackTransformPoint () const
 
Matrix64 CalcMotionObjectMatrixInv (const RayObject *op) const
 
void SkipRenderProcess ()
 
const RenderGetRenderInstance () const
 
void GetDUDV (const TexData *tex, const Vector64 &p, const Vector64 &phongn, const Vector64 &orign, const RayHitID &hit, Bool forceuvw, Vector *ddu, Vector *ddv, Bool usetangents, const RayPolyWeight *weight) const
 
void GetDUDVFromUVPoint (const RayObject *op, const TexData *tex, Float par_u, Float par_v, const Vector64 &uv, const Vector64 &p, const Vector64 &phongn, const Vector64 &orign, const UVWStruct &uvw, RayHitID &hit, Bool forceuvw, Vector *ddu, Vector *ddv, Bool usetangents)
 
void InitSurfacePointProperties (TexData *td)
 
Bool AttachVolumeDataFake (BaseObject *camera, const BaseContainer &renderdata, Int32 fakeCurrentThreadIdx, Int32 fakeThreadCount)
 
Bool HasVolumeDataFake () const
 
Bool SaveShaderStack (RayShaderStackElement *&stack, Int32 &stack_cnt)
 
Bool RestoreShaderStack (RayShaderStackElement *stack, Int32 stack_cnt)
 
const RayObjectGetRaySky (Int32 index) const
 
Int32 GetRaySkyCount () const
 
RaySamplerGetRaySampler (void *guid, Int32 depth)
 
Float GetRayWeight () const
 
Float CalcAmbientOcclusion (SurfaceIntersection *si, RaySampler *sampler, Float minlength, Float maxlength, Float index, Bool self, Bool trans, Float weight, Bool reverse)
 
Vector CalcSubsurfaceScattering (Vector scattering, Vector absorption, Vector diffuse, Float ior)
 
Int32 GetStreamCount () const
 
void GetStreamRay (Int32 stream, Float x, Float y, Ray *ray) const
 
Bool CalcIndirectIllumination (RayHemisphere *hs, Float weight)
 
Bool CalcIndirectPDF (const Vector &point, const Vector &normal, const Vector &ray_in, const Vector &ray_out, Float &pdf_qmc, Float &pdf_area, Float &pdf_portal, Float &pdf_sky)
 
Bool CalcIndirectPath (VolumeData *sd, const Vector &dir, void *source, void *target)
 
RayRadianceObjectCreateRadianceMaps ()
 
RayRadianceObjectGetRadianceMaps ()
 
Vector CalcRadianceValue (Ray *ray, const SurfaceIntersection &si)
 
Vector CalcRadiancePoly (RayRadianceObject *obj, SurfaceIntersection *si, Int32 poly, Int32 u, Int32 v, Bool back)
 
Bool IsPhysicalRender () const
 
Float GetPhysicalCameraIntensity () const
 
void SetPhysicalRayTime (Float time)
 
const RayMotionObjectGetMotionObject (RayObject *op)
 
const RayMotionLightGetMotionLight (RayLight *light)
 
const RayMotionCameraGetMotionCamera (Int32 stream)
 
Bool GetTile (Int32 &xMin, Int32 &yMin, Int32 &xMax, Int32 &yMax, Int32 &renderThreadIndex) const
 

Private Member Functions

 VolumeData ()
 
 ~VolumeData ()
 

Alloc/Free

static VolumeDataAlloc ()
 
static void Free (VolumeData *&vd)
 

Additional Inherited Members

- Public Attributes inherited from BaseVolumeData
Int32 version
 
Int32 fps
 
Vector ambient
 
Float time
 
Vector col
 
Vector trans
 
Vector refl
 
Float alpha
 
Raytray
 
Rayrray
 
Vector64 p
 
Vector64 bumpn
 
Rayray
 
Vector64 orign
 
Vector64 n
 
Vector64 dispn
 
Float64 dist
 
Float64 cosc
 
Vector uvw
 
Vector delta
 
RayHitID lhit
 
const TexDatatex
 
Vector ddu
 
Vector ddv
 
Int32 raydepth
 
Int32 calc_trans
 
Int32 calc_refl
 
Bool calc_shadow
 
Int32 calc_illum
 
Int32 calc_mip
 
Vector pp [3]
 
Vector nn [3]
 
RAYBIT raybits
 
const RayLightxlight
 
const RayObjectop
 
Int32 recursion_id
 
void * recursion_data
 
Multipassmultipass
 
Vector back_p
 
Vector back_delta
 
Float global_mip
 
Int32 sid
 
Float par_u
 
Float par_v
 
SurfaceIntersectionintersection
 
Float mb_offset
 
Vector comp_color
 
Vector comp_specular
 
Vector comp_luminance
 
TexEntry * rtex [4]
 
Int32 rtex_count
 
Int32 elementIndex
 
const RayPolyWeightdisplacementWeight
 
- Protected Member Functions inherited from BaseVolumeData
 BaseVolumeData ()
 

Constructor & Destructor Documentation

◆ VolumeData()

VolumeData ( )
private

◆ ~VolumeData()

~VolumeData ( )
private

Member Function Documentation

◆ Alloc()

static VolumeData* Alloc ( )
static

Allocates a volume data. Destroy the allocated volume data with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Warning
Should normally not be used.
Returns
The allocated volume data, or nullptr if the allocation failed.

◆ Free()

static void Free ( VolumeData *&  vd)
static

Destructs volume data allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]vdThe volume data to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ CalcArea()

void CalcArea ( const RayLight light,
Bool  nodiffuse,
Bool  nospecular,
Float  specular_exponent,
const Vector64 ray_vector,
const Vector64 p,
const Vector64 bumpn,
const Vector64 orign,
RAYBIT  raybits,
Bool  ignoreLightColor,
Vector diffuse,
Vector specular 
)

If you code custom illumination models (e.g. different specular function) you can do this for standard light sources easily.
For area lights you will usually want to fall back to the default illumination model though, as otherwise you would have to rebuild the sample code of area lights!
Here is an example how to sample area lights using this method:

for (i=sd->GetLightCount()-1; i>=0; i--)
{
lp = sd->GetLight(i);
if (!sd->IlluminateSurfacePoint(lp,&col,&lv,sd->p,sd->bumpn,sd->n,sd->orign,SV(sd->ray->v),sd->calc_shadow,sd->lhit,sd->raybits,true))
continue;
if (lp->ambient)
{
*diffuse += col;
continue;
}
nodif = nospec = false;
if (lp->lr.object)
CalcRestrictionInc(&lp->lr,sd->op,nodif,nospec);
if (lp->type==RT_LT_AREA)
{
Vector dif,spc;
sd->CalcArea(lp,nodif,nospec,exponent,SV(sd->ray->v),sd->p,sd->bumpn,sd->orign,sd->raybits,&dif,&spc);
*diffuse += dif^col;
*specular += spc^col;
}
else
{
cosa=lv*sd->bumpn;
if (!(lp->nodiffuse || nodif) && sd->cosc*cosa>=0.0)
{
if (lp->contrast!=0.0)
*diffuse += Pow(Abs(cosa),Exp(-lp->contrast))*col;
else
*diffuse += Abs(cosa)*col;
}
if (calc_specular && !(lp->nospecular || nospec))
{
cosb=SV(sd->ray->v) * (lv - sd->bumpn*(2.0 * cosa));
if (cosb<=0.0) continue;
*specular += Pow(cosb,exponent)*col;
}
}
}
diffuse.ClampMin(); // there can be subtractive light sources
specular.ClampMin();
}
@ Pow
Definition: Python-ast.h:24
Py_ssize_t i
Definition: abstract.h:645
void CalcRestrictionInc(const ObjectRestriction *lr, const RayObject *op, Bool &nodif, Bool &nospec)
#define RT_LT_AREA
Area light.
Definition: c4d_raytrace.h:97
Float32 Abs(Float32 val)
Definition: apibasemath.h:195
Float32 Exp(Float32 val)
Definition: apibasemath.h:156
Vector col
[READ WRITE] Set the calculated color within MaterialData::CalcSurface() and MaterialData::CalcVolume...
Definition: c4d_shader.h:1094
void ClampMin(const Vec3 &other=Vec3())
Set the minimum of each component.
Definition: vec.h:426
Parameters
[in]lightThe area light to calculate.
[in]nodiffusetrue if the diffuse value should not be calculated, otherwise false.
[in]nospeculartrue if the specular value should not be calculated, otherwise false.
[in]specular_exponentThe specular exponent to use.
[in]ray_vectorThe ray vector.
[in]pThe surface point.
[in]bumpnThe bump normal.
[in]orignThe original normal.
[in]raybitsThe ray bits: RAYBIT
[in]ignoreLightColorWhether to factor the light color into the result
[out]diffuseAssigned the diffuse component.
[out]specularAssigned the specular component.

◆ CalcShadow()

Vector CalcShadow ( const RayLight l,
const Vector64 p,
const Vector64 bumpn,
const Vector64 phongn,
const Vector64 orign,
const Vector64 rayv,
Bool  transparency,
const RayHitID hitid,
RAYBIT  raybits 
)

Computes a shadow.

Parameters
[in]lThe illuminating light source. The caller owns the pointed light.
[in]pThe point in global coordinates.
[in]bumpnThe bump normal.
[in]phongnThe phong normal.
[in]orignThe original normal.
[in]rayvThe ray vector.
[in]transparencytrue if transparencies/alphas for in between objects should be evaluated.
[in]hitidThe global RayHitID structure for the surface intersection (to avoid self shadowing).
Pass RayHitID() if not on a surface or to not use of this avoidance.
[in]raybitsThe ray bits: RAYBIT
Returns
The shadow value. If there is no shadow, 0.0 will be returned. 1.0 is the maximum shadow value for each component.

◆ IlluminateSurfacePoint()

Bool IlluminateSurfacePoint ( const RayLight rl,
Vector col,
Vector64 light_vector,
const Vector64 p,
const Vector64 bumpn,
const Vector64 phongn,
const Vector64 orign,
const Vector64 ray_vector,
ILLUMINATEFLAGS  flags,
const RayHitID hitid,
RAYBIT  raybits,
Bool  cosine_cutoff 
)

Calculates the intensity of incoming light for a given light and surface point. Used for custom illumination models.

Parameters
[in]rlThe illuminating light. The caller owns the pointed light.
[out]colAssigned the result of the calculation.
[out]light_vectorAssigned the light to point vector. For area and tube lights the vector will use the center of the light source.
[in]pThe surface point.
[in]bumpnThe bump normal.
[in]phongnThe phong normal.
[in]orignThe original normal.
[in]ray_vectorThe ray vector.
[in]flagsThe illuminate flags: ILLUMINATEFLAGS
[in]hitidThe global RayHitID structure for the surface intersection (to avoid self shadowing). Can be set to RayHitID() if you do not have the current RayHitID.
[in]raybitsThe ray bits: RAYBIT
[in]cosine_cutofftrue if cosine cut-off should be used, otherwise false.
Returns
true if the light illuminates the objects surface point, otherwise false.

◆ IlluminateAnyPoint()

Bool IlluminateAnyPoint ( const RayLight rl,
Vector col,
Vector64 light_vector,
const Vector64 p,
ILLUMINATEFLAGS  flags,
RAYBIT  raybits 
)

Calculates the intensity of incoming light for a given light and arbitrary point. Used for custom illumination models.

Parameters
[in]rlThe illuminating light. The caller owns the pointed light.
[out]colAssigned the result of the calculation.
[out]light_vectorAssigned the light to point vector. For area and tube lights the vector will use the center of the light source.
[in]pThe surface point.
[in]flagsThe illuminate flags: ILLUMINATEFLAGS
[in]raybitsThe ray bits: RAYBIT
Returns
true if the light illuminates the point, otherwise false.

◆ IlluminanceSurfacePoint()

void IlluminanceSurfacePoint ( IlluminanceSurfacePointData f,
Vector diffuse,
Vector specular 
)

Calculates the diffuse and specular components for a given point.
This function can calculate the illumination for any point in space and is widely used for volumetric shaders that display a surface structure (e.g. Cinema 4D's terrain shader).

Parameters
[in]fThe surface point data used for the call. The caller owns the pointed data.
[in]diffuseAssigned the diffuse component.
[in]specularAssigned the specular component.

◆ IlluminanceAnyPoint()

Vector IlluminanceAnyPoint ( const Vector64 p,
ILLUMINATEFLAGS  flags,
RAYBIT  raybits 
)

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

Parameters
[in]pThe global coordinate point to calculate the illumination for.
[in]flagsThe illuminate flags: ILLUMINATEFLAGS
[in]raybitsThe ray bits: RAYBIT
Returns
The calculated color. Note its components can exceed values of 1.0!

◆ IlluminanceSimple()

void IlluminanceSimple ( Vector diffuse,
Vector specular,
Float  exponent,
IlluminationModel model,
void *  data 
)

Calculates the diffuse and specular components according to the current VolumeData and a given specular exponent, or optionally using a custom illumination model.

Parameters
[out]diffuseAssigned the diffuse component.
[out]specularAssigned the specular component.
[in]exponentThe exponent to calculate the specular component.
If exponent==0.0 then no specular is calculated, otherwise a specular is calculated with exponent as exponent value for the phong formula.
[in]modelA custom illumination model, or nullptr to use the default illumination model. The caller owns the pointed illumination model.
[in]dataThe private data passed to the custom illumination function. The caller owns the pointed data.

◆ GetCurrentCPU()

Int32 GetCurrentCPU ( ) const

Retrieves the current thread index on which the shader is executed.

Returns
The running thread index, which is guaranteed to be >= 0 and smaller than GetCPUCount().

◆ GetCPUCount()

Int32 GetCPUCount ( ) const

Retrieves the thread count the renderer is utilizing. The value returned here can differ from or exceed the global GeGetCurrentThreadCount() as the renderer can utilize any different number of threads.

Returns
The number of utilized threads (>=1).

◆ Obj_to_Num()

Int32 Obj_to_Num ( const RayObject obj) const

Retrieves an object's number. Opposite of GetObj().

Parameters
[in]objThe object to get the number for. The caller owns the pointed object.
Returns
The object's number.

◆ GetObj()

const RayObject* GetObj ( Int32  index) const

Retrieves the object at index.

Parameters
[in]indexThe object index: 0<= index < GetObjCount()
Returns
The object. The volume data owns the pointed object.

◆ GetObjCount()

Int32 GetObjCount ( ) const

Retrieves the overall number of objects.

Returns
The total number of objects.

◆ GetUVW()

void GetUVW ( const RayObject op,
Int32  uvwind,
Int32  local_id,
PolyVector uvw 
) const

Retrieves the UVW coordinates information for a polygon.

Note
If the polygon consists of three points (triangle) the fourth UVW coordinate 'd' may be uninitialized.
Parameters
[in]opThe object. The caller owns the pointed object.
[in]uvwindThe UVW number (there may be several UVW coordinate sets): 1 <= uvwind < op->uvwcnt
[in]local_idThe local polygon ID: 0 <= local_id < op->vcnt
[out]uvwAssigned the UVW coordinates. The caller owns the pointed coordinates.

◆ GetNormals()

void GetNormals ( const RayObject op,
Int32  local_id,
PolyVector norm 
) const

Retrieves the phong normals for a polygon.

Note
If the polygon consists of three points (triangle) the fourth normal d may be uninitialized.
Parameters
[in]opThe object. The caller owns the pointed object.
[in]local_idThe local polygon ID: 0 <= local_id < op->vcnt
[out]normAssigned the phong normals. The caller owns the pointed coordinates.

◆ GetTexData()

TexData* GetTexData ( const RayObject op,
Int32  index 
) const

Retrieves the texture at index of an object.

Parameters
[in]opThe object. The caller owns the pointed object.
[in]indexThe index of the texture: 0 <= index < op->texcnt
Returns
The texture. The volume data owns the pointed texture.

◆ GetNormal()

Vector64 GetNormal ( const RayObject op,
Int32  polygon,
Bool  second 
) const

Retrieves the face normal for a polygon.

Parameters
[in]opThe object. The caller owns the pointed object.
[in]polygonThe local polygon ID: 0 <= local_id < op->vcnt
[in]secondtrue if this is the second part of a quadrangle (A-C-D), otherwise false.
Returns
The face normal.

◆ GetRayPolyState()

Int32 GetRayPolyState ( const RayObject op,
Int32  local_id 
) const

Gets the polygon state of the polygon with ID local_id of object op.

Parameters
[in]opThe object. The caller owns the pointed object.
[in]local_idThe local polygon ID: 0 <= local_id < op->vcnt
Returns
The polygon state: RayTracePolystate

◆ GetUniqueID()

Int32* GetUniqueID ( const RayObject op,
Int32 length 
) const

Retrieves the unique object IP address.

Note
The ID is somewhat constant across frames so it is handy to identify objects in animation.
Parameters
[in]opThe object. The caller owns the pointed object.
[in]lengthAssigned the length.
Returns
The pointer to the address of the unique ID. Cinema 4D owns the pointed ID.

◆ GetSmoothedNormal()

Vector64 GetSmoothedNormal ( const RayHitID hitid,
const Vector64 p 
) const

Retrieves the phong normal for a point.

Parameters
[in]hitidThe global RayHitID.
[in]pThe point for the phong normal. Must be within the surface boundaries of the polygon.
Returns
The phong normal.

◆ GetRS()

Bool GetRS ( const RayHitID hitid,
const Vector64 p,
Float r,
Float s 
) const

Calculates the R/S parameters for a point.
To calculate the weighted data (e.g. based upon a color for each polygon point) do it the following way:

Float r,s;
Bool snd = sd->GetRS(hitid,p,&r,&s);
if (snd)
result = [color a] * (1.0-r-s) + [color d]*r + [color c]*s
else
result = [color a] * (1.0-r-s) + [color b]*r + [color c]*s
PyObject PyObject const char const char char ** s
Definition: bytesobject.h:60
PyObject PyObject * result
Definition: abstract.h:43
Py_UNICODE c
Definition: unicodeobject.h:1200
maxon::Bool Bool
Definition: ge_sys_math.h:51
maxon::Float Float
Definition: ge_sys_math.h:62
Vector64 p
[READ WRITE] The surface point, this can only be modified by MaterialData::Displace().
Definition: c4d_shader.h:1100
Parameters
[in]hitidThe global RayHitID.
[in]pThe point.
[out]rAssigned the R parameter.
[out]sAssigned the S parameter.
Returns
true if the polygon is a quadrangle 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).

◆ GetWeights()

void GetWeights ( const RayHitID hitid,
const Vector64 p,
RayPolyWeight wgt 
) const

Calculates the barycentric coordinates for a point on the surface of a polygon.
Cinema 4D uses enhanced interpolation routines for quadrangles, so you will 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 fills the wgt structure with the weight factors for the global polygon with ID hitid at point p on polygon.
Works similar to GetRS(), but has a higher quality. Here is an example:

cd->vd->GetWeights(cd->vd->lhit, vSurfIntersect, &weight);
Float rWeightA, rWeightB, rWeightC, rWeightD;
Int32 lIndexA = pRayObject->vadr[lPolygonIndex].a;
Int32 lIndexB = pRayObject->vadr[lPolygonIndex].b;
Int32 lIndexC = pRayObject->vadr[lPolygonIndex].c;
Int32 lIndexD = pRayObject->vadr[lPolygonIndex].d;
rWeightA = prVertexMapData[lIndexA];
rWeightB = prVertexMapData[lIndexB];
rWeightC = prVertexMapData[lIndexC];
rWeightD = prVertexMapData[lIndexD];
rFunctionSample = weight.wa * rWeightA + weight.wb * rWeightB + weight.wc * rWeightC + weight.wd * rWeightD;
maxon::Int32 Int32
Definition: ge_sys_math.h:56
Parameters
[in]hitidThe global RayHitID.
[in]pThe point on polygon.
[out]wgtFilled with the weight factors. The caller owns the pointed weights.

◆ GetLight()

const RayLight* GetLight ( Int32  index) const

Get the light source at index.

Parameters
[in]indexThe index of the light source to return: 0 <= index < GetLightCount()
Returns
The light source. The volume data owns the pointed light.

◆ GetLightCount()

Int32 GetLightCount ( ) const

Gets the overall number of lights.

Returns
The number of lights.

◆ Light_to_Num()

Int32 Light_to_Num ( const RayLight light) const

Gets the number for a light. Opposite of GetLight().

Parameters
[in]lightThe light to get the number for. The caller owns the pointed light.
Returns
The light's number.

◆ GetRayData()

const void* GetRayData ( Int32  i) const

Retrieves one of the raytracer structures, these are also available as direct called, for example GetRaySky().

Parameters
[in]iThe requested structure type: RAY
Returns
The requested raytracer structure. The volume data owns the pointed structure.

◆ GetRayCamera()

const RayCamera* GetRayCamera ( ) const

Retrieves the raytracer camera.

Returns
The camera. The volume data owns the pointed camera.

◆ GetRayParameter()

const RayParameter* GetRayParameter ( ) const

Retrieves the raytracer parameters (settings).

Note
The raytracer uses a completely different representation than the normal scene (BaseDocument).
It has new, efficient data structures where you do not need to check a lot of things. As you do not have a BaseDocument (it is still there for special purposes, but normally you will not have to deal with it in the raytracer) all relevant data structures can be obtained through VolumeData.
Returns
The raytracer parameters. Guaranteed to be valid (not nullptr). The volume data owns the pointed parameters.

◆ GetRayEnvironment()

const RayEnvironment* GetRayEnvironment ( ) const

Retrieves the raytracer environment parameters.

Returns
The raytracer environment. Guaranteed to be valid (not nullptr). The volume data owns the pointed parameters.

◆ GetRaySky() [1/2]

const RayObject* GetRaySky ( ) const

Retrieves the sky object.

Returns
The sky object, or nullptr if none is there. The volume data owns the pointed sky object.

◆ GetRayForeground()

const RayObject* GetRayForeground ( ) const

Retrieves the foreground object.

Returns
The foreground object, or nullptr if none is there. The volume data owns the pointed foreground object.

◆ GetRayBackground()

const RayObject* GetRayBackground ( ) const

Retrieves the background object.

Returns
The background object, or nullptr if none is there. The volume data owns the pointed background object.

◆ GetRay()

void GetRay ( Float  x,
Float  y,
Ray ray 
) const

Generates the view ray for a position.
Does not set Ray::pp[0..2], Ray::vv[0..2], Ray::transport and Ray::ior. Those have to be filled in if used subsequently by TraceColor(), TraceColorDirect() or GetSurfaceData().
It is not necessary for TraceGeometry() though (as there are no MIP mapping calculations).

ray.ior=1.0;
ray.pp[0]=ray.pp[1]=ray.pp[2]=SV(ray.p);
ray.vv[0]=ray.vv[1]=ray.vv[2]=SV(ray.v);
Ray * ray
[READ ONLY] The current eye ray. Always valid, not nullptr.
Definition: c4d_shader.h:1103
Vector transport
[READ ONLY] The current ray intensity (for special shadow calculation). A ray starts with intensity 1...
Definition: c4d_shader.h:831
Vector64 p
[READ WRITE] The rays position.
Definition: c4d_shader.h:817
Vector vv[3]
Definition: c4d_shader.h:825
Vector64 v
[READ WRITE] The rays direction vector.
Definition: c4d_shader.h:818
Vector pp[3]
Definition: c4d_shader.h:820
Float ior
[READ WRITE] The current index of refraction.
Definition: c4d_shader.h:819
Parameters
[in]xThe X position for the view ray in screen space coordinates.
[in]yThe Y position for the view ray in screen space coordinates.
[out]rayAssigned the generated view ray. The caller owns the pointed ray.

◆ ScreenToCamera()

Vector64 ScreenToCamera ( const Vector64 p) const

Transforms screen to camera coordinates.

Note
During QTVR rendering same point is returned.
Parameters
[in]pThe screen coordinate.
Returns
The camera coordinate.

◆ CameraToScreen()

Vector64 CameraToScreen ( const Vector64 p) const

Transforms camera to screen coordinates.

Note
During QTVR rendering same point is returned.
Parameters
[in]pThe camera coordinate.
Returns
The screen coordinate.

◆ CalcHardShadow()

Vector CalcHardShadow ( const Vector64 p1,
const Vector64 p2,
CALCHARDSHADOW  flags,
const RayHitID last_hit,
Int32  recursion_id = 0,
void *  recursion_data = nullptr 
)

Calculates a hard shadow from point p1 to p2.

Note
Set the CALCHARDSHADOW::TRANSPARENCY flag if transparencies/alphas for in between objects shall be evaluated.
An additional last_hit can be passed to avoid self-shadowing (if starting on a surface). To not make use of it just pass 0.
Parameters
[in]p1The start point for the hard shadow.
[in]p2The end point for the hard shadow.
[in]flagsThe flags: CALCHARDSHADOW
[in]last_hitThe last intersection. Pass RayHitID() to include all polygons.
[in]recursion_idA plugin ID for data passed through recursion.
[in]recursion_dataThe data that can be passed through recursion.
Returns
The shadow value. 0.0 if there is no shadow. 1.0 is the maximum shadow value for each component.

◆ GetPointUVW()

Vector GetPointUVW ( const TexData tdp,
const RayHitID hit,
const Vector64 p 
) const

Computes the UVW coordinates for a texture.

Parameters
[in]tdpThe texture for the coordinate. The caller owns the pointed texture.
[in]hitThe global RayHitID.
[in]pThe point for the UVW coordinate.
Returns
The UVW coordinate.

◆ ProjectPoint()

Bool ProjectPoint ( const TexData tdp,
const RayHitID hit,
const Vector64 p,
const Vector64 n,
Vector uv 
) const

Computes the UVW coordinates for a texture.

Parameters
[in]tdpThe texture for the coordinates. The caller owns the pointed texture.
[in]hitThe global RayHitID.
[in]pThe point for the UVW coordinate.
[in]nThe normal for the UVW coordinate.
[out]uvAssigned the UVW coordinate.
Returns
true if successful, otherwise false.

◆ StatusSetText()

void StatusSetText ( const maxon::String str) const

Set the status bar text during initialization of a shader or videopost effect. If String() is passed the status bar will be cleared.

Parameters
[in]strThe status text to display.

◆ StatusSetBar()

void StatusSetBar ( Float  percentage) const

Sets the status bar progress during initialization a your shader or videopost effect.

Parameters
[in]percentageThe percentage for the bar.

◆ StatusSetSpinMode()

void StatusSetSpinMode ( Bool  on) const

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

Parameters
[in]ontrue to set the progress bar spinning, false to stop it.

◆ CalcVisibleLight()

Vector CalcVisibleLight ( const Ray ray,
Float  maxdist,
Vector trans 
) const

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

Parameters
[in]rayThe ray span. The caller owns the pointed ray.
[in]maxdistThe maximum distance for the lights.
[out]transAssigned a value !=0 if some light sources have a dust effect.
Returns
The mixed color of the lights.

◆ GetXY()

void GetXY ( Int32 x,
Int32 y,
Int32 scale 
) const

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

Note
Float(x)/Float(scale) and Float(y)/Float(scale) is the screen position.
Parameters
[out]xAssigned the X pixel position.
[out]yAssigned the Y pixel position.
[out]scaleAssigned the render scale.

◆ SetXY()

void SetXY ( Float  x,
Float  y 
)

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

Note
Float(x)/Float(scale) and Float(y)/Float(scale) is the screen position.
Certain Shaders use the screen pixel position. Plugins (like the Baker for instance) can change this position without having to render an image.
Parameters
[in]xThe X pixel position to set.
[in]yThe Y pixel position to set.

◆ GetSceneBoundaries()

MinMax GetSceneBoundaries ( ) const

Goes through all objects and calculates the scene boundaries. It does not take into account infinite sky/floor objects.

Returns
The boundary for all objects within the scene.

◆ CopyTo()

void CopyTo ( VolumeData dst) const

Copies the volume data to another VolumeData.

Parameters
[out]dstThe destination VolumeData. The caller owns the pointed volume data.

◆ Init()

void Init ( VolumeData from)

Initializes the VolumeData with the data of the from object.
Only the most essential parts are copied over, including the render instance.
Such a VolumeData can be used for TraceColorDirect(), TraceGeometry(), TraceColor() etc.

Note
Init() is faster than CopyTo(), but does not allow subsequent access of functions like BaseMaterial::CalcSurface() (only possible if all members are initialized by hand).
Parameters
[in]fromThe source volume data. The caller owns the pointed volume data.

◆ OutOfMemory()

void OutOfMemory ( )

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

◆ CalcFgBg()

Bool CalcFgBg ( Bool  foreground,
Int32  x,
Int32  y,
Int32  subx,
Int32  suby,
Vector color,
Float alpha 
) const

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

Parameters
[in]foregroundtrue to calculate the foreground color, otherwise the background color.
[in]xThe X coordinate.
[in]yThe Y coordinate.
[in]subxThe sub-pixel X position: 0 <= subx <= 15
[in]subyThe sub-pixel Y position: 0 <= suby <= 15
[out]colorAssigned the background/foreground color.
[out]alphaAssigned the background/foreground alpha.
Returns
true if successful, otherwise false.

◆ GetLightFalloff()

Float GetLightFalloff ( Int32  falloff,
Float  inner,
Float  outer,
Float  dist 
) const

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

Parameters
[in]falloffThe light falloff type: RaytraceLightFalloff
[in]innerThe inner falloff value.
[in]outerThe outer falloff value.
[in]distThe distance for the intensity to be calculated at.
Returns
The light falloff.

◆ TestBreak()

Bool TestBreak ( )

Tests for termination. If time intensive operations are performed (such as sending out several rays into the scene) call this routine to check for a renderer break.
In normal situations Cinema 4D breaks after a pixel has been calculated.

Returns
true if the operation has been terminated, otherwise false.

◆ GetVideoPost()

BaseVideoPost* GetVideoPost ( Int32  nth) const

Retrieves a videopost effect for the current render process by index.

Parameters
[in]nthThe index of the videopost effect.
Returns
The video post, or nullptr if the index is too large.

◆ FindVideoPost()

BaseVideoPost* FindVideoPost ( Int32  id) const

Retrieves a video post effect for the current render process by ID.

Parameters
[in]idThe video post effect ID.
Returns
The video post, or nullptr if the index is too large.

◆ GetFragments()

const VPFragment** GetFragments ( Int32  x,
Int32  y,
Int32  cnt,
VPGETFRAGMENTS  flags 
) const

Retrieves the videopost fragments for a point.

Note
Not all fragments are stored during rendering, just the ones closest to the camera. So this cannot be used to for example draw inside a transparent object.
Warning
The array needs to be freed with DeleteMem() afterwards. The fragments must not be freed!
Parameters
[in]xThe X coordinate.
[in]yThe Y coordinate.
[in]cntThe X pixel count.
[in]flagsThe flags: VPGETFRAGMENTS
Returns
An array of pointers to the videopost fragments. The caller owns the pointed array. The volume data owns the pointed fragments.

◆ AddLensGlow()

Bool AddLensGlow ( const LensGlowStruct lgs,
Vector lgs_pos,
Int32  lgs_cnt,
Float  intensity,
Bool  linear_workflow 
) const

Adds a number of lens glows to the image.
In earlier versions the SampleLensFX() call was done automatically. Now this has to be called manually at the end to provide Cinema 4D with the information where to sample.

Parameters
[in]lgsAn array of lgs_cnt lens glow structs to draw. The caller owns the pointed array.
[in]lgs_posAn array of lgs_cnt vectors with the corresponding positions of each lens glow in lgs. The caller owns the pointed array.
[in]lgs_cntThe number of elements in the lgs and lgs_pos arrays.
[in]intensityThe intensity of the lens glows.
[in]linear_workflowtrue if linear workflow is used, otherwise false.
Returns
true if the lens glow was added, otherwise false.

◆ SampleLensFX()

Bool SampleLensFX ( const VPBuffer rgba,
const VPBuffer fx,
BaseThread bt 
) const

Samples all lens effects previously created by calling AddLensGlow().

Parameters
[in]rgbaThe image buffer. The caller owns the pointed buffer.
[in]fxAn FX buffer for the new post effect multipass feature, or nullptr. The caller owns the pointed buffer.
[in]btThe current thread, or nullptr for the main Cinema 4D thread.
Returns
true if successful, otherwise false.

◆ TranslateObjIndex()

Int32 TranslateObjIndex ( Int32  index,
Bool  old_to_new 
) const

Translates a current RayObject number to the one used in the last frame's rendering or vice versa.
For instance if object 5 was object 10 in the last frame. Then TranslateObjIndex(5, false) = 10 and TranslateObjIndex(10, true) = 5.

Note
If plugin generator objects are involved it is necessary that they support the BaseObject::SetUniqueIP() feature.
Parameters
[in]indexThe object index to convert.
[in]old_to_newIf true then index is an index from the last frame and the return value is an index in the current frame. Otherwise it is the other way around.
Returns
The converted object index, or NOTOK if the object does not exist anymore (or did not exist before).

◆ TranslatePolygon()

Bool TranslatePolygon ( const RayObject op,
Int32  local_index,
Vector previous_points 
) const

For a given RayObject op and a local polygon ID local_index retrieves the array of points from the last frame.

Note
To enable this functionality VIDEOPOSTINFO::REQUEST_MOTIONGEOMETRY must be set in the video post.
This function only makes sense to activate in a videopost plugin, as it goes beyond a single frame.
Parameters
[in]opA ray object from the current frame. The caller owns the pointed object.
[in]local_indexA local polygon ID from the current frame.
[in,out]previous_pointsShould point to an array of 4 Vector elements. The caller owns the pointed array.
Assigned the points of the specified polygon from the last frame, if it existed. For a triangle only the 3 first fields of the array are filled.
Returns
true the data was available and stored in previous_points, otherwise false.

◆ TraceColor()

Vector TraceColor ( Ray ray,
Float  maxdist,
const RayHitID last_hit,
SurfaceIntersection si 
)

Works like TraceGeometry(), but calculates the color for a given ray and evaluates all shaders for the intersection point.

Note
To avoid self-intersection, pass the current hit as last_hit. To include all polygons, set last_hit to RayHitID().
Warning
Always use a limit for the recursion (typically a value from 6 to 20) to avoid the danger of a stack overflow.
Parameters
[in]rayThe ray to find the intersection for. The caller owns the pointed ray.
[in]maxdistThe maximum distance to check for intersections.
[in]last_hitThe last intersection, or RayHitID() to include all polygons.
[out]siThe surface intersection structure to take the calculated hit data. The caller owns the pointed surface intersection.
Returns
The color.
A color can be returned even if there was no intersection (si.gid==0); in this case the ray intersected the sky.

◆ TraceColorDirect()

Vector TraceColorDirect ( Ray ray,
Float  maxdist,
Int32  raydepth,
RAYBIT  raybits,
const RayHitID last_hit,
Vector64 oldray,
SurfaceIntersection si 
)

Works like TraceColor(), but always samples the full color including all effects.

Note
To avoid self-intersection, pass the current hit as last_hit. To include all polygons, set last_hit to RayHitID().
Warning
A shader must not call this function if RAYBIT::GI is set in raybits.
Parameters
[in]rayThe ray to find the intersection for. The caller owns the pointed ray.
[in]maxdistThe maximum distance to check for intersections.
[in]raydepthThe ray depth.
[in]raybitsThe ray flags: RAYBIT
[in]last_hitThe last intersection. Pass RayHitID() to include all polygons.
[in]oldrayShould be set to nullptr.
[out]siThe surface intersection structure to take the calculated hit data. The caller owns the pointed surface intersection.
Returns
The color.

◆ TraceGeometry()

Bool TraceGeometry ( const Ray ray,
Float  maxdist,
const RayHitID last_hit,
SurfaceIntersection si 
) const

Calculates an intersection for ray.

Note
To avoid self-intersection, pass the current hit as last_hit. To include all polygons, set last_hit to RayHitID().
Parameters
[in]rayThe ray to find the intersection for. The caller owns the pointed ray.
[in]maxdistThe maximum distance to check for intersections.
[in]last_hitThe last intersection. Pass RayHitID() to include all polygons.
[out]siThe surface intersection structure to take the calculated hit data. The caller owns the pointed surface intersection.
Returns
true if an intersection was found, otherwise false.

◆ TraceGeometryEnhanced()

Bool TraceGeometryEnhanced ( const Ray ray,
Float  maxdist,
const RayHitID last_hit,
Int32  raydepth,
RAYBIT  raybits,
Vector64 oldray,
SurfaceIntersection si 
) const

Calculates an intersection for ray at a certain ray depth.

Note
To avoid self-intersection, pass the current hit as last_hit. To include all polygons, set last_hit to RayHitID().
Parameters
[in]rayThe ray to find the intersection for. The caller owns the pointed ray.
[in]maxdistThe maximum distance to check for intersections.
[in]last_hitThe last intersection. Pass RayHitID() to include all polygons.
[in]raydepthThe ray depth.
[in]raybitsThe rays flags: RAYBIT
[in]oldrayShould be set to nullptr.
[out]siThe surface intersection structure to take the calculated hit data. The caller owns the pointed surface intersection.
Returns
true if an intersection was found, otherwise false.

◆ GetSurfaceData()

void GetSurfaceData ( SurfaceData cd,
Bool  calc_illum,
Bool  calc_shadow,
Bool  calc_refl,
Bool  calc_trans,
Ray ray,
const SurfaceIntersection si 
)

Retrieves information for a point on a surface.

Parameters
[out]cdThe retrieved surface information. The caller owns the pointed surface information.
[in]calc_illumtrue if the point shall be shaded (e.g. the sky is not shaded so is false).
[in]calc_shadowtrue if a shadow shall be calculated.
[in]calc_refltrue if a reflection shall be calculated.
[in]calc_transtrue if a transparency shall be calculated.
[in]rayThe ray. The caller owns the pointed ray.
[in]siThe surface intersection data.

◆ CentralDisplacePointUV()

Vector CentralDisplacePointUV ( const RayObject op,
Int32  local_id,
Int32  uu,
Int32  vv 
) const

Calculates the subpolygon displacement for a polygon local_id of object op.
SPD has to be enabled for the object. The indices uu and vv are >=0 and uu + vv <= op->spd_displacement.
See CalcDisplacementNormals() for an example.

Note
Cinema 4D automatically converts quads to triangles only if an objects has SPD enabled.
Parameters
[in]opThe ray object. The caller owns the pointed object.
[in]local_idThe local polygon ID.
[in]uuThe R coordinate.
[in]vvThe S coordinate.
Returns
The displacement vector.

◆ CentralDisplacePointFromUVPoint()

Vector CentralDisplacePointFromUVPoint ( const RayObject op,
Int32  local_id,
Bool  bFirst,
Float  l1,
Float  l2,
const Vector uv,
const UVWStruct uvw 
) const

Calculates the subpolygon displacement of a point uv in polygon local_id of object op.
SPD has to be enabled for the object. The uv point is expected to be within the triangle local_id. The parameters l1 and l2 are expected to be the triangular barycentric coordinates of point uv within a the triangle. If local_id corresponds to a triangle within a quad, bFirst indicates which of the sub triangles local_id is.

Note
Cinema 4D automatically converts quads to triangles only if an objects has SPD enabled.
Since
R18
Parameters
[in]opThe ray object. The caller owns the pointed object.
[in]local_idThe abc or acd triangle id of a quad polygon.
[in]bFirstWhether local_id corresponds to the abc or acd triangle of the quad polygon.
[in]l1First barycentric coordinate.
[in]l2Second barycentric coordinate.
[in]uvUV coordinates of the point to displace.
[in]uvwUVW polygon enclosing the 'uv' point.
Returns
The displacement vector.

◆ CalcDisplacementNormals()

Vector CalcDisplacementNormals ( Float  par_u,
Float  par_v,
Int32  u0,
Int32  v0,
Int32  u1,
Int32  v1,
Int32  u2,
Int32  v2,
const Vector a,
const Vector b,
const Vector c,
const RayObject op,
Int32  polynum 
) const

Calculates the normal at a point on polygon polynum of object op.
SPD has to be enabled for the object. The indices a/b/c are the corner points of the subpolygon and u0/v0/u1/v1/u2/v2 are the r/s coordinates for it.
These are passed here since one usually has to calculate them before, so for speed reasons they do not have to be calculated again.
Example:

Int32 num = lSubID & ~(1<<31), u0, u1, u2, v0, v1, v2;
u0 = u1 = u2 = num / m_pRayObject->spd_displacement;
v0 = v1 = v2 = num % m_pRayObject->spd_displacement;
if (lSubID & (1<<31))
{ u1--; v2--; }
else
{ u1++; v2++; }
tri0 = m_pVolumeData->CentralDisplacePointUV(m_pRayObject, lLocalID, u0, v0);
tri1 = m_pVolumeData->CentralDisplacePointUV(m_pRayObject, lLocalID, u1, v1);
tri2 = m_pVolumeData->CentralDisplacePointUV(m_pRayObject, lLocalID, u2, v2);
n = m_pVolumeData->CalcDisplacementNormals(rParU, rParV, u0, v0, u1, v1, u2, v2, tri0, tri1, tri2, m_pRayObject, lLocalID));
Vector64 n
[READ ONLY] The surface phong normal.
Definition: c4d_shader.h:1105

The sub-ID and par_u/par_v e.g. are retrieved with VolumeData::TraceGeometry().

Parameters
[in]par_uThe U parameter.
[in]par_vThe V parameter.
[in]u0The R coordinate for a.
[in]v0The S coordinate for a.
[in]u1The R coordinate for b.
[in]v1The S coordinate for b.
[in]u2The R coordinate for c.
[in]v2The S coordinate for c.
[in]aThe first corner point of the sub-polygon.
[in]bThe second corner point of the sub-polygon.
[in]cThe third corner point of the sub-polygon.
[in]opThe ray object. The caller owns the pointed object.
[in]polynumThe polygon index.
Returns
The displacement normal.

◆ CentralDisplaceUVGetNormal()

Vector CentralDisplaceUVGetNormal ( const RayObject op,
Int32  local_id,
Int32  uu,
Int32  vv 
) const

Private.

◆ CentralDisplaceGetSurfaceNormalFromUVPoint()

Vector CentralDisplaceGetSurfaceNormalFromUVPoint ( const RayObject op,
Int32  local_id,
Bool  bFirst,
Float  par_u,
Float  par_v,
const Vector uv,
const UVWStruct uvw 
) const

Computes the surface normal at the world point corresponding to the UV point at uv. Takes into account whether surface subdivision is active and if true, whether surface rounding is applied.

Since
R18
Parameters
[in]opRayObject containing the UV point and polygon in question.
[in]local_idId of the triangle containing the point uv.
[in]bFirstIf local_id is within a quad, whether local_id is the 'abc' or 'acd' triangle.
[in]par_u'u' barycentric coordinate of uv within the triangle.
[in]par_v'v' barycentric coordinate of uv within the triangle.
[in]uvUV point to evaluate.
[in]uvwUVW polygon enclosing the 'uv' point.
Returns
The surface normal at the world point corresponding to the UV point at uv.

◆ CentralDisplaceGetShadingNormalFromUVPoint()

Vector CentralDisplaceGetShadingNormalFromUVPoint ( const RayObject op,
Int32  local_id,
Bool  bFirst,
Float  par_u,
Float  par_v,
const Vector uv,
const UVWStruct uvw 
) const

Computes the shading normal at the world point corresponding to the UV point at uv. Takes into account whether surface subdivision is active and if true, whether surface rounding is applied.

Since
R18
Parameters
[in]opRayObject containing the UV point and polygon in question.
[in]local_idId of the triangle containing the point uv.
[in]bFirstIf local_id is within a quad, whether local_id is the 'abc' or 'acd' triangle.
[in]par_u'u' barycentric coordinate of uv' within the triangle.
[in]par_v'v' barycentric coordinate of uv within the triangle.
[in]uvPoint to evaluate.
[in]uvwUVW polygon enclosing the 'uv' point.
Returns
The shading normal at the world point corresponding to the UV point at uv.

◆ CentralDisplacePointUVGetBarycentric()

Bool CentralDisplacePointUVGetBarycentric ( const RayObject op,
Int32 local_id,
Int32 uu,
Int32 vv,
RayPolyWeight bary,
Bool displaceQuad 
) const

Private.

◆ GetDisplaceInfo()

Bool GetDisplaceInfo ( const RayObject op,
DisplaceInfo info 
) const

Private.

◆ GetDisplaceNeighbor()

Int32 GetDisplaceNeighbor ( const RayObject op,
Int32  local_id,
Int32  side 
) const

Private.

◆ CorrectLocalID()

void CorrectLocalID ( const RayObject op,
Int32 local_id 
) const

Private.

◆ CalcBackTransformPoint()

Vector CalcBackTransformPoint ( ) const

Calculates the back transform point.

Note
Every time the texture matrix multiplies the back point this method should be used: Call CalcBackTransformPoint():
p = cd->vd->CalcBackTransformPoint();
Instead of writing:
p = cd->vd->tex->im * cd->vd->back_p;
Returns
The back transform point.

◆ CalcMotionObjectMatrixInv()

Matrix64 CalcMotionObjectMatrixInv ( const RayObject op) const

Calculates the inverse matrix of the object when in motion blur.

Since
R16
Parameters
[in]opThe object. The caller owns the pointed object.
Returns
The inverse matrix of the object for motion blur.

◆ SkipRenderProcess()

void SkipRenderProcess ( )

Skips the render process.

Note
Useful for custom renderers.

◆ GetRenderInstance()

const Render* GetRenderInstance ( ) const

Retrieves the current Render* instance.

Returns
The render instance.

◆ GetDUDV()

void GetDUDV ( const TexData tex,
const Vector64 p,
const Vector64 phongn,
const Vector64 orign,
const RayHitID hit,
Bool  forceuvw,
Vector ddu,
Vector ddv,
Bool  usetangents,
const RayPolyWeight weight 
) const

Calculates the DU/DV components for a texture and a given point/normal.
Only necessary for channel shaders that normally cannot access this information.

Note
Traditionally we would estimate the DU/DV for UV mapping from surrounding points.
But it can be inaccurate at the edges for smooth surfaces. Just like we precompute phong normals to compute smooth normals, we added an option (usetangents) to use UV tangents to compute correct DU/DV at any point.
It is a more accurate method that avoid many of the previous problems.
Parameters
[in]texThe texture to initialize. The caller owns the pointed texture data.
[in]pThe surface point.
[in]phongnThe shading normal.
[in]orignThe original normal.
[in]hitThe global RayHitID to get the UV coordinate in.
[in]forceuvwtrue to force UVW calculation.
[out]dduAssigned the calculated DU component.
[out]ddvAssigned the calculated DV component.
[in]usetangentstrue to use UV tangents to compute DU/DV components.
[in]weightOptional weight for the polygon.

◆ GetDUDVFromUVPoint()

void GetDUDVFromUVPoint ( const RayObject op,
const TexData tex,
Float  par_u,
Float  par_v,
const Vector64 uv,
const Vector64 p,
const Vector64 phongn,
const Vector64 orign,
const UVWStruct uvw,
RayHitID hit,
Bool  forceuvw,
Vector ddu,
Vector ddv,
Bool  usetangents 
)

Calculates the DU/DV components for a texture and a given point/normal. Takes into account geometry rounding.

Since
R18
Parameters
[in]opRay object on which the tangents are being evaluated.
[in]texThe texture to initialize. The caller owns the pointed texture data.
[in]par_u'u' triangle barycentric coordinate for uv point
[in]par_v'v' triangle barycentric coordinate for uv point
[in]uvThe UV point for which to evaluate the tangents.
[in]pThe surface point.
[in]phongnThe shading normal. See CentralDisplaceGetShadingNormalFromUVPoint
[in]orignThe surface normal. See CentralDisplaceGetSurfaceNormalFromUVPoint
[in]uvwUVW polygon enclosing the 'uv' point.
[in]hitThe RayHitID containing the triangle info for the 'uv' point.
[in]forceuvwtrue to force UVW calculation.
[out]dduThe calculated DU tangent vector.
[out]ddvThe calculated DV co-tangent vector.
[in]usetangentstrue to use UV tangents to compute DU/DV components.

◆ InitSurfacePointProperties()

void InitSurfacePointProperties ( TexData td)

Initializes the surface point properties in the texture data td.

Parameters
[in]tdThe texture data to initialize. The caller owns the pointed texture data.

◆ AttachVolumeDataFake()

Bool AttachVolumeDataFake ( BaseObject camera,
const BaseContainer renderdata,
Int32  fakeCurrentThreadIdx,
Int32  fakeThreadCount 
)

Attaches camera data to the VolumeData structure that is not available otherwise (like camera information, renderdata and screen pixel position).
Enables the following render functions to work: SetXY(), GetXY(), ProjectPoint() (frontal projection), GetRay(), ScreenToCamera(), CameraToScreen(), GetParameter(), GetRayCamera().
To delete it either free the VolumeData or call AttachVolumeData(nullptr, empty_container).
Here is an example of how to use this method:

BaseDraw *bd = doc->GetRenderBaseDraw();
BaseObject *camera = bd?bd->GetSceneCamera(doc):nullptr;
RenderData *rdata = doc->GetActiveRenderData();
// This example run the main thread, so we pass 0 as fakeCurrentThreadIdx.
if (vd && camera && rdata && vd->AttachVolumeDataFake(camera, rdata->GetDataInstanceRef(), 0, 1))
{
Int32 x,y;
for (y=0; y<10; y++)
{
for (x=0; x<rdata->GetDataInstanceRef().GetInt32(RDATA_XRES); x++)
{
vd->GetRay(x,y,&ray);
}
}
}
void GePrint(const maxon::String &str)
Definition: c4d_basedraw.h:755
const BaseObject * GetSceneCamera(const BaseDocument *doc)
Definition: c4d_basedraw.h:818
const BaseContainer & GetDataInstanceRef() const
Definition: c4d_baselist.h:2518
Definition: c4d_baseobject.h:248
Definition: c4d_basedocument.h:143
Definition: c4d_string.h:41
static String FloatToString(Float32 v, Int32 vvk=-1, Int32 nnk=-3)
Definition: c4d_string.h:531
PyObject * x
Definition: bytesobject.h:38
@ RDATA_XRES
Definition: drendersettings.h:152
const char * doc
Definition: pyerrors.h:226
Definition: c4d_shader.h:811
Definition: c4d_tools.h:1388
static void Free(VolumeData *&vd)
Bool AttachVolumeDataFake(BaseObject *camera, const BaseContainer &renderdata, Int32 fakeCurrentThreadIdx, Int32 fakeThreadCount)
Definition: c4d_tools.h:2324
static VolumeData * Alloc()
void GetRay(Float x, Float y, Ray *ray) const
Definition: c4d_tools.h:1783
T y
Definition: vec.h:40
T x
Definition: vec.h:39
T z
Definition: vec.h:41
Parameters
[in]cameraThe camera to attach. The caller owns the pointed camera.
[in]renderdataThe render data container.
[in]fakeCurrentThreadIdxBefore this value was stored in renderdata.RDATA_VDFAKE_CURRENTTHREAD. Now the parameter is passed directly for speedup. The index of the current thread returned by maxon::JobRef::GetCurrentWorkerThreadIndex.
[in]fakeThreadCountBefore this value was stored in renderdata.RDATA_VDFAKE_THREADCOUNT. Now the parameter is passed directly for speedup. The total thread count that will be used to sample the data.
Returns
true if successful, otherwise false.

◆ HasVolumeDataFake()

Bool HasVolumeDataFake ( ) const

Checks if the VolumeData has fake attached.

Returns
true if the volume data has fake data attached, otherwise false.

◆ SaveShaderStack()

Bool SaveShaderStack ( RayShaderStackElement *&  stack,
Int32 stack_cnt 
)

Private.

◆ RestoreShaderStack()

Bool RestoreShaderStack ( RayShaderStackElement stack,
Int32  stack_cnt 
)

Private.

◆ GetRaySky() [2/2]

const RayObject* GetRaySky ( Int32  index) const

Retrieves the index-th sky object (index ranging from 0 to GetRaySkyCount()-1). The object is of type O_SKY.

Parameters
[in]indexThe sky object index.
Returns
The sky object, or nullptr. The volume data owns the pointed sky object.

◆ GetRaySkyCount()

Int32 GetRaySkyCount ( ) const

Gets the number of sky objects.

Returns
The number of sky objects.

◆ GetRaySampler()

RaySampler* GetRaySampler ( void *  guid,
Int32  depth 
)

Private.

◆ GetRayWeight()

Float GetRayWeight ( ) const

Private.

◆ CalcAmbientOcclusion()

Float CalcAmbientOcclusion ( SurfaceIntersection si,
RaySampler sampler,
Float  minlength,
Float  maxlength,
Float  index,
Bool  self,
Bool  trans,
Float  weight,
Bool  reverse 
)

Private.

◆ CalcSubsurfaceScattering()

Vector CalcSubsurfaceScattering ( Vector  scattering,
Vector  absorption,
Vector  diffuse,
Float  ior 
)

Private.

◆ GetStreamCount()

Int32 GetStreamCount ( ) const

Retrieves the number of stereoscopic streams that are rendered.

Returns
The number of stereoscopic streams.

◆ GetStreamRay()

void GetStreamRay ( Int32  stream,
Float  x,
Float  y,
Ray ray 
) const

The same as GetRay() but just for stereoscopic streams.

Parameters
[in]streamThe stereoscopic stream: 0 <= stream < GetStreamCount()
[in]xThe X position for the view ray in screen space coordinates.
[in]yThe Y position for the view ray in screen space coordinates.
[in]rayAssigned the generated view ray. The caller owns the pointed ray.

◆ CalcIndirectIllumination()

Bool CalcIndirectIllumination ( RayHemisphere hs,
Float  weight 
)

Entry point into Cinema 4D GI calculation. Performs the full 3 phase MIS sampling for indirect illumination.
CalcIndirectIllumination() can also be used to compute AO. It is handy as it computes also gradients allowing very fast AO with interpolation.

Parameters
[in]hsControls the GI and if gradient information needs to be computed or not for the caches.
[in]weightThe weight.
Returns
true if successful, otherwise false.

◆ CalcIndirectPDF()

Bool CalcIndirectPDF ( const Vector point,
const Vector normal,
const Vector ray_in,
const Vector ray_out,
Float pdf_qmc,
Float pdf_area,
Float pdf_portal,
Float pdf_sky 
)

Calculates the PDF (Probability Distribution) for the given intersection and 2 ray directions.

Parameters
[in]pointThe point.
[in]normalThe normal.
[in]ray_inThe ray in direction.
[in]ray_outThe ray out direction.
[out]pdf_qmcAssigned the PDF QMC.
[out]pdf_areaAssigned the PDF area.
[out]pdf_portalAssigned the PDF portal.
[out]pdf_skyAssigned the PDF sky.
Returns
true if successful, otherwise false.

◆ CalcIndirectPath()

Bool CalcIndirectPath ( VolumeData sd,
const Vector dir,
void *  source,
void *  target 
)

Private.

◆ CreateRadianceMaps()

RayRadianceObject* CreateRadianceMaps ( )

Private.

◆ GetRadianceMaps()

RayRadianceObject* GetRadianceMaps ( )

Private.

◆ CalcRadianceValue()

Vector CalcRadianceValue ( Ray ray,
const SurfaceIntersection si 
)

Calculates the values for radiance maps.

Parameters
[in]rayThe ray. The caller owns the pointed ray.
[in]siThe surface intersection structure. The caller owns the pointed surface intersection.
Returns
The radiance value.

◆ CalcRadiancePoly()

Vector CalcRadiancePoly ( RayRadianceObject obj,
SurfaceIntersection si,
Int32  poly,
Int32  u,
Int32  v,
Bool  back 
)

Computes the radiance for the given object and polygon index. Used by the Radiosity Maps when computing the color for each "texel" on the poly.

Parameters
[in]objThe radiance object.
[in]siThe surface intersection structure. The caller owns the pointed surface intersection.
[in]polyThe polygon index.
[in]uThe U texel position for the radiosity map.
[in]vThe V texel position for the radiosity map.
[in]backSet to true to computes the illumination for the back side.
Returns
The radiance value.

◆ IsPhysicalRender()

Bool IsPhysicalRender ( ) const

Checks if the Physical Render is being used to render the volume data.

Returns
true if the Physical Render is used to render, otherwise false.

◆ GetPhysicalCameraIntensity()

Float GetPhysicalCameraIntensity ( ) const

Used in Physical Render (always returns 1.0 in Standard).

Note
This method is handy if the plugin does any custom drawing into the buffer. e.g. it can be used in the GI/AO prepass to make sure the prepass intensity matches the render.
Returns
The relative intensity of the camera when exposure is used.

◆ SetPhysicalRayTime()

void SetPhysicalRayTime ( Float  time)

Used in Physical Render. Sets the time state inside the renderer.
The value range is from 0.0 to 1.0, and corresponds to the frame exposure range as specified by the camera.

Note
This method is useful to customize the time when rays are traced before the rendering starts, for example in various prepass tasks to make sure Motion Blur is properly handled.
Parameters
[in]timeThe time.

◆ GetMotionObject()

const RayMotionObject* GetMotionObject ( RayObject op)

Retrieves the motion blur information for an object.

Since
R17.032
Parameters
[in]opThe object. The caller owns the pointed op.
Returns
The motion data.

◆ GetMotionLight()

const RayMotionLight* GetMotionLight ( RayLight light)

Retrieves the motion blur information for a light.

Since
R17.032
Parameters
[in]lightThe light. The caller owns the pointed light.
Returns
The motion data.

◆ GetMotionCamera()

const RayMotionCamera* GetMotionCamera ( Int32  stream)

Retrieves the motion blur information for a camera.

Since
R17.032
Parameters
[in]streamThe camera stream.
Returns
The motion data.

◆ GetTile()

Bool GetTile ( Int32 xMin,
Int32 yMin,
Int32 xMax,
Int32 yMax,
Int32 renderThreadIndex 
) const

Queries information about the currently rendered RayTile.

Since
R16.038
Warning
Not valid during Videopost execution, with the exception of VIDEOPOSTCALL::TILE.
Parameters
[out]xMinAssigned the upper left of the rendered tile.
[out]yMinAssigned the lower left of the rendered tile.
[out]xMaxAssigned the upper right of the rendered tile.
[out]yMaxAssigned the lower right of the rendered tile.
[out]renderThreadIndexAssigned the index of the render thread that invoked VIDEOPOSTCALL::TILE and 'owns' the tile.
Note that pixel calculation can be distributed on multiple render threads.
Returns
true if successful, otherwise false.