VolumetricEffectLightVolume

Functions

SET_CID

IMPLEMENT_AS

SET_CHUNK_SIGNATURE

IMPLEMENT_CHUNKINTERPRETER

VolumetricEffectLightVolume

~VolumetricEffectLightVolume

bool

IsHomogeneous

void

GetSigmaA

void

GetSigmaSIn

void

GetSigmaSOut

void

SetSigmaA

void

SetSigmaA

void

SetSigmaSIn

void

SetSigmaSIn

void

SetSigmaSOut

void

SetSigmaSOut

void

SetSigmaS

void

SetSigmaS

void

GetEmission

void

SetEmission

void

SetEmission

double

GetDensity

void

GetPhase

RED_RC

GetVolumeIntervals

RED_RC

Save

Detailed Description

class VolumetricEffectLightVolume : public RED::VolumetricEffect

This class defines light volume volumetric effects in a scene.

@related Volumetric Effects, Rendering Volumetric Effects, class RED::IVolumeShape, class RED::ILightShape

Stores all the parameters defining a light volume volumetric effect. See RED::VolumetricEffect for all the parameters details.

Using this volumetric effect creates an homogeneous medium contained inside each light volume in the scene.

It works with all the lights which define a volume:

  • Point light,

  • Spot light,

  • Beam light,

The definition of volume by light for this effect can be independently enabled or disabled by setting the RED::RM_DEFINE_VOLUME render mode. By default, all compatible lights define volume.

It does not add the medium under infinite lights like ambient lights, directionnal lights, area lights, sun and sky lights.

By default, this class defines the following medium properties:

  • Homogeneous medium

  • Sigma a = 0

  • Sigma s = 0

  • Isotropic phase function

  • Density = 1

In order to see the volumetric effect inside the scene, make sure the correct sigma coefficients are set with RED::VolumetricEffectLightVolume::SetSigmaA, RED::VolumetricEffectLightVolume::SetSigmaSIn and RED::VolumetricEffectLightVolume::SetSigmaSOut.

Here are some examples of the same scene rendered with different sigma coefficients and with global illumination activated. Volume rendering is taken into account in the global illumination thanks to the option RED::OPTIONS_RAY_GI_ENABLE_VOLUME. The scene is a room of size 300cm x 400cm x 250cm containing a sphere of radius 30cm and a spot light of intensity 20. The model unit is centimeter. Hence, the sigma coefficients vary from 0 to 0.01m-1.

In order to be physically correct, the sigma s coefficient is the same for in and out-scattering.

../build/doxygen/RED/xml/API_VolumetricEffectSigma.png

To activate the rendering of volumetric effects in a scene, the RED::OPTIONS_RAY_VOLUME option must be set to 1 at least.

Public Functions

SET_CID(CID_class_REDVolumetricEffectLightVolume)
IMPLEMENT_AS()
SET_CHUNK_SIGNATURE (0x00000138)
IMPLEMENT_CHUNKINTERPRETER()
VolumetricEffectLightVolume()

Construction method.

This volumetric effect implements the light volume.

virtual ~VolumetricEffectLightVolume()

Destruction method.

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 SetSigmaSIn(const RED::Vector3 &iSigmaS)

Sets the scattering coefficient.

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

Parameters

iSigmaS – scattering coefficient.

void SetSigmaSIn(const double iSigmaS[3])

Sets the scattering coefficient.

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

Parameters

iSigmaS – scattering coefficient.

void SetSigmaSOut(const RED::Vector3 &iSigmaS)

Sets the scattering coefficient.

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

Parameters

iSigmaS – scattering coefficient.

void SetSigmaSOut(const double iSigmaS[3])

Sets the scattering coefficient.

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

Parameters

iSigmaS – scattering 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.

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.