What the spotlight looks like?

New Message Reply Date view Thread view Subject view Author view

Cao Zhigang (czg++at++iname.com)
Tue, 21 Oct 1997 23:12:47 -0700


Hello pfFriends,
I have been working on per-pixel Spotlight and asked many
questions on this mail list. Thanks to friends who helped
me. Maybe I'm not smart enough that I still can't get what
that looks like PER-PIXEL SPOTLIGHT.
I use iR station with IRIX6.2/pf2.1/OpenGL. I wrote my program
by modifing perfly. In env.c I added following code:

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


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:06 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.