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.
- TReflectanceShader (const TReflectanceShader & source)
- TReflectanceShader (double ka, double kd, double ks, double specularExp)
- TReflectanceShader ()
Interface Category:
API.
Purpose:
- Copy constructor.
- Constructor used to set the specific coefficients for ambient, diffuse, and specular light contributions.
- 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:
- Called to copy an object.
- Call this function directly.
- Called by the stream-in operators. You can also call this function directly.
Parameters:
- const TReflectanceShader & source -The object to be copied.
- double ka -The ambient light coefficient.
- double kd -The diffuse light coefficient.
- double ks -The specular light coefficient.
- double specularExp -The specular light exponent factor.
- Takes no parameters.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
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.
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:
- TShadingSample & shadingInfo -The information about the specific point to be shaded. The resultant color is set within the shading information object.
- const TSceneState & sceneState -The state of the scene.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
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:
- const TShadingSample & shadingInfo -The information about the specific point to be shaded.
- const TSceneState & sceneState -The state of the scene.
- TColor & returnColor -The color that represents the total diffuse light contribution from all light sources in the scene.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
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:
- const TShadingSample & shadingInfo -The information about the specific point to be shaded.
- const TSceneState & sceneState -The state of the scene.
- double specularExponent -The specular light exponent value to use.
- TColor & returnColor -The color that represents the total specular light contribution from all light sources in the scene.
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:
- double ambientCoefficient -The ambient light coefficient (should be between 0.0 and 1.0).
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:
- double diffuseCoefficient -The diffuse light coefficient (should be between 0.0 and 1.0).
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:
- double specularCoefficient -The specular light coefficient (should be between 0.0 and 1.0).
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:
- double specularExponent -The specular exponent to use.
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.
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.
virtual TStream & operator >>=(TStream &) const
Interface Category:
API.
Purpose:
Stream-out operator.
Calling Context:
Called to stream out data.
Parameters:
- TStream & -The stream that the object streams itself out to.
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.
virtual TStream & operator <<= (TStream &)
Interface Category:
API.
Purpose:
Stream-in operator.
Calling Context:
Called to stream in data.
Parameters:
- TStream & -The stream that the object streams itself in from.
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.