Diffuse Lighting with multiple channels and offsets.

New Message Reply Date view Thread view Subject view Author view

From: Jason Coposky (jasonc++at++elumens.com)
Date: 03/01/2001 12:10:59


everyone,

        the scenario:
        we are drawing multiple channels of the same
        scene in a channel group, using channel offsets
        to create a partial cube map, which is then used
        to texture special geometry. this cube map would be
        a cube which was rotated 45 degress such that the
        corner would be along the -z axis in ogl. we then render
        images of the left, right, top and bottom "walls" of the cube.

        the problem:
        given a light model which is set to local, i am still seeing
        lighting dicontinuities across the channel boundaries
        ( diffuse i believe ), which is especially noticable after
        texturing our geometry with the partial cube map.

        notes:
        this problem arose in our open gl implementation,
        which we corrected by (1) moving our "channel offsets"
        into the projection matrix OR (2) applying precalculated
        model-view transforms to the lights before they
        were drawn. ( as well as setting the light model to local
        viewer to fix specular issues )

        the questions:
        * how are the channel offsets dealt with in the pipeline?
          i would imagine them to be applied to the model-view
          matrix to keep the fog calcs proper.
        * what is the obvious thing that im missing?
        
        a simple hack of the simple.C app is included for perusal.
        the final texturing isnt done, but the 3 channels are drawn
        and the discontinuities are noticable. the light model is set
        to local and a red ambient color is added, showing that the
        light model is applied to the scene. ive had the same results
        with both pfLights and pfLightSources and various other attempts.

        thanks.

        ~J

-----------------------------------------------
//CC -o ltest lighttest.cpp -L/usr/lib32/ -lpf_ogl -lpfdu_ogl -lpfutil_ogl
-lGLU -lGL -lXmu -lXext -lX11 -lm
//
//
// Copyright 1995, Silicon Graphics, Inc.
// ALL RIGHTS RESERVED
//
// UNPUBLISHED -- Rights reserved under the copyright laws of the United
// States. Use of a copyright notice is precautionary only and does not
// imply publication or disclosure.
//
// U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
// Use, duplication or disclosure by the Government is subject to
restrictions
// as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the
Rights
// in Technical Data and Computer Software clause at DFARS 252.227-7013
and/or
// in similar or successor clauses in the FAR, or the DOD or NASA FAR
// Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
// 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
//
// Permission to use, copy, modify, distribute, and sell this software
// and its documentation for any purpose is hereby granted without
// fee, provided that (i) the above copyright notices and this
// permission notice appear in all copies of the software and related
// documentation, and (ii) the name of Silicon Graphics may not be
// used in any advertising or publicity relating to the software
// without the specific, prior written permission of Silicon Graphics.
//
// THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
// EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
// WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
//
// IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL,
// INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY
// DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
// WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY
// THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE
// OR PERFORMANCE OF THIS SOFTWARE.
//
//
// simpleC.C: simple Performer program for programmer's guide
//
// $Revision: 1.10 $
// $Date: 1995/11/22 14:35:21 $
//

#include <stdlib.h>

#include <Performer/pf/pfChannel.h>
#include <Performer/pf/pfLightSource.h>
#include <Performer/pf/pfNode.h>
#include <Performer/pf/pfScene.h>

#include <Performer/pr/pfLight.h>

#include <Performer/pfutil.h>
#include <Performer/pfdu.h>

//
// Usage() -- print usage advice and exit. This
// procedure is executed in the application process.
//
static void
Usage (void)
{
    pfNotify(PFNFY_FATAL, PFNFY_USAGE, "Usage: simpleC file.ext ...\n");
    exit(1);
}

pfLight* Sun;

pfGeoState* curState;

void pwConfig( pfPipeWindow* _pw )
{
    _pw->open();

    pfLightModel* ltm = new pfLightModel;
    ltm->setLocal( PF_ON );
    ltm->setAmbient( 1.0, 0.0, 0.0 );
    ltm->apply();

    Sun = new pfLight;
    Sun->setPos( 0.0, 0.0, 0.0, 1.0 );
    Sun->on();

    pfOverride( PFSTATE_LIGHTMODEL, PF_ON );
}

int
main (int argc, char *argv[])
{
    float t = 0.0f;

    if (argc < 2)
        Usage();

    // Initialize Performer
    pfInit();

    // Use default multiprocessing mode based on number of
    // processors.
    //
    pfMultiprocess( PFMP_DEFAULT );

    // Load all loader DSO's before pfConfig() forks
    pfdInitConverter(argv[1]);

    // initiate multi-processing mode set in pfMultiprocess call
    // FORKs for Performer processes, CULL and DRAW, etc. happen here.
    //
    pfConfig();

    // Append to Performer search path, PFPATH, files in
    // /usr/share/Performer/data */
     pfFilePath(".:/usr/share/Performer/data");

    pfNode *root = pfdLoadFile(argv[1]);
    if (root == NULL)
    {
        pfExit();
        exit(-1);
    }

    // Attach loaded file to a new pfScene
    pfScene *scene = new pfScene;
    scene->addChild( root );

    // Create a pfLightSource and attach it to scene
    //scene->addChild(new pfLightSource);

    // Configure and open GL window
    pfPipe *p = pfGetPipe(0);
    pfPipeWindow *pw = new pfPipeWindow(p);
    pw->setWinType(PFPWIN_TYPE_X);
    pw->setName("IRIS Performer");
    pw->setOriginSize(0,0,500,500/3);
    pw->setConfigFunc( pwConfig );
    pw->config();

    // Create and configure a pfChannel.
    pfChannel *chanL = new pfChannel(p);
    pfChannel *chanR = new pfChannel(p);
    pfChannel *chanF = new pfChannel(p);

    chanL->setViewport( 0.0, 0.3333, 0.0, 1.0 );
    chanF->setViewport( 0.3333, 0.6666, 0.0, 1.0 );
    chanR->setViewport( 0.6666, 1.0, 0.0, 1.0 );

    pfVec3 xyz ( 0.0, 0.0, 0.0 );
    pfVec3 hprL( 90.0, 0.0, 0.0 );
    pfVec3 hprR( -90.0, 0.0, 0.0 );
    pfVec3 hprF( 0.0, 0.0, 0.0 );

    chanL->setViewOffsets( xyz, hprL );
    chanR->setViewOffsets( xyz, hprR );
    chanF->setViewOffsets( xyz, hprF );

    chanF->setShare( PFCHAN_FOV |
                     PFCHAN_VIEW |
                     PFCHAN_NEARFAR |
                     PFCHAN_SCENE );

    chanF->attach( chanL );
    chanF->attach( chanR );
    // determine extent of scene's geometry
    pfSphere bsphere;
    root->getBound(&bsphere);

    chanF->setNearFar(0.001f, 10.0f * bsphere.radius);
    chanF->setScene(scene);
    chanF->setFOV(90.0f, 0.0f);

    pfEnable( PFEN_LIGHTING );

    // Simulate for twenty seconds.
    while ( 1 )//t < 20.0f)
    {
        pfCoord view;
        float s, c;

        // Go to sleep until next frame time.
        pfSync();

        // Initiate cull/draw for this frame.
        pfFrame();

        // Compute new view position.
        t = pfGetTime() / 2.0 ;

        pfSinCos(45.0f*t, &s, &c);
        view.hpr.set(45.0f*t, 0.0f, 0);
        view.xyz.set(
        #if 1
                0.0, 0.0, 0.0 );
        #else
                2.0f * bsphere.radius * s,
               -2.0f * bsphere.radius * c,
                0.5f * bsphere.radius );
        #endif

        chanF->setView(view.xyz, view.hpr);
    }

    // Terminate parallel processes and exit
    pfExit();
    return 0;
}

-----------------------------------------------

// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Jason M. Coposky, 3D Software Engineer
jasonc++at++elumens.com
// =-=-=-=-=-=-=-=-=-=


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Thu Mar 01 2001 - 12:15:52 PST

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