Class ShadeOutput

3DS Max Plug-In SDK

Class ShadeOutput

See Also: Class ShadeContext, Class Color.

class ShadeOutput : public BaseInterfaceServer

Description:

An instance of this class is a data member of the ShadeContext. This is used to contain the computed color and transparency of the pixel being shaded by a material. All methods of this class are implemented by the system.

Data Members:

public:

ULONG flags;

These flags are not currently used.

Color c;

Shaded color of the pixel.

Color t;

Transparency of the pixel.

float ior;

Index of refraction of the pixel.

int gbufId;

The G-buffer ID. This allows the MixIn() method to pick the id of the material which was blended in the highest proportion.

Methods:

Prototype:

void MixIn(ShadeOutput& a, float f);

Remarks:

This method is used to blend the output of two texmaps, for example, in the Mix texmap. The function is :

void ShadeOutput::MixIn(ShadeOutput &a, float f) {

 if (f<=0.0f) {

  (*this) = a;

  return;

  }

 else if (f>=1.0f) {

  return;

  }

 else {

  float s = 1.0f - f;

  flags |= a.flags;

  c = s*a.c + f*c;

  t = s*a.t + f*t;

  ior = s*a.ior + f*ior;

  if (f<=0.5f) gbufId = a.gbufId;

  }

 }

This does a blend of a with (*this). This blend is applied to the color, transparency, and index of refraction. The flags of are OR'ed together.

Parameters:

ShadeOutput& a

The output of the texmap to blend in.

float f

The amount to blend in, i.e.:

a.MixIn(b, 1.0f) results in 100% of a and none of b.

Prototype:

void Reset(int n = -1)

Remarks:

Implemented by the System.

This method resets the data member such that: c is set to black, t is set to black, ior is set to 1.0, gbufId is set to 0, and the flags are set to 0.

Parameters:

int n = -1

By supplying a negative value this method will clear elements but leave the number of elements unchanged.