class RED::VolumetricEffectClouds
This class defines clouds volumetric effects in a scene.
#include <REDVolumetricEffectClouds.h>
Inherits: VolumetricEffect.
Public functions:
VolumetricEffectClouds ( const RED::VolumetricEffectClouds & iEffect ) | |
VolumetricEffectClouds ( ) | |
virtual | ~VolumetricEffectClouds ( ) |
virtual void * | As ( const RED::CID & iCID ) |
virtual const void * | As ( const RED::CID & iCID ) const |
template< class T_As > const T_As * | As ( ) const |
template< class T_As > T_As * | As ( ) |
double | GetCoverBase ( ) const |
double | GetCoverPatchSize ( ) const |
double | GetCoverScale ( ) const |
virtual double | GetDensity ( const double iPosition[3] ) const |
double | GetDensityScale ( ) const |
virtual void | GetEmission ( double oEmission[3], const double iPosition[3] ) const |
double | GetErosionPatchSize ( ) const |
double | GetErosionScale ( ) const |
double | GetErosionThreshold ( ) const |
void | GetLayerHeights ( double & oHeightLow, double & oHeightHigh ) const |
double | GetNoisePatchSize ( ) const |
virtual void | GetPhase ( double oPhase[3], const double iPosition[3], const double iDirection1[3], const double iDirection2[3] ) const |
double | GetSharpness ( ) const |
virtual void | GetSigmaA ( double oSigmaA[3], const double iPosition[3] ) const |
virtual void | GetSigmaSIn ( double oSigmaS[3], const double iPosition[3] ) const |
virtual void | GetSigmaSOut ( double oSigmaS[3], const double iPosition[3] ) const |
virtual RED_RC | GetVolumeIntervals ( RED::Vector< double > & oIntervals, const double iE[3], const double iP[3], const RED::ISoftRenderingContext & iRenderCtx ) const |
IMPLEMENT_CHUNKINTERPRETER ( ) | |
virtual bool | IsHomogeneous ( ) const |
RED::VolumetricEffectClouds & | operator= ( const RED::VolumetricEffectClouds & iEffect ) |
virtual RED_RC | Save ( RED::IStream * iStream, RED::StreamingPolicy & iPolicy, int iState = -1 ) const |
RED_RC | SetCoverArray ( const float * iCover, int iSize ) |
void | SetCoverBase ( double iCover ) |
void | SetCoverPatchSize ( double iSize ) |
void | SetCoverScale ( double iScale ) |
void | SetDensityScale ( double iScale ) |
void | SetEmission ( const RED::Vector3 & iEmission ) |
void | SetEmission ( const double iEmission[3] ) |
RED_RC | SetErosionArray ( const float * iErosion, int iSize ) |
void | SetErosionPatchSize ( double iSize ) |
void | SetErosionScale ( double iScale ) |
void | SetErosionThreshold ( double iThreshold ) |
RED_RC | SetLayerHeights ( double iHeightLow, double iHeightHigh ) |
RED_RC | SetNoiseArray ( const float * iNoise, int iSize ) |
void | SetNoisePatchSize ( double iSize ) |
void | SetSharpness ( double iSharpness ) |
void | SetSigmaA ( const RED::Vector3 & iSigmaA ) |
void | SetSigmaA ( const double iSigmaA[3] ) |
void | SetSigmaS ( const RED::Vector3 & iSigmaS ) |
void | SetSigmaS ( const double iSigmaS[3] ) |
Public static functions:
static void | GenerateCirrusVolumeData ( float * oData, unsigned int iSize, double iScale ) |
static void | GenerateCumulusVolumeData ( float * oData, unsigned int iSize, double iScale ) |
static void | GenerateErosionVolumeData ( float * oData, unsigned int iSize, double iScale ) |
static RED::CID | GetClassID ( ) |
Protected variables:
const float * | _cover_array |
int | _cover_array_size |
double | _cover_base |
double | _cover_patch_size |
double | _cover_scale |
double | _density_scale |
double | _emission [3] |
const float * | _erosion_array |
int | _erosion_array_size |
double | _erosion_patch_size |
double | _erosion_scale |
double | _erosion_threshold |
double | _layer_threshold [4] |
const float * | _noise_array |
int | _noise_array_size |
double | _noise_patch_size |
double | _sharpness |
double | _sigma_a [3] |
double | _sigma_s [3] |
Private variables:
REDVolumetricEffectCloudsData * | _data |
Functions documentation
public RED::VolumetricEffectClouds::VolumetricEffectClouds | ( | const RED::VolumetricEffectClouds & | iEffect | ) |
Copy constructor.
Parameters:
iEffect: | the effect to copy. |
Construction method.
This volumetric effect implements the clouds volume.
public virtual RED::VolumetricEffectClouds::~VolumetricEffectClouds | ( | ) |
Destruction method.
public static void RED::VolumetricEffectClouds::GenerateCirrusVolumeData | ( | float * | oData, |
unsigned int | iSize, | ||
double | iScale | ||
) |
Generates volume noise data for cirrus clouds.
This method fills a 3d array with volumetric noise to be used by the RED::VolumetricEffectClouds object (RED::VolumetricEffectClouds::SetNoiseArray).
oData must point to allocated memory of size iSize * iSize * iSize.
Parameters:
oData: | array to be filled with data. |
iSize: | size of one dimension of the 3d array pointed by oData. |
iScale: | scaling factor applied to the noise data. |
public static void RED::VolumetricEffectClouds::GenerateCumulusVolumeData | ( | float * | oData, |
unsigned int | iSize, | ||
double | iScale | ||
) |
Generates volume noise data for cumulus clouds.
This method fills a 3d array with volumetric noise to be used by the RED::VolumetricEffectClouds object (RED::VolumetricEffectClouds::SetNoiseArray).
oData must point to allocated memory of size iSize * iSize * iSize.
Parameters:
oData: | array to be filled with data. |
iSize: | size of one dimension of the 3d array pointed by oData. |
iScale: | scaling factor applied to the noise data. |
public static void RED::VolumetricEffectClouds::GenerateErosionVolumeData | ( | float * | oData, |
unsigned int | iSize, | ||
double | iScale | ||
) |
Generates volume noise data for clouds erosion.
This method fills a 3d array with volumetric noise to be used by the RED::VolumetricEffectClouds object (RED::VolumetricEffectClouds::SetErosionArray).
oData must point to allocated memory of size iSize * iSize * iSize.
Parameters:
oData: | array to be filled with data. |
iSize: | size of one dimension of the 3d array pointed by oData. |
iScale: | scaling factor applied to the noise data. |
public static RED::CID RED::VolumetricEffectClouds::GetClassID | ( | ) |
Reimplements: RED::VolumetricEffect::GetClassID.
public virtual void * RED::VolumetricEffectClouds::As | ( | const RED::CID & | iCID | ) |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::VolumetricEffect::As.
public virtual const void * RED::VolumetricEffectClouds::As | ( | const RED::CID & | iCID | ) const |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::VolumetricEffect::As.
template< class T_As > public const T_As * RED::VolumetricEffectClouds::As | ( | ) const |
Template version of the as const method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::VolumetricEffect::As.
template< class T_As > public T_As * RED::VolumetricEffectClouds::As | ( | ) |
Template version of the as method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::VolumetricEffect::As.
public double RED::VolumetricEffectClouds::GetCoverBase | ( | ) const |
Gets the base cover value.
See RED::VolumetricEffectClouds::SetCoverBase.
Returns:
public double RED::VolumetricEffectClouds::GetCoverPatchSize | ( | ) const |
Gets the size of the cover patch in the sky.
See RED::VolumetricEffectClouds::SetCoverPatchSize.
Returns:
public double RED::VolumetricEffectClouds::GetCoverScale | ( | ) const |
Gets the cover scale value.
See RED::VolumetricEffectClouds::SetCoverScale.
Returns:
public virtual double RED::VolumetricEffectClouds::GetDensity | ( | const double | iPosition[3] | ) const |
Returns the volume density at a given position.
See RED::VolumetricEffect::GetDensity to have details about the density.
Parameters:
iPosition: | position in the volume. |
Returns:
Implements: RED::VolumetricEffect::GetDensity.
public double RED::VolumetricEffectClouds::GetDensityScale | ( | ) const |
public virtual void RED::VolumetricEffectClouds::GetEmission | ( | double | oEmission[3], |
const double | iPosition[3] | ||
) | const |
Returns the emission coefficient at a given position.
Emission is the property of the medium to emit light.
This coefficient can take any value greater than 0 and don't have an upper limit. It can be different for each color channel.
Parameters:
oEmission: | returned emission coefficient at the volume position. |
iPosition: | position in the volume. |
Implements: RED::VolumetricEffect::GetEmission.
public double RED::VolumetricEffectClouds::GetErosionPatchSize | ( | ) const |
Gets the size of one erosion tile in the sky.
See RED::VolumetricEffectClouds::SetErosionPatchSize.
Returns:
public double RED::VolumetricEffectClouds::GetErosionScale | ( | ) const |
Gets the erosion weight.
See RED::VolumetricEffectClouds::SetErosionScale.
Returns:
public double RED::VolumetricEffectClouds::GetErosionThreshold | ( | ) const |
Gets the noise threshold under which the erosion is done.
See RED::VolumetricEffectClouds::GetErosionThreshold.
Returns:
public void RED::VolumetricEffectClouds::GetLayerHeights | ( | double & | oHeightLow, |
double & | oHeightHigh | ||
) | const |
Gets the cloud layer low and high heights.
Parameters:
oHeightLow: | returned low height. |
oHeightHigh: | returned high height. |
public double RED::VolumetricEffectClouds::GetNoisePatchSize | ( | ) const |
Gets the size of one noise tile of clouds in the sky.
See RED::VolumetricEffectClouds::SetNoisePatchSize.
Returns:
public virtual void RED::VolumetricEffectClouds::GetPhase | ( | double | oPhase[3], |
const double | iPosition[3], | ||
const double | iDirection1[3], | ||
const double | iDirection2[3] | ||
) | const |
Returns the phase at a given position.
See RED::VolumetricEffect::GetPhase to have details about the phase.
Parameters:
oPhase: | returned phase value at the given position. |
iPosition: | position in the volume. |
iDirection1: | first direction. |
iDirection2: | second direction. |
Implements: RED::VolumetricEffect::GetPhase.
public double RED::VolumetricEffectClouds::GetSharpness | ( | ) const |
Gets the clouds sharpness.
See RED::VolumetricEffectClouds::SetSharpness.
Returns:
public virtual void RED::VolumetricEffectClouds::GetSigmaA | ( | double | oSigmaA[3], |
const double | iPosition[3] | ||
) | const |
Returns the absorption coefficient at a given position.
See RED::VolumetricEffect::GetSigmaA to have details about this coefficient.
Parameters:
oSigmaA: | returned absorption coefficient at the volume position. |
iPosition: | position in the volume. |
Implements: RED::VolumetricEffect::GetSigmaA.
public virtual void RED::VolumetricEffectClouds::GetSigmaSIn | ( | double | oSigmaS[3], |
const double | iPosition[3] | ||
) | const |
Returns the scattering coefficient at a given position.
See RED::VolumetricEffect::GetSigmaSIn to have details about this coefficient.
Parameters:
oSigmaS: | returned scattering coefficient at the volume position. |
iPosition: | position in the volume. |
Implements: RED::VolumetricEffect::GetSigmaSIn.
public virtual void RED::VolumetricEffectClouds::GetSigmaSOut | ( | double | oSigmaS[3], |
const double | iPosition[3] | ||
) | const |
Returns the scattering coefficient at a given position.
See RED::VolumetricEffect::GetSigmaSOut to have details about this coefficient.
Parameters:
oSigmaS: | returned scattering coefficient at the volume position. |
iPosition: | position in the volume. |
Implements: RED::VolumetricEffect::GetSigmaSOut.
public virtual RED_RC RED::VolumetricEffectClouds::GetVolumeIntervals | ( | RED::Vector< double > & | oIntervals, |
const double | iE[3], | ||
const double | iP[3], | ||
const RED::ISoftRenderingContext & | iRenderCtx | ||
) | const |
Returns the intervals of a ray intersecting the volume.
Given a ray, this method returns the parametric intervals along this ray where it intersects the volume.
The returned intervals are contained in a RED::Vector as a series of in and out parametric distances from the ray starting point: [in_1, out_1, in_2, out_2, ..., in_n, out_n]. Therefore, the returned array is always of size 2n.
The returned intervals do not intersect each other and are not sorted in any way.
The method clears the intervals RED:Vector before filling it.
Parameters:
oIntervals: | returned intervals. |
iE: | ray starting point. |
iP: | ray end point. |
iRenderCtx: | Rendering context. |
Returns:
Implements: RED::VolumetricEffect::GetVolumeIntervals.
public virtual bool RED::VolumetricEffectClouds::IsHomogeneous | ( | ) const |
Indicates if the medium is homogeneous.
This method returns true is the medium has the same properties (sigma, density and phase function) for all positions inside its volume.
Returns:
Implements: RED::VolumetricEffect::IsHomogeneous.
public RED::VolumetricEffectClouds & RED::VolumetricEffectClouds::operator= | ( | const RED::VolumetricEffectClouds & | iEffect | ) |
Copy operator.
Parameters:
iEffect: | the effect to copy. |
Returns:
public virtual RED_RC RED::VolumetricEffectClouds::Save | ( | RED::IStream * | iStream, |
RED::StreamingPolicy & | iPolicy, | ||
int | iState = -1 | ||
) | const |
Saves the object content as one or more chunks in the given stream.
Parameters:
iStream: | Pointer to the stream where the data must be saved. |
iPolicy: | Reference to the streaming policy to be used. |
iState: | Optional state number parameter at which the data to be saved must be retrieved. Default is set to 0 (for current state). |
Returns:
RED_FILE_WRITE_ERROR on a file write error (if iStream is a file stream),
RED_ALLOC_FAILURE on a memory allocation error,
RED_FAIL otherwise.
Implements: RED::IChunkSaver::Save.
public RED_RC RED::VolumetricEffectClouds::SetCoverArray | ( | const float * | iCover, |
int | iSize | ||
) |
Sets the clouds cover 2d data.
The data contained in the array must be between 0 and 1.
0 means no clouds,
1 means thick clouds.
Parameters:
iCover: | 2d cover array. |
iSize: | size of one dimension of the 2d cover array. |
Returns:
public void RED::VolumetricEffectClouds::SetCoverBase | ( | double | iCover | ) |
Sets the base cover value.
The cover base is the minimum cover value for all the clouds.
The final cover is computed like this:
cover = cover base + cover array * cover scale.
Parameters:
iCover: | Base cover value. |
public void RED::VolumetricEffectClouds::SetCoverPatchSize | ( | double | iSize | ) |
Sets the size of the cover patch in the sky.
Parameters:
iSize: | cover patch size. |
public void RED::VolumetricEffectClouds::SetCoverScale | ( | double | iScale | ) |
Sets the cover scale value.
The cover scale is applied to the cover array values.
The final cover is computed like this:
cover = cover base + cover array * cover scale.
Parameters:
iScale: | Cover scale value. |
public void RED::VolumetricEffectClouds::SetDensityScale | ( | double | iScale | ) |
Sets the overall density scale.
The density scale is an overall scale applied to the clouds density.
Parameters:
iScale: | erosion scale. |
public void RED::VolumetricEffectClouds::SetEmission | ( | const RED::Vector3 & | iEmission | ) |
Sets the emission coefficient.
This function set the emission coefficient. See RED::VolumetricEffect::GetEmission to have details about this coefficient.
Parameters:
iEmission: | emission coefficient. |
public void RED::VolumetricEffectClouds::SetEmission | ( | const double | iEmission[3] | ) |
Sets the emission coefficient.
This function set the emission coefficient. See RED::VolumetricEffect::GetEmission to have details about this coefficient.
Parameters:
iEmission: | emission coefficient. |
public RED_RC RED::VolumetricEffectClouds::SetErosionArray | ( | const float * | iErosion, |
int | iSize | ||
) |
Sets the erosion volumetric data.
This array is used to erode the edges of the clouds and bring details to the clouds shape.
The data contained in the array must be between 0 and 1. 0 means no erosion, 1 means full erosion.
The RED::VolumetricEffectClouds::GenerateErosionVolumeData helper function can be used to generate the clouds erosion array.
Parameters:
iErosion: | 3d erosion array. |
iSize: | size of one dimension of the 3d erosion array. |
Returns:
public void RED::VolumetricEffectClouds::SetErosionPatchSize | ( | double | iSize | ) |
Sets the size of one erosion tile in the sky.
To be effective and bring details, the erosion patch size must be lower than the noise patch size.
Parameters:
iSize: | erosion patch size. |
public void RED::VolumetricEffectClouds::SetErosionScale | ( | double | iScale | ) |
Sets the amount of erosion data removed from the clouds edges.
The erosion scale is applied to the erosion array values. The higher the value, the more the cloud shape will be eroded.
Parameters:
iScale: | erosion scale. |
public void RED::VolumetricEffectClouds::SetErosionThreshold | ( | double | iThreshold | ) |
Sets the noise threshold under which the erosion is done.
The erosion threshold must be between 0 and 1. The higher the value, the more the cloud shape will be eroded to the center of the cloud.
0 means no erosion,
1 means all the cloud shape is eroded from edge to center.
Parameters:
iThreshold: | erosion threshold. |
public RED_RC RED::VolumetricEffectClouds::SetLayerHeights | ( | double | iHeightLow, |
double | iHeightHigh | ||
) |
Sets the cloud layer low and high heights.
Parameters:
iHeightLow: | low height. |
iHeightHigh: | high height. |
Returns:
public RED_RC RED::VolumetricEffectClouds::SetNoiseArray | ( | const float * | iNoise, |
int | iSize | ||
) |
Sets the clouds volumetric noise data.
The data contained in the array must be between 0 and 1.
0 means no density, i.e. no clouds,
1 means full density, i.e. thick clouds.
The RED::VolumetricEffectClouds::GenerateCumulusVolumeData and RED::VolumetricEffectClouds::GenerateCirrusVolumeData helper functions can be used to generate the clouds noise.
Parameters:
iNoise: | 3d noise array. |
iSize: | size of one dimension of the 3d noise array. |
Returns:
public void RED::VolumetricEffectClouds::SetNoisePatchSize | ( | double | iSize | ) |
Sets the size of one noise tile of clouds in the sky.
Parameters:
iSize: | noise patch size. |
public void RED::VolumetricEffectClouds::SetSharpness | ( | double | iSharpness | ) |
Sets the clouds sharpness.
The clouds sharpness value must be between 0 and 1. Lower values gives fluffy clouds whereas higher values give sharp clouds.
Parameters:
iSharpness: | Clouds sharpness. |
public void RED::VolumetricEffectClouds::SetSigmaA | ( | const RED::Vector3 & | iSigmaA | ) |
Sets the absorption coefficient.
See RED::VolumetricEffect::GetSigmaA to have details about this coefficient.
Parameters:
iSigmaA: | absorption coefficient. |
public void RED::VolumetricEffectClouds::SetSigmaA | ( | const double | iSigmaA[3] | ) |
Sets the absorption coefficient.
See RED::VolumetricEffect::GetSigmaA to have details about this coefficient.
Parameters:
iSigmaA: | absorption coefficient. |
public void RED::VolumetricEffectClouds::SetSigmaS | ( | const RED::Vector3 & | iSigmaS | ) |
Sets the scattering coefficients.
This function set the in-scattering and out-scattering coefficients. Both coefficients are set to iSigmaS. See RED::VolumetricEffect::GetSigmaSIn and RED::VolumetricEffect::GetSigmaSOut to have details about these coefficients.
Parameters:
iSigmaS: | scattering coefficient. |
public void RED::VolumetricEffectClouds::SetSigmaS | ( | const double | iSigmaS[3] | ) |
Sets the scattering coefficients.
This function set the in-scattering and out-scattering coefficients. Both coefficients are set to iSigmaS. See RED::VolumetricEffect::GetSigmaSIn and RED::VolumetricEffect::GetSigmaSOut to have details about these coefficients.
Parameters:
iSigmaS: | scattering coefficient. |
Variables documentation
2d cover array.
Size per dimension of the 2d cover array.
Cover added to the cover array value (cover = _cover_base + _cover_array * _cover_scale).
Size of one texture tile of cover array in the sky.
Scale factor applied to the cover array value (cover = _cover_base + _cover_array * _cover_scale).
Overall cloud density scale.
Emission coefficient.
3d Erosion array.
Size per dimension of the 3d erosion array.
Size of one texture tile of erosion array in the sky.
Scale factor applied to the erosion array value.
Threshold of noise under which we start eroding the cloud.
Layer thresholds.
3d noise array.
Size per dimension of the 3d noise array.
Size of one texture tile of noise array in the sky.
Sharpness factor.
Absorption coefficient.
Scattering coefficient.
Precomputed data for optimization.