Class: TShader

Declaration: Shaders.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

MCollectible

Inherited By:

TReflectanceShader TBumpMapShader TImageMapShader TProcedureMapShader TSurfaceShader

Purpose:

TShader is an abstract base class for shaders. A shader is an object that calculates the color of each point on a 3-D surface. The shader cooperates with the renderer in a 3-D rendering pipeline. First, the renderer asks the shader what sorts of information it needs to compute the shading, by invoking TShader::GetShadingUsageVariables. This is invoked only once per surface. Then, for each point on the surface, the renderer determines whether the point is visible relative to all other objects in the scene. If the point is visible, the renderer initializes a TShadingSample object, which specifies the characteristics of the surface point, such as its color and position. The renderer then passes this TShadingSample to the shader as an argument to ComputeShade, along with a TSceneState object from which the shader can access the scene's light sources, camera, atmosphere shader, and so on. Within TShader::ComputeShade, the shader uses all this information to compute a resulting color for this point, based on other factors that it knows about, such as the reflectance of the surface or a texture map that it applies to the surface. (The specifics of these other factors are determined by TShader derived classes, which override TShader::ComputeShade to implement different shading behavior.) Finally, the shader stores the resultant color and other variables in the TShadingSample, which it returns to the renderer for display.

Instantiation:

Abstract class; do not allocate.

Deriving Classes:

Provided classes: TReflectanceShader, TImageMapShader, TBumpMapShader, TProcedureMapShader, and TSurfaceShader.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: TShader::ComputeShade

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

Interface Category:

API.

Purpose:

Computes the resultant color and other shading variables, given the current surface point and scene state. This is a pure virtual function that must be overridden by derived classes.

Calling Context:

Do not 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: TShader::GetShadingUsageVariables

virtual void GetShadingUsageVariables (TShadingUsageVariables & variables) const

Interface Category:

API.

Purpose:

Returns a TShadingUsageVariables object specifying what information the shader needs in order to shade the surface. Although this function is designed to be overridden by derived classes, the following set of shading information is returned as a default. The shading normal, position, and base color are required for shading. The texture coordinate, tangent, and UV variables are not required.

Calling Context:

Do not call this function directly. It is designed to be overridden by derived classes.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TShader::~TShader

virtual ~ TShader ()

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: TShader::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: TShader::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.

Member Function: TShader::TShader

  1. TShader ()
  2. TShader (const TShader &)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Copy constructor.

Calling Context:

  1. Called by the stream-in operators. This is a protected constructor that should only be called by member functions of a derived class.
  2. Called to copy an object. This is a protected constructor that should only be called by the copy constructor of a derived class.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TShader::operator=

TShader & operator =(const TShader & source)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Call this function by using the operator in an assignment statement. This is a protected constructor that should only be called by member functions of a derived class.

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.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.