class RED::IMoonLightShape

This interface gives access to the moon light settings. More...

#include <REDIMoonLightShape.h>

Inherits: IREDObject.

Public functions:

virtual RED_RCGetMoon ( RED::Vector3 & oMoonDir, double & oMoonScale, double & oMoonMult, int iStateNumber = -1 ) const = 0
virtual RED_RCGetSamplesCount ( unsigned int & oSamplesCount, int iStateNumber = -1 ) const = 0
virtual RED_RCSetSamplesCount ( unsigned int iSamplesCount, const RED::State & iState ) = 0

Public static functions:

static RED::CIDGetClassID ( )

Detailed description:

This interface gives access to the moon light settings.

The RED::IMoonLightShape interface is exposed by the CID_REDLightShape instances.

This light simulates a moon based on a sky model definition. It's set-up through the RED::ISkyLightShape interface by calling RED::ISkyLightShape::SetMoonLight. You can get the correct moon's position as seen from earth according to time, date and location by using the RED::ISkyLightShape::ComputeMoonDirection method.

To get a full sky simulation (i.e including light scattered by the atmosphere), don't forget to add a RED::ISkyLightShape instance to your scene.

The sun light is handled separately using the RED::ISunLightShape and RED::ISkyLightShape interfaces.

task

Task: Setup a physical moon light

A physical moon light can't exist without a physical sky light. So all starts with the creation of a physical sky light (Setup a physical sky light).

Then the sky light is used to set up the moon light according to its sky model:

// "sky" is a pointer to a previously created and set up RED sky light instance.
RED::ISkyLightShape* isky = sky->As< RED::ISkyLightShape >();

// Initialize the moon light according to the current sky model settings.
RED::Object* sun = NULL;  // passing NULL makes the method below to create the sun instance for us.
RC_TEST( isky->SetMoonLight( sun, iresmgr->GetState() ) );

Because the moon is a physical light, no other parameters are needed (like colour or intensity) and all other data are computed based on physics simulation.

Note:

The moon is a very weak source of light. Therefore, its contribution to a scene is often quite subtle.

Functions documentation

public virtual RED_RC RED::IMoonLightShape::GetMoon(RED::Vector3 &oMoonDir,
double &oMoonScale,
double &oMoonMult,
intiStateNumber = -1
)const = 0

Gets parameters of a physical moon.

See RED::ISkyLightShape::SetMoonLight for all the details about the parameters returned by this method.

Parameters:

oMoonDirunit direction from the ground to the moon.
oMoonScaleMoon size scaling factor.
oMoonMultMoon intensity multiplier.
iStateNumberQueried state number.

Returns:

RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received invalid parameters,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_WORKFLOW_ERROR if a transaction error has occurred,
RED_FAIL otherwise.
public virtual RED_RC RED::IMoonLightShape::GetSamplesCount(unsigned int &oSamplesCount,
intiStateNumber = -1
)const = 0

Gets the number of moon samples.

See RED::IMoonLightShape::SetSamplesCount for details.

Parameters:

oSamplesCountthe maximum number of moon light samples.
iStateNumberqueried state number.

Returns:

RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received invalid parameters,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_WORKFLOW_ERROR if a transaction error has occurred,
RED_FAIL otherwise.
public virtual RED_RC RED::IMoonLightShape::SetSamplesCount(unsigned intiSamplesCount,
const RED::State &iState
) = 0

Sets the number of samples to be taken during moon evaluation.

Lights are sampled during the rendering phase in each shaded point to estimate their contribution to the scene. The more the samples, the better the result and the longer the rendering times.

Lights can't have less than 1 sample. If 0 is supplied, 1 will be used instead.

A moon light is a very small source as seen from the ground and few samples are needed for a good result.

Parameters:

iSamplesCountmaximum number of samples to be taken while evaluating the moon light contribution.
iStatecurrent transaction.

Returns:

RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received invalid parameters,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_WORKFLOW_ERROR if a transaction error has occurred,
RED_FAIL otherwise.