Class MapSampler

3DS Max Plug-In SDK

Class MapSampler

See Also: Class UVGen, Class ShadeContext.

Description:

A texture map implements this class and passes it into the UVGen methods EvalUVMap(), EvalUVMapMono(), and EvalDeriv() to evaluate itself with tiling & mirroring. Each of the methods of this class are used to sample the map at a single UV coordinate.

Methods:

Prototype:

virtual AColor Sample(ShadeContext& sc, float u, float v)=0;

Remarks:

Implemented by the Plug-In.

This method is required. It is called to sample the map at a single UV coordinate. This method should not try to antialias the map, it should just return the value. Take for example a bitmap texture implementing this method. If the u values passed was 0.5 and the v value passed was 0.5, the plug-in would just return the pixel value at the center of the bitmap as an AColor.

Parameters:

ShadeContext& sc

The ShadeContext.

float u

The U value in the range of 0.0 to 1.0

float v

The V value in the range of 0.0 to 1.0

Return Value:

The sampled value as an AColor.

Prototype:

virtual AColor SampleFilter(ShadeContext& sc, float u,

 float v, float du, float dv)=0;

Remarks:

Implemented by the Plug-In.

This method is required. It is called to return a value from the map that is the averaged value over the specified region of width du and height dv, centered at u, v. Certain map types may use the du and dv values directly to perform antialiasing of the map.

Parameters:

ShadeContext& sc

The ShadeContext.

float u

The U value in the range of 0.0 to 1.0

float v

The V value in the range of 0.0 to 1.0

float du

This parameter can be considered the width of a small rectangle center on u,v. The u and v value are guaranteed to be inside this rectangle.

float dv

This parameter can be considered the height of a small rectangle center on u,v. The u and v value are guaranteed to be inside this rectangle.

Return Value:

The sampled value as an AColor.

Prototype:

virtual float SampleMono(ShadeContext& sc, float u, float v)

Remarks:

Implemented by the Plug-In.

This method is optional as a default implementation is provided. It may be implemented however if a certain map type can be more efficient in evaluating a mono channel. For example a noise function that produces a single floating point value as a function of UV. This method is called to sample the map at a single UV coordinate. This method should not try to antialias the map, it should just return the value.

Parameters:

ShadeContext& sc

The ShadeContext.

float u

The U value in the range of 0.0 to 1.0

float v

The V value in the range of 0.0 to 1.0

Return Value:

The sampled value as an float.

Default Implementation:

{ return Intens(Sample(sc,u,v)); }

Prototype:

virtual float SampleMonoFilter(ShadeContext& sc, float u,

 float v, float du, float dv)

Remarks:

Implemented by the Plug-In.

This method is optional. It is called to return a value from the map that is the averaged value over the specified region of width du and height dv, centered at u, v. Certain map types may use the du and dv values directly to perform antialiasing of the map.

Parameters:

ShadeContext& sc

The ShadeContext.

float u

The U value in the range of 0.0 to 1.0

float v

The V value in the range of 0.0 to 1.0

float du

This parameter can be considered the width of a small rectangle center on u,v. The u and v value are guaranteed to be inside this rectangle.

float dv

This parameter can be considered the height of a small rectangle center on u,v. The u and v value are guaranteed to be inside this rectangle.

Return Value:

The sampled value as an float.

Default Implementation:

{ return Intens(SampleFilter(sc,u,v,du,dv)); }