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 ( )
doubleGetCoverBase ( ) const
doubleGetCoverPatchSize ( ) const
doubleGetCoverScale ( ) const
virtual doubleGetDensity ( const double iPosition[3] ) const
doubleGetDensityScale ( ) const
virtual voidGetEmission ( double oEmission[3], const double iPosition[3] ) const
doubleGetErosionPatchSize ( ) const
doubleGetErosionScale ( ) const
doubleGetErosionThreshold ( ) const
voidGetLayerHeights ( double & oHeightLow, double & oHeightHigh ) const
doubleGetNoisePatchSize ( ) const
virtual voidGetPhase ( double oPhase[3], const double iPosition[3], const double iDirection1[3], const double iDirection2[3] ) const
doubleGetSharpness ( ) const
virtual voidGetSigmaA ( double oSigmaA[3], const double iPosition[3] ) const
virtual voidGetSigmaSIn ( double oSigmaS[3], const double iPosition[3] ) const
virtual voidGetSigmaSOut ( double oSigmaS[3], const double iPosition[3] ) const
virtual RED_RCGetVolumeIntervals ( RED::Vector< double > & oIntervals, const double iE[3], const double iP[3], const RED::ISoftRenderingContext & iRenderCtx ) const
IMPLEMENT_CHUNKINTERPRETER ( )
virtual boolIsHomogeneous ( ) const
RED::VolumetricEffectClouds &operator= ( const RED::VolumetricEffectClouds & iEffect )
virtual RED_RCSave ( RED::IStream * iStream, RED::StreamingPolicy & iPolicy, int iState = -1 ) const
RED_RCSetCoverArray ( const float * iCover, int iSize )
voidSetCoverBase ( double iCover )
voidSetCoverPatchSize ( double iSize )
voidSetCoverScale ( double iScale )
voidSetDensityScale ( double iScale )
voidSetEmission ( const RED::Vector3 & iEmission )
voidSetEmission ( const double iEmission[3] )
RED_RCSetErosionArray ( const float * iErosion, int iSize )
voidSetErosionPatchSize ( double iSize )
voidSetErosionScale ( double iScale )
voidSetErosionThreshold ( double iThreshold )
RED_RCSetLayerHeights ( double iHeightLow, double iHeightHigh )
RED_RCSetNoiseArray ( const float * iNoise, int iSize )
voidSetNoisePatchSize ( double iSize )
voidSetSharpness ( double iSharpness )
voidSetSigmaA ( const RED::Vector3 & iSigmaA )
voidSetSigmaA ( const double iSigmaA[3] )
voidSetSigmaS ( const RED::Vector3 & iSigmaS )
voidSetSigmaS ( const double iSigmaS[3] )

Public static functions:

static voidGenerateCirrusVolumeData ( float * oData, unsigned int iSize, double iScale )
static voidGenerateCumulusVolumeData ( float * oData, unsigned int iSize, double iScale )
static voidGenerateErosionVolumeData ( float * oData, unsigned int iSize, double iScale )
static RED::CIDGetClassID ( )

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

Copy constructor.

Parameters:

iEffect:the effect to copy.

Construction method.

This volumetric effect implements the clouds volume.

Destruction method.

public static void RED::VolumetricEffectClouds::GenerateCirrusVolumeData(float *oData,
unsigned intiSize,
doubleiScale
)

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 intiSize,
doubleiScale
)

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 intiSize,
doubleiScale
)

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 virtual void * RED::VolumetricEffectClouds::As(const RED::CID &iCID)

Converts the object to an instance of the given type.

Parameters:

iCID:Requested class.

Returns:

An object pointer of the given class on success, NULL otherwise.

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:

An object pointer of the given class on success, NULL otherwise.

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:

A pointer to a const instance of class T on success, NULL otherwise.

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:

A pointer to an instance of class T on success, NULL otherwise.

Reimplements: RED::VolumetricEffect::As.

Gets the base cover value.

See RED::VolumetricEffectClouds::SetCoverBase.

Returns:

the base cover value.

Gets the size of the cover patch in the sky.

See RED::VolumetricEffectClouds::SetCoverPatchSize.

Returns:

the cover patch size.

Gets the cover scale value.

See RED::VolumetricEffectClouds::SetCoverScale.

Returns:

the cover scale value.
public virtual double RED::VolumetricEffectClouds::GetDensity(const doubleiPosition[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:

the volume density at a given position in the volume.

Implements: RED::VolumetricEffect::GetDensity.

Gets the density scale.

See RED::VolumetricEffectClouds::SetDensityScale.

Returns:

the erosion scale.
public virtual void RED::VolumetricEffectClouds::GetEmission(doubleoEmission[3],
const doubleiPosition[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.

Gets the size of one erosion tile in the sky.

See RED::VolumetricEffectClouds::SetErosionPatchSize.

Returns:

the erosion patch size.

Gets the erosion weight.

See RED::VolumetricEffectClouds::SetErosionScale.

Returns:

the erosion scale.

Gets the noise threshold under which the erosion is done.

See RED::VolumetricEffectClouds::GetErosionThreshold.

Returns:

the erosion threshold.
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.

Gets the size of one noise tile of clouds in the sky.

See RED::VolumetricEffectClouds::SetNoisePatchSize.

Returns:

the noise patch size.
public virtual void RED::VolumetricEffectClouds::GetPhase(doubleoPhase[3],
const doubleiPosition[3],
const doubleiDirection1[3],
const doubleiDirection2[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.

Gets the clouds sharpness.

See RED::VolumetricEffectClouds::SetSharpness.

Returns:

the clouds sharpness.
public virtual void RED::VolumetricEffectClouds::GetSigmaA(doubleoSigmaA[3],
const doubleiPosition[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(doubleoSigmaS[3],
const doubleiPosition[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(doubleoSigmaS[3],
const doubleiPosition[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 doubleiE[3],
const doubleiP[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:

RED_OK if the operation has succeded.
RED_FAIL otherwise.

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:

True if the medium is homogeneous.

Implements: RED::VolumetricEffect::IsHomogeneous.

Copy operator.

Parameters:

iEffect:the effect to copy.

Returns:

a reference to this.
public virtual RED_RC RED::VolumetricEffectClouds::Save(RED::IStream *iStream,
RED::StreamingPolicy &iPolicy,
intiState = -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_OK on success,
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,
intiSize
)

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:

RED_OK if the method has succeeded,
RED_BAD_PARAM if iSize is invalid.

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.

Sets the size of the cover patch in the sky.

Parameters:

iSize:cover patch size.

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.

Sets the overall density scale.

The density scale is an overall scale applied to the clouds density.

Parameters:

iScale:erosion scale.

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 doubleiEmission[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,
intiSize
)

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:

RED_OK if the method has succeeded,
RED_BAD_PARAM if iSharpness is invalid.

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.

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.

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(doubleiHeightLow,
doubleiHeightHigh
)

Sets the cloud layer low and high heights.

Parameters:

iHeightLow:low height.
iHeightHigh:high height.

Returns:

RED_OK if the method has succeeded,
RED_BAD_PARAM if iHeightLow is higher than iHeightHigh.
public RED_RC RED::VolumetricEffectClouds::SetNoiseArray(const float *iNoise,
intiSize
)

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:

RED_OK if the method has succeeded,
RED_BAD_PARAM if iSize is invalid.

Sets the size of one noise tile of clouds in the sky.

Parameters:

iSize:noise patch size.
public void RED::VolumetricEffectClouds::SetSharpness(doubleiSharpness)

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.

Sets the absorption coefficient.

See RED::VolumetricEffect::GetSigmaA to have details about this coefficient.

Parameters:

iSigmaA:absorption coefficient.
public void RED::VolumetricEffectClouds::SetSigmaA(const doubleiSigmaA[3])

Sets the absorption coefficient.

See RED::VolumetricEffect::GetSigmaA to have details about this coefficient.

Parameters:

iSigmaA:absorption coefficient.

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 doubleiSigmaS[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.

private REDVolumetricEffectCloudsData * RED::VolumetricEffectClouds::_data

Precomputed data for optimization.