pfuLPointState(3pf) OpenGL Performer 3.2.2 libpfutil Reference Pages
NAME
pfuMakeLPStateShapeTex, pfuMakeLPStateRangeTex - Sample functions to
derive a texture image from light point specifications.
FUNCTION SPECIFICATION
#include <Performer/pfutil.h>
void pfuMakeLPStateShapeTex(pfLPointState *lps, pfTexture *tex,
int size);
void pfuMakeLPStateRangeTex(pfLPointState *lps, pfTexture *tex,
int size, pfFog *fog);
DESCRIPTION
pfMakeLPStateRangeTex and pfMakeLPStateShapeTex are provided to compute a
texture image which accurately mimics certain characteristics of
pfLightPoints. These functions are provided as sample code in libpfutil.
EXAMPLES
The following example illustrates how to build a comprehensive light
point structure that uses texture mapping to accelerate directionality
computations. The texture maps are generated using the
pfuMakeLPStateShapeTex described here.
/*
* Create pfLPointState and pfGeoState.
*/
pfGeoState *gst = pfNewGState(arena);
pfLPointState *lps = pfNewLPState(arena);
pfGStateMode(gst, PFSTATE_ENLPOINTSTATE, 1);
pfGStateAttr(gst, PFSTATE_LPOINTSTATE, lps);
/*
* Light point projected diameter is computed on CPU. Real world
* size is 0.07 database units and projected size is clamped be
* between 0.25 and 4 pixels.
*/
pfLPStateMode(lps, PFLPS_SIZE_MODE, PFLPS_SIZE_MODE_ON);
pfLPStateVal(lps, PFLPS_SIZE_MIN_PIXEL, 0.25f);
pfLPStateVal(lps, PFLPS_SIZE_ACTUAL, 0.07f);
pfLPStateVal(lps, PFLPS_SIZE_MAX_PIXEL, 4.0f);
/*
* Light points become transparent when their projected diameter is
* < 2 pixels. The transparency falloff rate is linear with
* projected size with a scale factor of 0.6. The transparency
* multiplier, NOT the light point transparency, is clamped to 0.1.
*/
pfLPStateVal(lps, PFLPS_TRANSP_PIXEL_SIZE, 2.0f);
Page 1
pfuLPointState(3pf) OpenGL Performer 3.2.2 libpfutil Reference Pages
pfLPStateVal(lps, PFLPS_TRANSP_EXPONENT, 1.0f);
pfLPStateVal(lps, PFLPS_TRANSP_SCALE, 0.6f);
pfLPStateVal(lps, PFLPS_TRANSP_CLAMP, 0.1f);
/*
* Light points will be fogged as if they were 4 times
* nearer to the eye than actual to achieve punch-through.
*/
pfLPStateVal(lps, PFLPS_FOG_SCALE, 0.25f);
/* Range to light points computed on CPU is true range */
pfLPStateMode(lps, PFLPS_RANGE_MODE, PFLPS_RANGE_MODE_TRUE);
/*
* Light points are bidirectional but have different (magenta)
* back color. Front color is provided by pfGeoSet colors.
*/
pfLPStateMode(lps, PFLPS_SHAPE_MODE, PFLPS_SHAPE_MODE_BI_COLOR);
pfLPStateBackColor(lps, 1.0f, 0.0f, 1.0f, 1.0f);
/*
* 60 degrees horizontal and 30 degrees vertical envelope.
* Envelope is rotated -25 degrees about the light point
* direction. Falloff rate is linear and ambient intensity is 0.1.
*/
pfLPStateShape(lps, 60.0f, 30.0f, -25.0f, 1.0f, 0.1f);
/*
* Specify that light points should use texturing hardware to simulate
* directionality and use CPU to compute light point transparency and
* fog punch-through. Note that if light points are omnidirectional,
* you should use PFLPS_TRANSP_MODE_TEX and PFLPS_FOG_MODE_TEX instead.
*/
pfLPStateMode(lps, PFLPS_DIR_MODE, PFLPS_DIR_MODE_TEX);
pfLPStateMode(lps, PFLPS_TRANSP_MODE, PFLPS_TRANSP_MODE_ALPHA);
pfLPStateMode(lps, PFLPS_FOG_MODE, PFLPS_FOG_MODE_ALPHA);
/*
* Make directionality environment map of size 64 x 64 and attach
* it to the light point pfGeoState. We assume that a pfTexEnv of
* type PFTE_MODULATE has been globally applied with pfApplyTEnv.
*/
tex = pfNewTex(arena);
pfuMakeLPStateShapeTex(lps, tex, 64);
pfGStateAttr(gst, PFSTATE_TEXTURE, tex);
pfGStateMode(gst, PFSTATE_ENTEXTURE, 1);
/*
* Make SPHERE_MAP pfTexGen and attach to light point pfGeoState.
* pfGeoSet normals define the per-light light point direction.
*/
tgen = pfNewTGen(arena);
Page 2
pfuLPointState(3pf) OpenGL Performer 3.2.2 libpfutil Reference Pages
pfTGenMode(tgen, PF_S, PFTG_SPHERE_MAP);
pfTGenMode(tgen, PF_T, PFTG_SPHERE_MAP);
pfGStateAttr(gst, PFSTATE_TEXGEN, tgen);
pfGStateMode(gst, PFSTATE_ENTEXGEN, 1);
/*
* Configure light point transparency. Use PFTR_BLEND_ALPHA for high
* quality transparency. Set pfAlphaFunc so that light points are not
* drawn unless their alphas exceed 1 when using 8-bit color resolution.
*/
pfGStateMode(gst, PFSTATE_TRANSPARENCY, PFTR_BLEND_ALPHA);
pfGStateVal(gst, PFSTATE_ALPHAREF, 1.0/255.0);
pfGStateMode(gst, PFSTATE_ALPHAFUNC, PFAF_GREATER);
/*
* Disable pfFog effects since light points are fogged by
* the pfLPointState.
*/
pfGStateMode(gst, PFSTATE_ENFOG, 0);
/*
* Disable lighting effects since light points are completely
* emissive.
*/
pfGStateMode(gst, PFSTATE_ENLIGHTING, 0);
/*
* Attach the pfGeoState to a pfGeoSet of type PFGS_POINTS and
* you've got light points!
*/
pfGSetPrimType(gset, PFGS_POINTS);
pfGSetGState(gset, gst);
For further details, see the libpr routines pfMakeLPStateShapeTex and
pfMakeLPStateRangeTex.
NOTES
The libpfutil source code, object code and documentation are provided as
unsupported software. Routines are subject to change in future releases.
SEE ALSO
pfLPointState, pfMakeLPStateShapeTex, pfMakeLPStateRangeTex
Page 3