#include <c4d_tools.h>
Private Member Functions | |
VolumeData () | |
~VolumeData () | |
Alloc/Free | |
static VolumeData * | Alloc () |
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 |
Ray * | tray |
Ray * | rray |
Vector64 | p |
Vector64 | bumpn |
Ray * | ray |
Vector64 | orign |
Vector64 | n |
Vector64 | dispn |
Float64 | dist |
Float64 | cosc |
Vector | uvw |
Vector | delta |
RayHitID | lhit |
const TexData * | tex |
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 RayLight * | xlight |
const RayObject * | op |
Int32 | recursion_id |
void * | recursion_data |
Multipass * | multipass |
Vector | back_p |
Vector | back_delta |
Float | global_mip |
Int32 | sid |
Float | par_u |
Float | par_v |
SurfaceIntersection * | intersection |
Float | mb_offset |
Vector | comp_color |
Vector | comp_specular |
Vector | comp_luminance |
TexEntry * | rtex [4] |
Int32 | rtex_count |
Int32 | elementIndex |
const RayPolyWeight * | displacementWeight |
Protected Member Functions inherited from BaseVolumeData | |
BaseVolumeData () | |
|
private |
|
private |
|
static |
|
static |
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:
[in] | light | The area light to calculate. |
[in] | nodiffuse | true if the diffuse value should not be calculated, otherwise false. |
[in] | nospecular | true if the specular value should not be calculated, otherwise false. |
[in] | specular_exponent | The specular exponent to use. |
[in] | ray_vector | The ray vector. |
[in] | p | The surface point. |
[in] | bumpn | The bump normal. |
[in] | orign | The original normal. |
[in] | raybits | The ray bits: RAYBIT |
[in] | ignoreLightColor | Whether to factor the light color into the result |
[out] | diffuse | Assigned the diffuse component. |
[out] | specular | Assigned the specular component. |
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.
[in] | l | The illuminating light source. The caller owns the pointed light. |
[in] | p | The point in global coordinates. |
[in] | bumpn | The bump normal. |
[in] | phongn | The phong normal. |
[in] | orign | The original normal. |
[in] | rayv | The ray vector. |
[in] | transparency | true if transparencies/alphas for in between objects should be evaluated. |
[in] | hitid | The 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] | raybits | The ray bits: RAYBIT |
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.
[in] | rl | The illuminating light. The caller owns the pointed light. |
[out] | col | Assigned the result of the calculation. |
[out] | light_vector | Assigned the light to point vector. For area and tube lights the vector will use the center of the light source. |
[in] | p | The surface point. |
[in] | bumpn | The bump normal. |
[in] | phongn | The phong normal. |
[in] | orign | The original normal. |
[in] | ray_vector | The ray vector. |
[in] | flags | The illuminate flags: ILLUMINATEFLAGS |
[in] | hitid | The 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] | raybits | The ray bits: RAYBIT |
[in] | cosine_cutoff | true if cosine cut-off should be used, otherwise false. |
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.
[in] | rl | The illuminating light. The caller owns the pointed light. |
[out] | col | Assigned the result of the calculation. |
[out] | light_vector | Assigned the light to point vector. For area and tube lights the vector will use the center of the light source. |
[in] | p | The surface point. |
[in] | flags | The illuminate flags: ILLUMINATEFLAGS |
[in] | raybits | The ray bits: RAYBIT |
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).
[in] | f | The surface point data used for the call. The caller owns the pointed data. |
[in] | diffuse | Assigned the diffuse component. |
[in] | specular | Assigned the specular component. |
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.).
[in] | p | The global coordinate point to calculate the illumination for. |
[in] | flags | The illuminate flags: ILLUMINATEFLAGS |
[in] | raybits | The ray bits: RAYBIT |
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.
[out] | diffuse | Assigned the diffuse component. |
[out] | specular | Assigned the specular component. |
[in] | exponent | The 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] | model | A custom illumination model, or nullptr to use the default illumination model. The caller owns the pointed illumination model. |
[in] | data | The private data passed to the custom illumination function. The caller owns the pointed data. |
Int32 GetCurrentCPU | ( | ) | const |
Retrieves the current thread index on which the shader is executed.
>= 0
and smaller than 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.
Retrieves an object's number. Opposite of GetObj().
[in] | obj | The object to get the number for. The caller owns the pointed object. |
Retrieves the object at index.
[in] | index | The object index: 0<= index < GetObjCount() |
Int32 GetObjCount | ( | ) | const |
Retrieves the overall number of objects.
void GetUVW | ( | const RayObject * | op, |
Int32 | uvwind, | ||
Int32 | local_id, | ||
PolyVector * | uvw | ||
) | const |
Retrieves the UVW coordinates information for a polygon.
void GetNormals | ( | const RayObject * | op, |
Int32 | local_id, | ||
PolyVector * | norm | ||
) | const |
Retrieves the phong normals for a polygon.
[in] | op | The object. The caller owns the pointed object. |
[in] | local_id | The local polygon ID: 0 <= local_id < op->vcnt |
[out] | norm | Assigned the phong normals. The caller owns the pointed coordinates. |
Retrieves the texture at index of an object.
[in] | op | The object. The caller owns the pointed object. |
[in] | index | The index of the texture: 0 <= index < op->texcnt |
Retrieves the face normal for a polygon.
[in] | op | The object. The caller owns the pointed object. |
[in] | polygon | The local polygon ID: 0 <= local_id < op->vcnt |
[in] | second | true if this is the second part of a quadrangle (A-C-D), otherwise false. |
Gets the polygon state of the polygon with ID local_id of object op.
[in] | op | The object. The caller owns the pointed object. |
[in] | local_id | The local polygon ID: 0 <= local_id < op->vcnt |
Retrieves the unique object IP address.
[in] | op | The object. The caller owns the pointed object. |
[in] | length | Assigned the length. |
Retrieves the phong normal for a point.
[in] | hitid | The global RayHitID. |
[in] | p | The point for the phong normal. Must be within the surface boundaries of the polygon. |
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:
[in] | hitid | The global RayHitID. |
[in] | p | The point. |
[out] | r | Assigned the R parameter. |
[out] | s | Assigned the S parameter. |
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:
[in] | hitid | The global RayHitID. |
[in] | p | The point on polygon. |
[out] | wgt | Filled with the weight factors. The caller owns the pointed weights. |
Get the light source at index.
[in] | index | The index of the light source to return: 0 <= index < GetLightCount() |
Int32 GetLightCount | ( | ) | const |
Gets the overall number of lights.
Gets the number for a light. Opposite of GetLight().
[in] | light | The light to get the number for. The caller owns the pointed light. |
const void* GetRayData | ( | Int32 | i | ) | const |
Retrieves one of the raytracer structures, these are also available as direct called, for example GetRaySky().
[in] | i | The requested structure type: RAY |
const RayCamera* GetRayCamera | ( | ) | const |
Retrieves the raytracer camera.
const RayParameter* GetRayParameter | ( | ) | const |
Retrieves the raytracer parameters (settings).
const RayEnvironment* GetRayEnvironment | ( | ) | const |
Retrieves the raytracer environment parameters.
const RayObject* GetRaySky | ( | ) | const |
Retrieves the sky object.
const RayObject* GetRayForeground | ( | ) | const |
Retrieves the foreground object.
const RayObject* GetRayBackground | ( | ) | const |
Retrieves the background object.
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).
[in] | x | The X position for the view ray in screen space coordinates. |
[in] | y | The Y position for the view ray in screen space coordinates. |
[out] | ray | Assigned the generated view ray. The caller owns the pointed ray. |
Transforms screen to camera coordinates.
[in] | p | The screen coordinate. |
Transforms camera to screen coordinates.
[in] | p | The camera coordinate. |
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.
[in] | p1 | The start point for the hard shadow. |
[in] | p2 | The end point for the hard shadow. |
[in] | flags | The flags: CALCHARDSHADOW |
[in] | last_hit | The last intersection. Pass RayHitID() to include all polygons. |
[in] | recursion_id | A plugin ID for data passed through recursion. |
[in] | recursion_data | The data that can be passed through recursion. |
Computes the UVW coordinates for a texture.
[in] | tdp | The texture for the coordinate. The caller owns the pointed texture. |
[in] | hit | The global RayHitID. |
[in] | p | The point for the UVW coordinate. |
Bool ProjectPoint | ( | const TexData * | tdp, |
const RayHitID & | hit, | ||
const Vector64 & | p, | ||
const Vector64 & | n, | ||
Vector * | uv | ||
) | const |
Computes the UVW coordinates for a texture.
[in] | tdp | The texture for the coordinates. The caller owns the pointed texture. |
[in] | hit | The global RayHitID. |
[in] | p | The point for the UVW coordinate. |
[in] | n | The normal for the UVW coordinate. |
[out] | uv | Assigned the UVW coordinate. |
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.
[in] | str | The status text to display. |
void StatusSetBar | ( | Float | percentage | ) | const |
Sets the status bar progress during initialization a your shader or videopost effect.
[in] | percentage | The percentage for the bar. |
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.
[in] | on | true to set the progress bar spinning, false to stop it. |
Calculates the mixed color of all visible lights on a given ray span.
[in] | ray | The ray span. The caller owns the pointed ray. |
[in] | maxdist | The maximum distance for the lights. |
[out] | trans | Assigned a value !=0 if some light sources have a dust effect. |
Retrieves the current X/Y pixel position in render resolution. Render resolution is the screen resolution multiplied by scale.
Float(x)/Float
(scale) and Float(y)/Float
(scale) is the screen position. [out] | x | Assigned the X pixel position. |
[out] | y | Assigned the Y pixel position. |
[out] | scale | Assigned the render scale. |
Sets the current X/Y pixel position in render resolution. Render resolution is the screen resolution multiplied by scale.
Float(x)/Float
(scale) and Float(y)/Float
(scale) is the screen position.[in] | x | The X pixel position to set. |
[in] | y | The Y pixel position to set. |
MinMax GetSceneBoundaries | ( | ) | const |
Goes through all objects and calculates the scene boundaries. It does not take into account infinite sky/floor objects.
void CopyTo | ( | VolumeData * | dst | ) | const |
Copies the volume data to another VolumeData.
[out] | dst | The destination VolumeData. The caller owns the pointed volume data. |
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.
[in] | from | The source volume data. The caller owns the pointed volume data. |
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.
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).
[in] | foreground | true to calculate the foreground color, otherwise the background color. |
[in] | x | The X coordinate. |
[in] | y | The Y coordinate. |
[in] | subx | The sub-pixel X position: 0 <= subx <= 15 |
[in] | suby | The sub-pixel Y position: 0 <= suby <= 15 |
[out] | color | Assigned the background/foreground color. |
[out] | alpha | Assigned the background/foreground alpha. |
Calculates the light falloff function (light intensity for a distance).
[in] | falloff | The light falloff type: RaytraceLightFalloff |
[in] | inner | The inner falloff value. |
[in] | outer | The outer falloff value. |
[in] | dist | The distance for the intensity to be calculated at. |
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.
BaseVideoPost* GetVideoPost | ( | Int32 | nth | ) | const |
Retrieves a videopost effect for the current render process by index.
[in] | nth | The index of the videopost effect. |
BaseVideoPost* FindVideoPost | ( | Int32 | id | ) | const |
Retrieves a video post effect for the current render process by ID.
[in] | id | The video post effect ID. |
const VPFragment** GetFragments | ( | Int32 | x, |
Int32 | y, | ||
Int32 | cnt, | ||
VPGETFRAGMENTS | flags | ||
) | const |
Retrieves the videopost fragments for a point.
[in] | x | The X coordinate. |
[in] | y | The Y coordinate. |
[in] | cnt | The X pixel count. |
[in] | flags | The flags: VPGETFRAGMENTS |
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.
[in] | lgs | An array of lgs_cnt lens glow structs to draw. The caller owns the pointed array. |
[in] | lgs_pos | An array of lgs_cnt vectors with the corresponding positions of each lens glow in lgs. The caller owns the pointed array. |
[in] | lgs_cnt | The number of elements in the lgs and lgs_pos arrays. |
[in] | intensity | The intensity of the lens glows. |
[in] | linear_workflow | true if linear workflow is used, otherwise false. |
Bool SampleLensFX | ( | const VPBuffer * | rgba, |
const VPBuffer * | fx, | ||
BaseThread * | bt | ||
) | const |
Samples all lens effects previously created by calling AddLensGlow().
[in] | rgba | The image buffer. The caller owns the pointed buffer. |
[in] | fx | An FX buffer for the new post effect multipass feature, or nullptr. The caller owns the pointed buffer. |
[in] | bt | The current thread, or nullptr for the main Cinema 4D thread. |
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.
[in] | index | The object index to convert. |
[in] | old_to_new | If 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. |
For a given RayObject op and a local polygon ID local_index retrieves the array of points from the last frame.
[in] | op | A ray object from the current frame. The caller owns the pointed object. |
[in] | local_index | A local polygon ID from the current frame. |
[in,out] | previous_points | Should 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. |
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.
[in] | ray | The ray to find the intersection for. The caller owns the pointed ray. |
[in] | maxdist | The maximum distance to check for intersections. |
[in] | last_hit | The last intersection, or RayHitID() to include all polygons. |
[out] | si | The surface intersection structure to take the calculated hit data. The caller owns the pointed surface intersection. |
si.gid==0
); in this case the ray intersected the sky. 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.
[in] | ray | The ray to find the intersection for. The caller owns the pointed ray. |
[in] | maxdist | The maximum distance to check for intersections. |
[in] | raydepth | The ray depth. |
[in] | raybits | The ray flags: RAYBIT |
[in] | last_hit | The last intersection. Pass RayHitID() to include all polygons. |
[in] | oldray | Should be set to nullptr. |
[out] | si | The surface intersection structure to take the calculated hit data. The caller owns the pointed surface intersection. |
Bool TraceGeometry | ( | const Ray * | ray, |
Float | maxdist, | ||
const RayHitID & | last_hit, | ||
SurfaceIntersection * | si | ||
) | const |
Calculates an intersection for ray.
[in] | ray | The ray to find the intersection for. The caller owns the pointed ray. |
[in] | maxdist | The maximum distance to check for intersections. |
[in] | last_hit | The last intersection. Pass RayHitID() to include all polygons. |
[out] | si | The surface intersection structure to take the calculated hit data. The caller owns the pointed surface intersection. |
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.
[in] | ray | The ray to find the intersection for. The caller owns the pointed ray. |
[in] | maxdist | The maximum distance to check for intersections. |
[in] | last_hit | The last intersection. Pass RayHitID() to include all polygons. |
[in] | raydepth | The ray depth. |
[in] | raybits | The rays flags: RAYBIT |
[in] | oldray | Should be set to nullptr. |
[out] | si | The surface intersection structure to take the calculated hit data. The caller owns the pointed surface intersection. |
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.
[out] | cd | The retrieved surface information. The caller owns the pointed surface information. |
[in] | calc_illum | true if the point shall be shaded (e.g. the sky is not shaded so is false). |
[in] | calc_shadow | true if a shadow shall be calculated. |
[in] | calc_refl | true if a reflection shall be calculated. |
[in] | calc_trans | true if a transparency shall be calculated. |
[in] | ray | The ray. The caller owns the pointed ray. |
[in] | si | The surface intersection data. |
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.
[in] | op | The ray object. The caller owns the pointed object. |
[in] | local_id | The local polygon ID. |
[in] | uu | The R coordinate. |
[in] | vv | The S coordinate. |
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.
[in] | op | The ray object. The caller owns the pointed object. |
[in] | local_id | The abc or acd triangle id of a quad polygon. |
[in] | bFirst | Whether local_id corresponds to the abc or acd triangle of the quad polygon. |
[in] | l1 | First barycentric coordinate. |
[in] | l2 | Second barycentric coordinate. |
[in] | uv | UV coordinates of the point to displace. |
[in] | uvw | UVW polygon enclosing the 'uv' point. |
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:
The sub-ID and par_u/par_v e.g. are retrieved with VolumeData::TraceGeometry().
[in] | par_u | The U parameter. |
[in] | par_v | The V parameter. |
[in] | u0 | The R coordinate for a. |
[in] | v0 | The S coordinate for a. |
[in] | u1 | The R coordinate for b. |
[in] | v1 | The S coordinate for b. |
[in] | u2 | The R coordinate for c. |
[in] | v2 | The S coordinate for c. |
[in] | a | The first corner point of the sub-polygon. |
[in] | b | The second corner point of the sub-polygon. |
[in] | c | The third corner point of the sub-polygon. |
[in] | op | The ray object. The caller owns the pointed object. |
[in] | polynum | The polygon index. |
Vector CentralDisplaceUVGetNormal | ( | const RayObject * | op, |
Int32 | local_id, | ||
Int32 | uu, | ||
Int32 | vv | ||
) | const |
Private.
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.
[in] | op | RayObject containing the UV point and polygon in question. |
[in] | local_id | Id of the triangle containing the point uv. |
[in] | bFirst | If 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] | uv | UV point to evaluate. |
[in] | uvw | UVW polygon enclosing the 'uv' point. |
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.
[in] | op | RayObject containing the UV point and polygon in question. |
[in] | local_id | Id of the triangle containing the point uv. |
[in] | bFirst | If 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] | uv | Point to evaluate. |
[in] | uvw | UVW polygon enclosing the 'uv' point. |
Bool CentralDisplacePointUVGetBarycentric | ( | const RayObject * | op, |
Int32 & | local_id, | ||
Int32 & | uu, | ||
Int32 & | vv, | ||
RayPolyWeight & | bary, | ||
Bool & | displaceQuad | ||
) | const |
Private.
Bool GetDisplaceInfo | ( | const RayObject * | op, |
DisplaceInfo & | info | ||
) | const |
Private.
Vector CalcBackTransformPoint | ( | ) | const |
Calculates the back transform point.
Calculates the inverse matrix of the object when in motion blur.
[in] | op | The object. The caller owns the pointed object. |
void SkipRenderProcess | ( | ) |
Skips the render process.
const Render* GetRenderInstance | ( | ) | const |
Retrieves the current Render* instance.
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.
[in] | tex | The texture to initialize. The caller owns the pointed texture data. |
[in] | p | The surface point. |
[in] | phongn | The shading normal. |
[in] | orign | The original normal. |
[in] | hit | The global RayHitID to get the UV coordinate in. |
[in] | forceuvw | true to force UVW calculation. |
[out] | ddu | Assigned the calculated DU component. |
[out] | ddv | Assigned the calculated DV component. |
[in] | usetangents | true to use UV tangents to compute DU/DV components. |
[in] | weight | Optional weight for the polygon. |
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.
[in] | op | Ray object on which the tangents are being evaluated. |
[in] | tex | The 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] | uv | The UV point for which to evaluate the tangents. |
[in] | p | The surface point. |
[in] | phongn | The shading normal. See CentralDisplaceGetShadingNormalFromUVPoint |
[in] | orign | The surface normal. See CentralDisplaceGetSurfaceNormalFromUVPoint |
[in] | uvw | UVW polygon enclosing the 'uv' point. |
[in] | hit | The RayHitID containing the triangle info for the 'uv' point. |
[in] | forceuvw | true to force UVW calculation. |
[out] | ddu | The calculated DU tangent vector. |
[out] | ddv | The calculated DV co-tangent vector. |
[in] | usetangents | true to use UV tangents to compute DU/DV components. |
void InitSurfacePointProperties | ( | TexData * | td | ) |
Initializes the surface point properties in the texture data td.
[in] | td | The texture data to initialize. The caller owns the pointed texture data. |
Bool AttachVolumeDataFake | ( | BaseObject * | camera, |
const BaseContainer & | renderdata | ||
) |
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:
[in] | camera | The camera to attach. The caller owns the pointed camera. |
[in] | renderdata | The render data container. |
Bool HasVolumeDataFake | ( | ) | const |
Checks if the VolumeData has fake attached.
Bool SaveShaderStack | ( | RayShaderStackElement *& | stack, |
Int32 & | stack_cnt | ||
) |
Private.
Bool RestoreShaderStack | ( | RayShaderStackElement * | stack, |
Int32 | stack_cnt | ||
) |
Private.
Retrieves the index-th sky object (index ranging from 0 to GetRaySkyCount()-1). The object is of type O_SKY.
[in] | index | The sky object index. |
Int32 GetRaySkyCount | ( | ) | const |
Gets the number of sky objects.
RaySampler* GetRaySampler | ( | void * | guid, |
Int32 | depth | ||
) |
Private.
Float GetRayWeight | ( | ) | const |
Private.
Float CalcAmbientOcclusion | ( | SurfaceIntersection * | si, |
RaySampler * | sampler, | ||
Float | minlength, | ||
Float | maxlength, | ||
Float | index, | ||
Bool | self, | ||
Bool | trans, | ||
Float | weight, | ||
Bool | reverse | ||
) |
Private.
Private.
Int32 GetStreamCount | ( | ) | const |
Retrieves the number of stereoscopic streams that are rendered.
The same as GetRay() but just for stereoscopic streams.
[in] | stream | The stereoscopic stream: 0 <= stream < GetStreamCount() |
[in] | x | The X position for the view ray in screen space coordinates. |
[in] | y | The Y position for the view ray in screen space coordinates. |
[in] | ray | Assigned the generated view ray. The caller owns the pointed ray. |
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.
[in] | hs | Controls the GI and if gradient information needs to be computed or not for the caches. |
[in] | weight | The 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 | ||
) |
Calculates the PDF (Probability Distribution) for the given intersection and 2 ray directions.
[in] | point | The point. |
[in] | normal | The normal. |
[in] | ray_in | The ray in direction. |
[in] | ray_out | The ray out direction. |
[out] | pdf_qmc | Assigned the PDF QMC. |
[out] | pdf_area | Assigned the PDF area. |
[out] | pdf_portal | Assigned the PDF portal. |
[out] | pdf_sky | Assigned the PDF sky. |
Bool CalcIndirectPath | ( | VolumeData * | sd, |
const Vector & | dir, | ||
void * | source, | ||
void * | target | ||
) |
Private.
RayRadianceObject* CreateRadianceMaps | ( | ) |
Private.
RayRadianceObject* GetRadianceMaps | ( | ) |
Private.
Vector CalcRadianceValue | ( | Ray * | ray, |
const SurfaceIntersection & | si | ||
) |
Calculates the values for radiance maps.
[in] | ray | The ray. The caller owns the pointed ray. |
[in] | si | The surface intersection structure. The caller owns the pointed surface intersection. |
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.
[in] | obj | The radiance object. |
[in] | si | The surface intersection structure. The caller owns the pointed surface intersection. |
[in] | poly | The polygon index. |
[in] | u | The U texel position for the radiosity map. |
[in] | v | The V texel position for the radiosity map. |
[in] | back | Set to true to computes the illumination for the back side. |
Bool IsPhysicalRender | ( | ) | const |
Checks if the Physical Render is being used to render the volume data.
Float GetPhysicalCameraIntensity | ( | ) | const |
Used in Physical Render (always returns 1.0 in Standard).
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.
[in] | time | The time. |
const RayMotionObject* GetMotionObject | ( | RayObject * | op | ) |
Retrieves the motion blur information for an object.
[in] | op | The object. The caller owns the pointed op. |
const RayMotionLight* GetMotionLight | ( | RayLight * | light | ) |
Retrieves the motion blur information for a light.
[in] | light | The light. The caller owns the pointed light. |
const RayMotionCamera* GetMotionCamera | ( | Int32 | stream | ) |
Retrieves the motion blur information for a camera.
[in] | stream | The camera stream. |
Bool GetTile | ( | Int32 & | xMin, |
Int32 & | yMin, | ||
Int32 & | xMax, | ||
Int32 & | yMax, | ||
Int32 & | renderThreadIndex | ||
) | const |
Queries information about the currently rendered RayTile.
[out] | xMin | Assigned the upper left of the rendered tile. |
[out] | yMin | Assigned the lower left of the rendered tile. |
[out] | xMax | Assigned the upper right of the rendered tile. |
[out] | yMax | Assigned the lower right of the rendered tile. |
[out] | renderThreadIndex | Assigned 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. |