Class: TReflectanceShader

Declaration: Shaders.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TShader

Inherited By:

None.

Purpose:

TReflectanceShader, a concrete class derived from TShader, calculates the color of each point on a 3-D surface by simulating the way objects reflect light. It uses a simple shading model that computes the surface color as a weighted sum of the intensity from ambient, diffuse, and specular reflection. Ambient light reflects equally from all surfaces in all directions, so its contribution is equal at all points on a surface. Diffuse reflection refers to light that the surface scatters equally in all directions, but that originates from a point light source and thus does not necessarily reach all the points of a surface. For example, the front and back of a sphere has the same amount of ambient reflection, but the diffuse reflection appears only on the hemisphere facing the light source. Specular reflection refers to light that is not reflected equally in all directions, and that depends on both the angle of the light source and the angle of viewing. An example is the reflection of a window in a shiny apple. At this point on the apple, the color might be almost white (the color of the window) rather than the apple's base color (such as red or green). TReflectanceShader computes the shade based on four variables that are standard in computer graphics: the ambient coefficient, diffuse coefficient, specular coefficient, and specular exponent. These variables can be set to different values to simulate the reflective properties of different real-world materials. Note that every default shader in the Graphics system has a TReflectanceShader object.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

None.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: TReflectanceShader::TReflectanceShader

  1. TReflectanceShader (const TReflectanceShader & source)
  2. TReflectanceShader (double ka, double kd, double ks, double specularExp)
  3. TReflectanceShader ()

Interface Category:

API.

Purpose:

  1. Copy constructor.
  2. Constructor used to set the specific coefficients for ambient, diffuse, and specular light contributions.
  3. Default constructor. Sets the ambient light coefficient to 0.3. Sets the diffuse light coefficient to 0.7. Sets the specular light coefficient to 0.0. Sets the specular exponent to 20.0.

Calling Context:

  1. Called to copy an object.
  2. Call this function directly.
  3. Called by the stream-in operators. You can also call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::~TReflectanceShader

virtual ~ TReflectanceShader ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::ComputeShade

virtual void ComputeShade (TShadingSample & shadingInfo, const TSceneState & sceneState)

Interface Category:

API.

Purpose:

Computes the resultant color for the given point, using the base color, reflections, and atmospheric attenuation.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::Diffuse

virtual void Diffuse (const TShadingSample & shadingInfo, const TSceneState & sceneState, TColor & returnColor)

Interface Category:

API.

Purpose:

Returns the total diffuse light contribution from all light sources.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::Specular

virtual void Specular (const TShadingSample & shadingInfo, const TSceneState & sceneState, double specularExponent, TColor & returnColor)

Interface Category:

API.

Purpose:

Returns the total specular light contribution from all light sources.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::SetAmbientCoefficient

virtual void SetAmbientCoefficient (double ambientCoefficient)

Interface Category:

API.

Purpose:

Sets the coefficient for the contribution of ambient light.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::SetDiffuseCoefficient

virtual void SetDiffuseCoefficient (double diffuseCoefficient)

Interface Category:

API.

Purpose:

Sets the coefficient for the contribution of diffuse light.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::SetSpecularCoefficient

virtual void SetSpecularCoefficient (double specularCoefficient)

Interface Category:

API.

Purpose:

Sets the coefficient for the contribution of specular light.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::SetSpecularExponent

virtual void SetSpecularExponent (double specularExponent)

Interface Category:

API.

Purpose:

Sets the exponential value used to compute the contribution of specular light.

Calling Context:

Call this function directly.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::GetAmbientCoefficient

virtual double GetAmbientCoefficient () const

Interface Category:

API.

Purpose:

Returns the ambient light coefficient.

Calling Context:

Call this function directly.

Parameters:

Return Value:

The ambient light coefficient (should be between 0.0 and 1.0).

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::GetDiffuseCoefficient

virtual double GetDiffuseCoefficient () const

Interface Category:

API.

Purpose:

Returns the diffuse light coefficient.

Calling Context:

Call this function directly.

Parameters:

Return Value:

The diffuse light coefficient (should be between 0.0 and 1.0).

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::GetSpecularCoefficient

virtual double GetSpecularCoefficient () const

Interface Category:

API.

Purpose:

Returns the specular light coefficient.

Calling Context:

Call this function directly.

Parameters:

Return Value:

The specular light coefficient (should be between 0.0 and 1.0).

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::GetSpecularExponent

virtual double GetSpecularExponent () const

Interface Category:

API.

Purpose:

Returns the exponent value used in computing the contribution of specular light.

Calling Context:

Call this function directly.

Parameters:

Return Value:

The specular exponent value.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::operator=

TReflectanceShader & operator =(const TReflectanceShader & source)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Call this function by using the operator in an assignment statement.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::operator>>=

virtual TStream & operator >>=(TStream &) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TReflectanceShader::operator<<=

virtual TStream & operator <<= (TStream &)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.