pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)NAMEpfShader - Create, modify and query multi-pass shading primitives.
FUNCTION SPECIFICATION
#include <Performer/pf/pfShader.h>
pfShader::pfShader();
static pfType * pfShader::getClassType(void);
void pfShader::setName(const char* _name);
const char* pfShader::getName() const;
void pfShader::openPass(int passType);
void pfShader::closePass();
int pfShader::getCurPassType();
int pfShader::getNumPasses();
pfShaderPass * pfShader::getCurPass();
pfShaderPass * pfShader::getPass(int index);
pfPassList * pfShader::getPassList();
void pfShader::setPassMode(int which, int mode);
int pfShader::getPassMode(int which);
void pfShader::setPassMultiMode(int which, int index,
int mode);
int pfShader::getPassMultiMode(int which, int index);
void pfShader::setPassAttr(int which, void* attr);
void * pfShader::getPassAttr(int which);
void pfShader::setPassMultiAttr(int which, int index,
void *attr);
void * pfShader::getPassMultiAttr(int which, int index);
void pfShader::setPassVal(int which, float value);
float pfShader::getPassVal(int which);
Page 1
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)
void pfShader::setPassMultiVal(int which, int index,
float values);
float pfShader::getPassMultiVal(int which, int index);
void pfShader::setPassFluxedAttr(int which, void* attr);
void* pfShader::getPassFluxedAttr(int which);
void pfShader::setPassFluxedMode(int mode, void* value);
void* pfShader::getPassFluxedMode(int mode);
void pfShader::setPassFluxedMultiAttr(int which, int index,
void *attr);
void* pfShader::getPassFluxedMultiAttr(int which,
int index);
void pfShader::setPassFluxedVal(int which, void *value);
void* pfShader::getPassFluxedVal(int which);
void pfShader::setPassFluxedMultiMode(int mode, int index,
void * value);
void* pfShader::getPassFluxedMultiMode(int mode, int index);
void pfShader::setPassFluxedMultiVal(int which, int index,
void* value);
void* pfShader::getPassFluxedMultiVal(int which, int index);
void pfShader::setPassNamedMode(int mode, char *name);
void pfShader::setPassNamedAttr(int which, char *name);
void pfShader::setPassNamedMultiAttr(int which, int index,
char *name);
void pfShader::setPassNamedVal(int which, char *name);
void pfShader::setPassNamedMultiMode(int mode, int index,
char *name);
void pfShader::setPassNamedMultiVal(int which, int index,
char *name);
void pfShader::setDefaultGeoState(pfGeoState *gstate);
Page 2
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)
void pfShader::setDefaultFBState(pfFBState *fbs);
pfGeoState * pfShader::getDefaultGeoState();
pfFBState * pfShader::getDefaultFBState();
void pfShader::setPassGeoState(pfGeoState *gstate);
void pfShader::setPassFBState(pfFBState *fbs);
pfGeoState * pfShader::getPassGeoState();
pfFBState * pfShader::getPassFBState();
int pfShader::allocateTempTexture();
int pfShader::setPassTempTexture(int texID);
int pfShader::setTempTexture(int texID,
pfTexture *texture);
int pfShader::resolveTempTextures();
int pfShader::getNumTempTextures();
static pfShader* pfShader::makeBumpMapShader(pfTexture *bumpTex,
pfFlux *lightPos);
static pfShader* -
pfShader::makePhongSpecularShader(pfTexture *specularMap,
pfVec3 specularColor, pfFlux *lightPos,
int mapSize);
static pfShader* pfShader::makeFullPhongShader(pfTexture *specularMap,
pfVec3 specularColor, pfTexture *diffuseMap,
pfFlux *lightPos, int mapSize);
static pfShader* pfShader::makeMultiPhongSpecularShader(int n,
pfTexture **specularMap, pfVec3 *specularColor,
pfFlux **lightPos, int *mapSize);
static pfShader* pfShader::makeMultiFullPhongShader(int n,
pfTexture **specularMap, pfVec3 *specularColor,
pfTexture **diffuseMap, pfFlux **lightPos,
int *mapSize);
static pfShader* -
pfShader::makeSpecularHighlightShader(pfTexture *specularMap,
pfVec3 specularColor, pfFlux *lightPos,
int mapSize);
Page 3
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)PARENT CLASS FUNCTIONS
The OpenGL Performer class pfShader is derived from the parent class
pfObject, so each of these member functions of class pfObject are also
directly usable with objects of class pfShader. This is also true for
ancestor classes of class pfObject.
void* pfObject::operator new(size_t);
void* pfObject::operator new(size_t, pfFluxMemory *fmem);
void pfObject::setUserData(void *data);
void pfObject::setUserData(int slot, void *data);
void* pfObject::getUserData(pfObject *obj);
void* pfObject::getUserData(pfObject *obj, int slot);
int pfObject::getNumUserData();
Since the class pfObject is itself derived from the parent class
pfMemory, objects of class pfShader can also be used with these functions
designed for objects of class pfMemory.
void* pfMemory::getData(const void *ptr);
pfType * pfMemory::getType();
int pfMemory::isOfType(pfType *type);
int pfMemory::isExactType(pfType *type);
const char * pfMemory::getTypeName();
int pfMemory::copy(pfMemory *src);
int pfMemory::compare(const pfMemory *mem);
void pfMemory::print(uint which, uint verbose, char *prefix,
FILE *file);
int pfMemory::getArena(void *ptr);
void* pfMemory::getArena();
int pfMemory::ref();
int pfMemory::unref();
int pfMemory::unrefDelete();
int pfMemory::unrefGetRef();
int pfMemory::getRef();
int pfMemory::checkDelete();
int pfMemory::isFluxed();
void * pfMemory::getArena();
int pfMemory::getSize();
DESCRIPTION
A pfShader is a container for multi-pass rendering algorithm
descriptions. A multi-pass rendering algorithm consists of a collection
of passes. A pass contains information for drawing some arbitrary
geometry with a specific state on the graphic pipeline. A pass may
contain pointers to a pfGeoState and a pfFBState. These two determine the
graphic state to be set before rendering the pass.
A pfShader is not a part of the scene graph. An application should use
pfShaderManager in order to associate a pfShader to a node on the scene
graph. Once a node on the scene graph has a pfShader associated with it,
the entire geometry contents under this node is rendered using that
Page 4
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)
pfShader.
pfShader supports a number of pass types:
PF_SHADERPASS_GEOMETRY
PF_SHADERPASS_QUAD
PF_SHADERPASS_COPYPIXELS
PF_SHADERPASS_ACCUM
PF_SHADERPASS_GEOMETRY_DYNAMIC
PF_SHADERPASS_QUAD_DYNAMIC
PF_SHADERPASS_COPYPIXELS_DYNAMIC
PF_SHADERPASS_ACCUM_DYNAMIC
PF_SHADERPASS_SHIFT_TEXTURE
A pass of type PF_SHADERPASS_GEOMETRY draws its associated geometry using
the pass pfGeoState and pfFBState.
A pass of type PF_SHADERPASS_QUAD draws a quad covering the screen
bounding box of the associated geometry. It applies the specified
pfGeoState and pfFBState before drawing the quad.
A pass of type PF_SHADERPASS_COPYPIXELS operates on bitmaps the size of
the screen bounding box of the associated geometry. It can move bitmaps
in three directions:
1. From frame buffer to texture memory.
2. From frame buffer onto itself.
3. From texture memory to frame buffer.
A pass of type PF_SHADERPASS_ACCUM operates on bitmaps the size of the
screen bounding box of the associated geometry. It can copy bitmaps to
and from the accumulation buffer.
Passes of types PF_SHADERPASS_GEOMETRY_DYNAMIC,
PF_SHADERPASS_QUAD_DYNAMIC, PF_SHADERPASS_COPYPIXELS_DYNAMIC and
PF_SHADERPASS_ACCUM_DYNAMIC behave just like their counterparts without
the _DYNAMIC suffix with the difference that they can refer to fluxed
attributes for any of their attribute types. If both a fluxed and non-
fluxed attribute is set on a dynamic pass, the fluxed attribute takes
precedence.
A pass of type PF_SHADERPASS_SHIFT_TEXTURE is a refinement of
PF_SHADERPASS_GEOMETRY_DYNAMIC which computes new texture coordinates for
the pfGeoSets that it shades which are offset toward a light. This pass
is used for multi-pass bump mapping. This pass can only operate on
pfGeoSets that contain individual triangles. No strips of any sort are
yet supported.
new pfShader creates and returns a handle to a pfShader. Like other
Page 5
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)
pfUpdatables, pfShaders are always allocated from shared memory and
cannot be created statically, on the stack or in arrays. pfShaders
should be deleted using pfDelete rather than the delete operator.
pfShader::getClassType returns the pfType* for the class pfShader. The
pfType* returned by pfShader::getClassType is the same as the pfType*
returned by invoking the virtual function getType on any instance of
class pfShader. Because OpenGL Performer allows subclassing of built-in
types, when decisions are made based on the type of an object, it is
usually better to use the member function isOfType to test if an object
is of a type derived from a Performer type rather than to test for strict
equality of the pfType*'s.
pfShader::setName sets the name for the shader. Note that this is only
used for identifying purposes and by the pfb loader. pfShader::getName
returns the name of the shader, if any.
pfShader::openPass starts a definition of a new pass on a pfShader.
pfShader::closePass ends the definition of the currently open pass. Upon
opening a new pass, the application must provide a pass type from the
types mentioned above. While a pass is open, an application may invoke
methods to define the parameters of the pass.
pfShader::getCurPassType returns the type of the currently open pass. If
no pass is currently open, it returns NULL.
pfShader::getNumPasses returns the number of passes on a pfShader. This
number does not include the currently open pass.
pfShader::getPassList returns a pointer to a pfPassList. A pfPassList
contains the full description of all the passes that were opened and
closed on this pfShader. The pfPassList pointer can be added to a
pfGeoSet using the method pfGeoSet::setPassList in order to change its
drawing behavior and make it use the pfShader passes instead of its
standard drawing function. Changing the pfPassList pointer on a pfGeoSet
is normally handled by the pfShaderManager.
pfShader::setPassMode and pfShader::getPassMode set and get modes on the
currently open pass. On passes of type PF_SHADERPASS_COPYPIXELS, one can
set the pixel copy direction by setting which to
PF_SHADERPASS_COPYPIXELS_DIRECTION and setting mode to one of the
following:
PF_COPYPIXELSPASS_TO_TEXTURE
- From frame buffer to Texture memory.
PF_COPYPIXELSPASS_FROM_TEXTURE
- From texture memory to frame buffer.
Page 6
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)
PF_COPYPIXELSPASS_IN_PLACE
- From frame buffer onto itself.
On passes of type PF_SHADERPASS_ACCUM, one can set the accumulation
buffer operation by setting which to PF_SHADERPASS_ACCUM_OP and setting
mode to one of the valid OpenGL GLenum's as the first parameter of the
OpenGL function glAccum. The PF_SHADERPASS_ACCUM passes mode directly to
the glAccum call.
On passes of type PF_SHADERPASS_GEOMETRY and
PF_SHADERPASS_GEOMETRY_DYNAMIC, it is possible to tell the shader to use
each pfGeoSet's pfGeoState to render that pass. To turn on this mode, set
which to PF_SHADERPASS_USE_LOCAL_GSTATE and set mode to 1. If
PF_SHADERPASS_USE_LOCAL_GSTATE is enabled and the pass also has its own
pfGeoState, the pass pfGeoState takes precedence.
pfShader::setPassMultiMode and pfShader::getPassMultiMode set and get
multi-valued modes on the currently open pass. At the moment, there are
no available modes to set. This API is reserved for future extensions.
pfShader::setPassAttr and pfShader::getPassAttr set and get attributes
on the currently open pass.
On all pass types, setting which to PF_SHADERPASS_FBSTATE and attr to a
pfFBState pointer sets the pfFBState that the currently open pass uses.
On passes of type PF_SHADERPASS_GEOMETRY, PF_SHADERPASS_QUAD,
PF_SHADERPASS_GEOMETRY_DYNAMIC, PF_SHADERPASS_QUAD_DYNAMIC and
PF_SHADERPASS_SHIFT_TEXTURE, setting which to PF_SHADERPASS_GSTATE and
attr to a pfGeoState pointer sets the pfGeoState that the currently open
pass uses.
On passes of type PF_SHADERPASS_GEOMETRY, PF_SHADERPASS_GEOMETRY_DYNAMIC
and PF_SHADERPASS_SHIFT_TEXTURE, setting which to
PF_SHADERPASS_OVERRIDE_COLOR and setting attr to a pfVec4 pointer sets
the override color of the currently open pass to the input pfVec4.
On passes of type PF_SHADERPASS_QUAD and PF_SHADERPASS_QUAD_DYNAMIC,
setting which to PF_SHADERPASS_COLOR and setting attr to a pfVec4 pointer
sets the quad color of the currently open pass.
On passes of type PF_SHADERPASS_COPYPIXELS and
PF_SHADERPASS_COPYPIXELS_DIRECTION, setting which to
PF_SHADERPASS_TEXTURE and setting attr to a pfTexture pointer sets the
texture used by the currently open pass.
pfShader::setPassMultiAttr and pfShader::getPassMultiAttr set and get
multi-value attributes on the currently open pass. At the moment, there
are no available attributes to set. This API is reserved for future
extensions.
pfShader::setPassVal and pfShader::getPassVal set and get values on the
Page 7
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)
currently open pass.
On passes of type PF_SHADERPASS_COPYPIXELS and
PF_SHADERPASS_COPYPIXELS_DYNAMIC, setting which to
PF_SHADERPASS_TEMP_TEXTURE_ID and setting value to a temporary texture ID
determines what temporary texture this pass uses. This value is not used
internally by the pass. It serves as temporary storage for the chosen
texture ID. A later call to pfShader::setPassAttr should supply the
actual pfTexture pointer for this pass.
On passes of type PF_SHADERPASS_ACCUM and PF_SHADERPASS_ACCUM_DYNAMIC,
setting which to PF_SHADERPASS_ACCUM_VAL determines the second parameter
of the call to glAccum. The PF_SHADERPASS_ACCUM pass uses value as the
second parameter of the OpenGL glAccum call.
The following table contains a summary of the available attributes, modes
and values for each shader type:
Token GEOMETRY QUAD COPYPIXELS ACCUM
_________________________________________________________________________
PF_SHADERPASS_FBSTATE + + + +
(Attribute)
PF_SHADERPASS_GSTATE + + - -
(Attribute)
PF_SHADERPASS_OVERRIDE_COLOR + - - -
(Attribute)
PF_SHADERPASS_COLOR - + - -
(Attribute)
PF_SHADERPASS_TEXTURE - - + -
(Attribute)
PF_SHADERPASS_COPYPIXELS_DIRECTION - - + -
(Mode)
PF_SHADERPASS_ACCUM_OP - - - +
(Mode)
PF_SHADERPASS_TEMP_TEXTURE_ID - - + -
(Value)
PF_SHADERPASS_ACCUM_VAL - - - +
(Value)
|
pfShader::setPassFluxedAttr and pfShader::getPassFluxedAttr set and get
the fluxed attributes on the currently open pass.
On all dynamic pass types, setting which to PF_SHADERPASS_FBSTATE and
attr to a pfFluxedFBState sets the pfFluxedFBState that the currently
open pass uses.
On dynamic passes of type PF_SHADERPASS_GEOMETRY_DYNAMIC,
PF_SHADERPASS_SHIFT_TEXTURE and PF_SHADERPASS_QUAD_DYNAMIC, setting
which to PF_SHADERPASS_GSTATE and attr to a pfFluxedGeoState pointer sets
Page 8
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)
the pfFluxedGeoState on the currently open dynamic pass.
On passes of type PF_SHADERPASS_GEOMETRY_DYNAMIC and
PF_SHADERPASS_SHIFT_TEXTURE, setting which to
PF_SHADERPASS_OVERRIDE_COLOR and attr to a pfFlux which contains a pfVec4
sets the fluxed override color for the currently open dynamic pass.
On passes of type PF_SHADERPASS_QUAD_DYNAMIC, setting which to
PF_SHADERPASS_COLOR and attr to a pfFlux containing a pfVec4 sets the
fluxed color of the quad that the currently open dynamic pass will draw.
On passes of type PF_SHADERPASS_COPYPIXELS_DYNAMIC, setting which to
PF_SHADERPASS_TEXTURE and attr to a pfFlux containing a pfTexture pointer
will set the fluxed texture pointer that the currently open pass uses.
pfShader::setPassFluxedMode and pfShader::getPassFluxedMode get and set
the fluxed mode of the currently open pass.
On passes of type PF_SHADERPASS_COPYPIXELS_DYNAMIC, setting which to
PF_SHADERPASS_COPYPIXELS_DIRECTION and mode to a pfFlux containing an int
will set the fluxed copy pixels direction. The valid modes for this
fluxed integer are PF_COPYPIXELSPASS_TO_TEXTURE,
PF_COPYPIXELSPASS_FROM_TEXTURE, and PF_COPYPIXELSPASS_IN_PLACE.
On passes of type PF_SHADERPASS_ACCUM_DYNAMIC, setting which to
PF_SHADERPASS_ACCUM_OP and mode to a pfFlux containing a GLenum will set
the fluxed accumulation buffer operation. Valid values for this GLenum
are the same as for the first parameter of glAccum.
pfShader::setPassFluxedMultiAttr and pfShader::getPassFluxedMultiAttr get
and set fluxed multi-value attributes on the currently open pass. There
are currently no such attributes, these functions are here for future
expansion.
pfShader::setPassFluxedVal and pfShader::getPassFluxedVal set and get the
specified fluxed value on the currently open pass.
Currently the only supported fluxed value is on a
PF_SHADERPASS_ACCUM_DYNAMIC pass type. which must be
PF_SHADERPASS_ACCUM_VAL and value should point to a pfFlux containing a
GLfloat. The legal values for this GLfloat are the same as values for the
second parameter of glAccum.
pfShader::setPassFluxedMultiMode and pfShader::getPassFluxedMultiMode get
and set fluxed multi-element modes. There are currently no such supported
modes.
pfShader::setPassFluxedMultiVal and pfShader::getPassFluxedMultiVal get
and set fluxed multi-element values. There are currently no such
supported values.
Page 9
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)
pfShader::setPassMultiVal and pfShader::getPassMultiVal set and get
multi-element values on the currently open pass. At the moment, there are
no available multi-element values to set. This API is reserved for future
extensions.
pfShader::setPassNamedMode, pfShader::setPassNamedAttr,
pfShader::setPassNamedMultiAttr, pfShader::setPassNamedVal,
pfShader::setPassNamedMultiMode and pfShader::setPassNamedMultiVal are
used to set named properties of passes. A named property is essentially a
variable; it can be used to parametrize a shader. For example, let's say
we used a pfNameSpace to attach a pfGeoState under the name "pass1
GState" somewhere in the scenegraph. When constructing a shader, we could
set the PF_SHADERPASS_GSTATE attribute of any pass by name rather than by
reference. For instance, we could call pfShader::setPassNamedAttr setting
which to PF_SHADERPASS_GSTATE and name to "pass1 GState". When the
pfShaderManager is used to resolve the shaders in the tree, it will map
names to attributes and forward them to the individual passes. With this
kind of setup, it is possible to have the same name refer to different
things in different parts of the tree.
pfShader::setPassNamedMode supports the same set of modes as
pfShader::setPassMode.
pfShader::setPassNamedAttr supports the same set of attributes as
pfShader::setPassAttr
pfShader::setPassNamedVal supports the same set of values as
pfShader::setPassVal.
There is no distinction between fluxed and non-fluxed named properties
since performer can deduce this at run-time. If a non-dynamic pass type
refers to a name that resolves to a fluxed propery, pfShaderManager will
issue a warning.
pfShader::setPassNamedMultiAttr, pfShader::setPassNamedMultiMode, and
pfShader::setPassNamedMultiVal do not support any properties yet.
pfShader::setDefaultGeoState and pfShader::getDefaultGeoState set and get
the shader default pfGeoState. All graphic state that isn't defined on a
pass pfGeoState is inherited from the pfShader pfGeoState. Any graphic
state that isn't specified on both the default pfGeoState and the
pfShader pfGeoState is inherited from a hard-coded system default.
pfShader::setDefaultFBState and pfShader::getDefaultFBState set and get
the shader default pfFBState. All frame-buffer state that isn't defined
on a pass pfFBState is inherited from the pfShader pfFBState. Any frame-
buffer state that isn't specified on both the default pfFBState and the
pfShader pfFBState is inherited from a hard-coded system default.
pfShader::allocateTempTexture returns the integer ID of the next
Page 10
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)
available temporary texture for the pfShader and increments the temporary
texture count for the pfShader.
When constructing a new pfShader object, pfShader::allocateTempTexture
must be called once for each unique temporary texture which will be used
by the pfShader. The returned integer ID should be used for subsequent
calls to pfShader::setPassTempTexture and pfShader::setTempTexture for
specifying texture IDs for passes and mapping pfTexture objects to
texture IDs.
When constructing a pass of a pfShader which requires a temporary
texture, pfShader::setPassTempTexture should be called to assign one of
the texture IDs returned by pfShader::allocateTempTexture to the current
pass. This will create an association between the pfShader's pass and
one of the temporary texture IDs allocated with
pfShader::allocateTempTexture. pfShader::setPassTempTexture returns
negative one if texID is less than zero or greater than or equal to the
temporary texture count for the pfShader. Negative one will also be
returned if the current pass is not a pfCopyPixelsPass. Zero is returned
on successful assignment.
pfShader::setTempTexture maps the integer texID returned by
pfShader::allocateTempTexture to the pfTexture* texture. In order to
reduce texture memory usage it is desirable for texture to point to a
pfTexture object which will be shared between multiple pfShaders. This
can be done because the data stored in pfShader temporary textures is
just that, temporary. Once all the passes of one pfShader have been
applied, another pfShader can make use of the temporary texture for
storing its own temporary results. Of course, it isn't required that
pfTextures be shared between pfShaders, it's just a good idea to do so
and avoid wasting resources. pfShader::setPassTempTexture returns
negative one if texID is less than zero or greater than or equal to the
temporary texture count for the pfShader. Zero is returned on success.
pfShader::resolveTempTextures resolves the mapping from the per pass
integer texture IDs assigned with pfShader::setPassTempTexture to the
pfTexture pointers assigned with pfShader::setTempTexture. If
pfShader::resolveTempTextures is not called, the passes of the pfShaders
will not be assigned pointers to pfTexture objects.
pfShader::resolveTempTextures returns negative one if the current pass
for the pfShader is still open. Zero is returned on success.
When loading pfShaders with pfdLoadShader and mapping them to pfNodes
with the pfShaderManager, temporary texture management will be taken care
of automatically. pfdLoadShader will make the appropriate calls to
pfShader::allocateTempTexture and pfShader::setPassTempTexture while the
pfShaderManager will create a shared pool of pfTexture objects and assign
them to pfShaders with pfShader::setTempTexture. Finally, once all
texture IDs of all pfShaders have been mapped to pointers to pfTextures
in the shared pfTexture pool, the pfShaderManager will call
Page 11
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)
pfShader::resolveTempTextures to map the texture IDs stored in each
pfShader's passes to pfTexture pointers.
pfShader::getNumTempTextures returns the count of allocated temporary
textures for the pfShader.
pfShader::makeBumpMapShader generates a shader which bump maps the
geometry that it applies to. The pfGeoSets that this shader draws must
have a primitive type of PFGS_TRIS for now. bumpTex is pfTexture whose
image data contains a greyscale displacement map. Dark colors map to
little displacement, light colors map to a larger displacement. lightPos
is a pfFlux which contains a pfVec3 that encodes a light position in eye
space.
pfShader::makePhongSpecularShader generates a shader which simulates a
phong specular term on the geometry that it applies to. specularMap is
an environment map which encodes the shininess of the light. The specular
map is generated by rendering a highly tesselated sphere in an
orthographic projection with the light and eye in the same location.
We've provided the utility generatePhongMap.C in
/usr/share/Performer/src/tools to generate these specular maps.
specularColor is a pfVec4 that specifies the color of the specular
highlight; normally the color of the light. lightPos is a pfFlux which
contains a pfVec3 that controls the light position in eye space. mapSize
is a parameter that specifies the size of the environment map to generate
for applying the specular. A size of 64 (width=height) is more than
enough for most applications.
pfShader::makeFullPhongShader This shader is an extension of the phong
specular shader which also simulates the phong lighting model on the
diffuse term of the lighting equation. The additional parameter
diffuseMap specifies a texture that encodes the diffuse term of the phong
lighting equation. For isotropic lighting models, use
"/usr/share/Performer/data/NdotL.rgb"
pfShader::makeMultiPhongSpecularShader This function generates the same
sort of shader as pfShader::makePhongSpecularShader except that it can
handle multiple lights. The first parameter, n specifies the number of
lights. The remaining parameters are arrays of size n which contain the
same types of data as passed to pfShader::makePhongSpecularShader.
pfShader::makeMultiFullPhongShader This function generates a multi-light
full phong shader. The first parameter, n, specifies the number of
lights. The remaining parameters are arrays of size n which contain the
same type of data as passed to pfShader::makeFullPhongShader
pfShader::makeSpecularHighlightShader generates a shader which draws ONLY
the specular term of the phong lighting model and adds it to the
framebuffer. This shader is useful for combining with other shaders so
that it draws the specular highlight on top of their results. The
parameters are the same as to pfShader::makePhongSpecularShader
Page 12
pfShader(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages pfShader(3pf)NOTES
Shaded pfGeoSets can not be compiled into OpenGL display lists. Applying
a shader to a pfNode will disable that functionality on all the pfGeoSets
in the subtree rooted at that node. The function pfGeoSet:setDrawMode
with the PFGS_COMPILE_GL or PFGS_DRAW_GLOBJ mode tokens will have no
effect on shaded pfGeoSets.
SEE ALSO
pfShaderManager, pfGeoSet, glAccum, pfGeoState, pfFBState, pfNameSpace,
pfFluxedGeoState, pfFluxedFBState
Page 13