Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9491 for code/branches/shaders


Ignore:
Timestamp:
Dec 4, 2012, 2:04:46 PM (12 years ago)
Author:
davidsa
Message:

FIX: fixed light intensity being affected in a weird way by the distance to the light source, and weird scaling artifacts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/shaders/src/orxonox/graphics/LensFlare.cc

    r9466 r9491  
    8585        this->occlusionBillboard_ = new Billboard(this);
    8686        this->occlusionBillboard_->setMaterial("lensflare/hoq");
    87         this->occlusionBillboard_->setPosition(this->getPosition());
    8887        this->occlusionBillboard_->setVisible(false);
    8988        this->occlusionBillboard_->disableFrustumCulling();
     
    9392        Billboard* burst = new Billboard(this);
    9493        burst->setMaterial("lensflare/burst");
    95         burst->setPosition(this->getPosition());
    9694        burst->disableFrustumCulling();
    9795        burst->setVisible(true);
     
    10098        Billboard* bursthalo = new Billboard(this);
    10199        bursthalo->setMaterial("lensflare/bursthalo");
    102         bursthalo->setPosition(this->getPosition());
    103100        bursthalo->disableFrustumCulling();
    104101        bursthalo->setVisible(true);
     
    107104        bursthalo = new Billboard(this);
    108105        bursthalo->setMaterial("lensflare/halo1");
    109         bursthalo->setPosition(this->getPosition());
    110106        bursthalo->disableFrustumCulling();
    111107        bursthalo->setVisible(true);
     
    114110        bursthalo = new Billboard(this);
    115111        bursthalo->setMaterial("lensflare/halo2");
    116         bursthalo->setPosition(this->getPosition());
    117112        bursthalo->disableFrustumCulling();
    118113        bursthalo->setVisible(true);
     
    121116        bursthalo = new Billboard(this);
    122117        bursthalo->setMaterial("lensflare/halo3");
    123         bursthalo->setPosition(this->getPosition());
    124118        bursthalo->disableFrustumCulling();
    125119        bursthalo->setVisible(true);
     
    143137        int i=0;
    144138        float step=0.0f;
    145         Vector3 position=CameraManager::getInstance().getActiveCamera()->getOgreCamera()->getDerivedPosition();
    146139        for(std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++) {
    147140            Billboard* billboard=static_cast<Billboard*>(*it);
    148             billboard->setPosition(this->getPosition()-viewDirection*step);
     141            billboard->setPosition(-viewDirection*step);
    149142            billboard->setVisible(lightIsVisible);
    150             billboard->setDefaultDimensions((i<0?0.5f:1.0f)*(i>2?0.25f:1.0f)*dimension*std::pow((1.0f-step),-1.0f),(i<0?0.5f:1.0f)*(i>2?0.25f:1.0f)*dimension*std::pow((1.0f-step),-1.0f));
     143            billboard->setDefaultDimensions((i==0?0.5f:1.0f)*(i>2?0.25f:1.0f)*dimension*std::pow((1.0f-step),-1.0f),(i==0?0.5f:1.0f)*(i>2?0.25f:1.0f)*dimension*std::pow((1.0f-step),-1.0f));
    151144            step=0.25f*(i>2?(i-2):0);
    152145            i++;
     
    168161            if(i==2)
    169162            {
    170                 this->colour_->a*=0.5f;
     163                this->colour_->a*=0.33f;
    171164            }
    172165            Billboard* billboard=static_cast<Billboard*>(*it);
     
    187180    {
    188181        Ogre::Camera* camera=CameraManager::getInstance().getActiveCamera()->getOgreCamera();
    189         Vector3 position = this->getPosition();
     182        Vector3 position = this->getWorldPosition();
    190183        Vector3 nX = camera->getDerivedOrientation().xAxis().normalisedCopy();
    191184        Vector3 nY = camera->getDerivedOrientation().yAxis().normalisedCopy();
     
    212205        {
    213206            Ogre::Camera* camera=CameraManager::getInstance().getActiveCamera()->getOgreCamera(); //get active Ogre Camera Instance, so we can check whether the light source is visible
    214             this->cameraDistance_=camera->getPosition().distance(this->getPosition());
     207            this->cameraDistance_=camera->getDerivedPosition().distance(this->getPosition());
    215208            float dimension=this->cameraDistance_*this->scale_;
    216209            if(!this->fadeOnViewBorder_)
     
    218211                this->fadeResolution_=3;//this is so we can still determine when the billboard has left the screen
    219212            }
    220             unsigned int pointCount=this->getPointCount(dimension*0.5f);
    221             Vector3 viewDirection=this->getPosition()-camera->getDerivedPosition()-camera->getDerivedDirection()*this->cameraDistance_;
     213            unsigned int pointCount=this->getPointCount(dimension*0.25f*this->scale_);
     214            Vector3 viewDirection=this->getWorldPosition()-camera->getDerivedPosition()-camera->getDerivedDirection()*this->cameraDistance_;
    222215            updateBillboardStates(viewDirection,dimension,pointCount>0);
    223216            if(pointCount>0) {
    224                 Ogre::Sphere* sphere=new Ogre::Sphere(this->getPosition(),dimension*0.25f);
     217                Ogre::Sphere* sphere=new Ogre::Sphere(this->getPosition(),dimension*0.25f*this->scale_);
    225218                float left, right, top, bottom;
    226219                camera->projectSphere(*sphere,&left,&top,&right,&bottom);//approximate maximum pixel count of billboard with a sphere
Note: See TracChangeset for help on using the changeset viewer.