Show
Ignore:
Timestamp:
04/12/06 11:42:25 (8 years ago)
Author:
robert
Message:

Moved common uniforms to top of precipitation subgraph.

Added a run of the SpatializeGroupVisitor? to create a balanced subgraph.

Changed the quad to particle transistion distance from 100 to 50m.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgprecipitation/osgprecipitation.cpp

    r5084 r5085  
    348348    osg::LOD* lod = new osg::LOD; 
    349349     
    350     float nearDistance = 100.0; 
     350    float nearDistance = 50.0; 
    351351    float farDistance = 200.0; 
    352352     
     
    404404 
    405405 
     406         
     407        stateset->addUniform(position_Uniform); // vec3 
     408        stateset->addUniform(dv_i_Uniform); // vec3 could be float  
     409        stateset->addUniform(dv_j_Uniform); // vec3 could be float 
     410        stateset->addUniform(dv_k_Uniform); // vec3 
     411        stateset->addUniform(inversePeriodUniform); // float 
     412        stateset->addUniform(startTime); // float 
     413         
     414 
     415        // make it render after the normal transparent bin 
     416        stateset->setRenderBinDetails(11,"DepthSortedBin"); 
     417         
     418#if 0 
    406419        stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF); 
    407420        stateset->setMode(GL_BLEND, osg::StateAttribute::ON); 
    408421         
    409         stateset->addUniform(position_Uniform); 
    410         stateset->addUniform(dv_i_Uniform); 
    411         stateset->addUniform(dv_j_Uniform); 
    412         stateset->addUniform(dv_k_Uniform); 
    413         stateset->addUniform(inversePeriodUniform); 
    414         stateset->addUniform(startTime); 
    415         stateset->addUniform(new osg::Uniform("particleColour", osg::Vec4(0.6,0.6,0.6,1.0))); 
    416          
    417422        static osg::Uniform* baseTextureSampler = new osg::Uniform("baseTexture",0); 
    418423        stateset->addUniform(baseTextureSampler); 
     
    420425        static osg::Texture2D* texture = new osg::Texture2D(createSpotLightImage(osg::Vec4(1.0f,1.0f,1.0f,1.0f),osg::Vec4(1.0f,1.0f,1.0f,0.0f),32,1.0)); 
    421426        stateset->setTextureAttribute(0, texture); 
    422  
    423         // make it render after the normal transparent bin 
    424         stateset->setRenderBinDetails(11,"DepthSortedBin"); 
    425  
     427         
     428        stateset->addUniform(new osg::Uniform("particleColour", osg::Vec4(0.6,0.6,0.6,1.0))); 
     429        stateset->addUniform(new osg::Uniform("particleSize", 0.01f)); 
     430         
    426431        osg::Uniform* previousModelViewUniform = new osg::Uniform("previousModelViewMatrix",osg::Matrix()); 
    427432        stateset->addUniform(previousModelViewUniform); 
    428433        lod->setCullCallback(new CullCallback(previousModelViewUniform)); 
    429  
     434#endif 
    430435    } 
    431436 
     
    437442{ 
    438443     
    439     unsigned int numX = 50; 
    440     unsigned int numY = 50; 
     444    unsigned int numX = 80; 
     445    unsigned int numY = 80; 
    441446    unsigned int numCells = numX*numY; 
    442447    unsigned int numParticlesPerCell = numParticles/numCells; 
     
    466471        }         
    467472    } 
     473     
     474#if 1     
     475    osgUtil::Optimizer::SpatializeGroupsVisitor sgv; 
     476    group->accept(sgv); 
     477    sgv.divide(); 
     478#endif     
     479 
     480#if 1 
     481    osg::StateSet* stateset = group->getOrCreateStateSet(); 
     482 
     483    stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF); 
     484    stateset->setMode(GL_BLEND, osg::StateAttribute::ON); 
     485 
     486    osg::Uniform* baseTextureSampler = new osg::Uniform("baseTexture",0); 
     487    stateset->addUniform(baseTextureSampler); 
     488 
     489    osg::Texture2D* texture = new osg::Texture2D(createSpotLightImage(osg::Vec4(1.0f,1.0f,1.0f,1.0f),osg::Vec4(1.0f,1.0f,1.0f,0.0f),32,1.0)); 
     490    stateset->setTextureAttribute(0, texture); 
     491 
     492    stateset->addUniform(new osg::Uniform("particleColour", osg::Vec4(0.6,0.6,0.6,1.0))); 
     493    stateset->addUniform(new osg::Uniform("particleSize", 0.01f)); 
     494   
     495    osg::Uniform* previousModelViewUniform = new osg::Uniform("previousModelViewMatrix",osg::Matrix()); 
     496    stateset->addUniform(previousModelViewUniform); 
     497     
     498    group->setCullCallback(new CullCallback(previousModelViewUniform)); 
     499#endif 
     500 
    468501    return group; 
    469502}