Cao Zhigang (czg++at++iname.com)
Tue, 21 Oct 1997 23:12:47 -0700
void
initEnvironment(void)
{
pfEarthSky *es;
pfFrustum *spotFrust;
pfTexture *spotTex;
pfFog *spotFog;
/* Create and configure shadow frustum */
spotFrust = pfNewFrust(pfGetSharedArena());
pfMakeSimpleFrust(spotFrust, 20.0f);
pfFrustNearFar(spotFrust, 1.0f, 100.0f);
/* Load spotlight texture */
spotTex = pfNewTex(pfGetSharedArena());
pfLoadTexFile(spotTex, "spot.rgba");
/* Create and configure range-attenuation fog model */
spotFog = pfNewFog(pfGetSharedArena());
pfFogColor(spotFog, 0.1f, 0.1f, 0.1f);
pfFogRange(spotFog, 0.0f, 100.0f);
/* Create and configure spotlight */
ViewState->spot = pfNewLSource();
pfLSourceAttr(ViewState->spot, PFLS_PROJ_TEX, spotTex);
pfLSourceAttr(ViewState->spot, PFLS_PROJ_FRUST, spotFrust);
pfLSourceAttr(ViewState->spot, PFLS_PROJ_FOG, spotFog);
pfLSourceColor(ViewState->spot, PFLT_DIFFUSE, 1.0f, 1.0f, 1.0f);
pfLSourceVal(ViewState->spot, PFLS_INTENSITY, 1.0f);
pfLSourcePos(ViewState->spot, 0.0f, 0.0f, 0.0f, 1.0f);
pfSpotLSourceDir(ViewState->spot, 1.0f, 0.0f, 1.0f);
pfLSourceMode(ViewState->spot, PFLS_PROJTEX_ENABLE, 1);
/* Add to DCSes so we can move lights around */
ViewState->spotDCS = pfNewDCS();
pfAddChild(ViewState->spotDCS, ViewState->spot);
pfAddChild(ViewState->scene, ViewState->spotDCS);
/* Enable emissive pass since scene has emissive surfaces */
pfChanTravMode(ViewState->masterChan, PFTRAV_MULTIPASS,
PFMPASS_EMISSIVE_PASS|PFMPASS_GLOBAL_AMBIENT);
.......
}
void
updateEnvironment(void)
{
......
/* update pos of spot lightsource */
pfDCSMat(ViewState->spotDCS, ViewState->viewMat);
......
}
The program works but the scene is not lighted PER-PIXEL but PER-VERTEX.
And whatever type the spottexture is, there is no difference. I'v used
the
texture with all texels set to max value and the texture with all texels
set to zero, and no difference. In on-line books and manpage I can't
find
how to make spottexture----its size and type, how it is placed related
with
the lightsource. There is no change if I remark out the line
pfChanTravMode(ViewState->masterChan, PFTRAV_MULTIPASS,
PFMPASS_EMISSIVE_PASS|PFMPASS_GLOBAL_AMBIENT);
I'm in a heavy fog ... don't know where to go. Please help.
Thanks
Cao Zhigang
===================================
E-Mail: czg++at++iname.com
Tel: (8610)68428861-340
Fax: (8610)68424844
===================================
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:06 PDT