[BUG] Skybox looses textures in ortho-mode

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

[BUG] Skybox looses textures in ortho-mode

Post by gerdb »

Hi,

i have a strange issue when i switch my camera to ortho mode (per GUI Editor)
the skybox "looses" textures (some sides are just black, which is my clearColor in beginScene())

http://benjaminhampe.be.ohost.de/Irrlic ... ox_test.7z

here the bottom tex is lost after pressing Ortho On/Off twice

Image

- Can that be related to Near And Far Value of Camera, which are used by SkyBox to render, and maybe corrupted by Ortho-Mode?
Last edited by gerdb on Tue Jul 24, 2012 9:24 pm, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: [BUG] Skybox looses textures in ortho-mode

Post by hybrid »

Yeah, near and far value could be a problem. The ortho cam is only seldomly used, so it's not well tested. I hope to have time for some test cases after 1.8 is out.
The GUI problem seems unrelated and thus should be moved to a different topic.
gerdb
Posts: 194
Joined: Wed Dec 02, 2009 8:21 pm
Location: Dresden, Germany

Re: [BUG] Skybox looses textures in ortho-mode

Post by gerdb »

Hi,

I disabled the whole if else code in CSkyboxSceneNode::render(), leaving only the normal way to render the skybox, it works!

may i add that to my previous Skybox Patch?

Code: Select all

 
//! renders the node.
void CSkyBoxSceneNode::render()
{
    video::IVideoDriver* driver = SceneManager->getVideoDriver();
    scene::ICameraSceneNode* camera = SceneManager->getActiveCamera();
 
    if (!camera || !driver)
        return;
 
//  if ( !camera->isOrthogonal() )
//  {
        // draw perspective skybox
 
        core::matrix4 translate(AbsoluteTransformation);
        translate.setTranslation(camera->getAbsolutePosition());
 
        // Draw the sky box between the near and far clip plane
        const f32 viewDistance = (camera->getNearValue() + camera->getFarValue()) * 0.5f;
        core::matrix4 scale;
        scale.setScale(core::vector3df(viewDistance, viewDistance, viewDistance));
 
        driver->setTransform(video::ETS_WORLD, translate * scale);
 
        for (s32 i=0; i<6; ++i)
        {
            driver->setMaterial(Material[i]);
            driver->drawIndexedTriangleFan(&Vertices[i*4], 4, Indices, 2);
        }
//  }
//  else
//  {
//      // draw orthogonal skybox,
//      // simply choose one texture and draw it as 2d picture.
//      // there could be better ways to do this, but currently I think this is ok.
//
//      core::vector3df lookVect = camera->getTarget() - camera->getAbsolutePosition();
//      lookVect.normalize();
//      core::vector3df absVect( core::abs_(lookVect.X),
//                   core::abs_(lookVect.Y),
//                   core::abs_(lookVect.Z));
//
//      int idx = 0;
//
//      if ( absVect.X >= absVect.Y && absVect.X >= absVect.Z )
//      {
//          // x direction
//          idx = lookVect.X > 0 ? 0 : 2;
//      }
//      else
//      if ( absVect.Y >= absVect.X && absVect.Y >= absVect.Z )
//      {
//          // y direction
//          idx = lookVect.Y > 0 ? 4 : 5;
//      }
//      else
//      if ( absVect.Z >= absVect.X && absVect.Z >= absVect.Y )
//      {
//          // z direction
//          idx = lookVect.Z > 0 ? 1 : 3;
//      }
//
//      video::ITexture* tex = Material[idx].getTexture(0);
//
//      if ( tex )
//      {
//          core::rect<s32> rctDest(core::position2d<s32>(-1,0),
//                                  core::dimension2di(driver->getCurrentRenderTargetSize()));
//          core::rect<s32> rctSrc(core::position2d<s32>(0,0),
//                                  core::dimension2di(tex->getSize()));
//
//          driver->draw2DImage(tex, rctDest, rctSrc);
//      }
//  }
}
 
 
i'll move my 2nd issue to a new topic

thx
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: [BUG] Skybox looses textures in ortho-mode

Post by hendu »

Please do separate patches for separate issues.
Post Reply