Public Member Functions | Public Attributes

ShadeOutput Class Reference

This reference page is linked to from the following overview topics: Render Elements.


Search for all occurrences

Detailed Description

See also:
Class ShadeContext, Class Color.

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

#include <imtl.h>

Inheritance diagram for ShadeOutput:
Inheritance graph
[legend]

List of all members.

Public Member Functions

CoreExport void  MixIn (ShadeOutput &a, float f)
  ShadeOutput ()
  ShadeOutput (int nEle)
void  Reset (int nEle=-1)
CoreExport ShadeOutput Clone ()
int  NewElementVal ()
int  NElementVals ()
void  SetNElements (int n)
AColor  ElementVal (int n)
void  SetElementVal (int n, AColor c)
void  AccumElementVal (int n, AColor c)
void  Sum (ShadeOutput *pSample)
void  Scale (float x)
void  SumClr (ShadeOutput *pSample)
ShadeOutput operator+= (ShadeOutput &a)
ShadeOutput operator*= (Color x)
ShadeOutput operator= (ShadeOutput &a)

Public Attributes

ULONG  flags
Color  c
Color  t
float  ior
int  gbufId
int  nElements
AColor  elementVals [N_MAX_RENDER_ELEMENTS]

Constructor & Destructor Documentation

ShadeOutput ( ) [inline]
:nElements(0), flags(0), gbufId(0){};
ShadeOutput ( int  nEle ) [inline]
:flags(0), gbufId(0){ nElements = nEle; }

Member Function Documentation

CoreExport 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 as follows:
            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.
void Reset ( int  nEle = -1 ) [inline]
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.
            { 
                 flags = 0;
                 gbufId = 0;
                 c.Black(); t.Black(); ior = 1.0f;
                 // clear nEle's worth of render elements
                 if (nEle >= 0)
                        nElements = nEle;
                 for( int i=0; i < nElements; ++i )
                        elementVals[i].r = elementVals[i].g =
                             elementVals[i].b = elementVals[i].a = 0.0f;
            }
CoreExport ShadeOutput* Clone ( )
int NewElementVal ( ) [inline]
                               {
                 DbgAssert((nElements+1)<N_MAX_RENDER_ELEMENTS); 
                 return nElements++; 
            }
int NElementVals ( ) [inline]
void SetNElements ( int  n ) [inline]
                                      {
                 DbgAssert( n>=0 && n<N_MAX_RENDER_ELEMENTS); 
                 nElements = n;
            }
AColor ElementVal ( int  n ) [inline]
                                      { 
                 DbgAssert( n>=0 && n<N_MAX_RENDER_ELEMENTS); 
                 return elementVals[n]; 
            }
void SetElementVal ( int  n,
AColor  c 
) [inline]
                                                 { 
                 DbgAssert( n>=0 && n<N_MAX_RENDER_ELEMENTS); 
                 elementVals[n] = c; 
            }
void AccumElementVal ( int  n,
AColor  c 
) [inline]
                                                   { 
                 DbgAssert( n>=0 && n<N_MAX_RENDER_ELEMENTS); 
                 elementVals[n] += c; 
            }
void Sum ( ShadeOutput pSample ) [inline]
                                            {
                 c += pSample->c; t += pSample->t;
                 for( int i = 0; i < nElements; ++i )
                        elementVals[i] += pSample->elementVals[i];
            }
void Scale ( float  x ) [inline]
                                 {
                 c *= x; t *= x;
                 for( int i = 0; i < nElements; ++i )
                        elementVals[i] *= x;
            }
void SumClr ( ShadeOutput pSample ) [inline]
                                               {
                 c += pSample->c; 
                 for( int i = 0; i < nElements; ++i ){
                        elementVals[i].r += pSample->elementVals[i].r;
                        elementVals[i].g += pSample->elementVals[i].g;
                        elementVals[i].b += pSample->elementVals[i].b;
                 }
            }
ShadeOutput& operator+= ( ShadeOutput a ) [inline]
                                                       {
                 c += a.c;  
                 t += a.t; 
                 for( int i = 0; i < nElements; ++i )
                        elementVals[i] += a.elementVals[i];
                 return *this;
            }
ShadeOutput& operator*= ( Color  x ) [inline]
                                                {
                 c *= x; // t *= x; 
                 AColor ac( x );
                 ac.a = Intens( x );
                 for( int i = 0; i < nElements; ++i )
                        elementVals[i] *= ac;
                 return *this;
            }
ShadeOutput& operator= ( ShadeOutput a ) [inline]
                                                      {
                 flags = a.flags;
                 c = a.c; t = a.t; 
                 ior = a.ior;
                 gbufId = a.gbufId;
                 nElements = a.nElements;
                 for( int i = 0; i < nElements; ++i )
                        elementVals[i] = a.elementVals[i];
                 return *this;
            }

Member Data Documentation

ULONG flags
float ior
int gbufId
int nElements
AColor elementVals[N_MAX_RENDER_ELEMENTS]

ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput
ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput ShadeOutput