VolumetricEffectClouds

Detailed Description

class VolumetricEffectClouds : public RED::VolumetricEffect

This class defines clouds volumetric effects in a scene.

@related Rendering Volumetric Clouds, class RED::ICloudsVolumeShape, class RED::VolumetricEffect

Public Functions

SET_CID(CID_class_REDVolumetricEffectClouds)
IMPLEMENT_AS()
SET_CHUNK_SIGNATURE (0x00000040)
IMPLEMENT_CHUNKINTERPRETER()
VolumetricEffectClouds()

Construction method.

This volumetric effect implements the clouds volume.

VolumetricEffectClouds(const RED::VolumetricEffectClouds &iEffect)

Copy constructor.

Parameters:iEffect – the effect to copy.
virtual ~VolumetricEffectClouds()

Destruction method.

RED::VolumetricEffectClouds &operator=(const RED::VolumetricEffectClouds &iEffect)

Copy operator.

Parameters:iEffect – the effect to copy.
Returns:a reference to this.
virtual bool 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.
virtual void 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.
virtual void 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.
virtual void 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.
void SetSigmaA(const RED::Vector3 &iSigmaA)

Sets the absorption coefficient.

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

Parameters:iSigmaA – absorption coefficient.
void SetSigmaA(const double iSigmaA[3])

Sets the absorption coefficient.

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

Parameters:iSigmaA – absorption coefficient.
void 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.
void 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.
virtual void 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.
void 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.
void 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.
virtual double 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:the volume density at a given position in the volume.
virtual void 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.
virtual RED_RC 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:

RED_OK if the operation has succeded.

RED_FAIL otherwise.

RED_RC SetLayerHeights(double iHeightLow, double iHeightHigh)

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.

inline void GetLayerHeights(double &oHeightLow, double &oHeightHigh) const

Gets the cloud layer low and high heights.

Parameters:
  • oHeightLow – returned low height.
  • oHeightHigh – returned high height.
RED_RC 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:

RED_OK if the method has succeeded,

RED_BAD_PARAM if iSize is invalid.

void SetNoisePatchSize(double iSize)

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

Parameters:iSize – noise patch size.
inline double GetNoisePatchSize() const

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

See RED::VolumetricEffectClouds::SetNoisePatchSize.

Returns:the noise patch size.
RED_RC 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:

RED_OK if the method has succeeded,

RED_BAD_PARAM if iSize is invalid.

void SetCoverPatchSize(double iSize)

Sets the size of the cover patch in the sky.

Parameters:iSize – cover patch size.
inline double GetCoverPatchSize() const

Gets the size of the cover patch in the sky.

See RED::VolumetricEffectClouds::SetCoverPatchSize.

Returns:the cover patch size.
inline void 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.
inline double GetCoverBase() const

Gets the base cover value.

See RED::VolumetricEffectClouds::SetCoverBase.

Returns:the base cover value.
inline void 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.
inline double GetCoverScale() const

Gets the cover scale value.

See RED::VolumetricEffectClouds::SetCoverScale.

Returns:the cover scale value.
void 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.
inline double GetSharpness() const

Gets the clouds sharpness.

See RED::VolumetricEffectClouds::SetSharpness.

Returns:the clouds sharpness.
RED_RC 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:

RED_OK if the method has succeeded,

RED_BAD_PARAM if iSharpness is invalid.

void 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.
inline double GetErosionPatchSize() const

Gets the size of one erosion tile in the sky.

See RED::VolumetricEffectClouds::SetErosionPatchSize.

Returns:the erosion patch size.
inline void 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.
inline double GetErosionScale() const

Gets the erosion weight.

See RED::VolumetricEffectClouds::SetErosionScale.

Returns:the erosion scale.
void 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.
inline double GetErosionThreshold() const

Gets the noise threshold under which the erosion is done.

See RED::VolumetricEffectClouds::GetErosionThreshold.

Returns:the erosion threshold.
inline void SetDensityScale(double iScale)

Sets the overall density scale.

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

Parameters:iScale – erosion scale.
inline double GetDensityScale() const

Gets the density scale.

See RED::VolumetricEffectClouds::SetDensityScale.

Returns:the erosion scale.
virtual RED_RC 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_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.

Public Static Functions

static void 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.
static void 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.
static void 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.