[2.1] Some problems with cubemap rendering

Design / architecture / roadmap discussions related to future of Ogre3D (version 2.0 and above)
Post Reply
xrgo
OGRE Expert User
OGRE Expert User
Posts: 909
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 50

[2.1] Some problems with cubemap rendering

Post by xrgo » Tue Sep 04, 2018 3:26 am

Hello, I am having some problems rendering cubemaps...

My engine has the ability to record 360 video 4k and save to a mp4 file... but that's very slow, so I came with the next solution:
I just render the equirectangular 360 (or cubemap 3x2 grid) 4k image in to another window which I open in a second 4k monitor... so I record that screen with nvidia shadowplay and it runs very fast!!

but I am having the next problems:

1) For some reason when I have more workspaces (menus, mirrors, etc) running, rendering to the secondary window doesn't work, it freezes the whole app. But it does render in to the file, so the cubemap workspaces are fine. I still have to search for more clues about this to give you.

2) I have an static shadow casted by a very far spotlight (for the static objects, since directional light can't cast static shadows), this shadow doesn't appear in my cubemap, the pssm (for the dynamic objects) does show ok. the cubemap workspace is using the same shadow node as the normal render.

3) Trying to fix this problems I updated Ogre (I was using a 5 months old version) and the problems persists... but! now I can't render cubemap using fsaa, If I use fsaa!=0 I see the same in every face, is fsaa broken for cubemaps for the current version?

here is some code:

Workspace:

Code: Select all

abstract target cubemap_target
{
	pass clear
	{
		colour_value 0.0 0.0 0.0 1
	}

	pass render_scene
	{
    shadows MainEngineShadowNode recalculate
    lod_update_list off
    //Filter stuff that shouldn't be reflected (vampires?)
    //visibility_mask      0x00000004
    overlays         off
		camera_cubemap_reorient true
	}
}

compositor_node cubeMapCaptureRenderNode
{
	in 0 cubemap

	target cubemap +X : cubemap_target { }
	target cubemap -X : cubemap_target { }
	target cubemap +Y : cubemap_target { }
	target cubemap -Y : cubemap_target { }
	target cubemap +Z : cubemap_target { }
	target cubemap -Z : cubemap_target {}
}

//CubeMap Capture Workspace
workspace cubeCaptureWorkspace
{
	connect_external 0 cubeMapCaptureRenderNode 0
}
The actual cubemap texture using the prev workspace (this is called just one time):

Code: Select all

void yCaptureManager::init360Capture(){

    Ogre::SceneManager* sceneManager = yGraphicsServices::getGraphicsSceneNodeManager().getMainSceneManager();

    mCubeCameraNode = sceneManager->getRootSceneNode()->createChildSceneNode();


    Ogre::Camera* cubeCamera = sceneManager->createCamera( "cubeCaptureCamera",true,true );
    cubeCamera->setFOVy( Ogre::Degree(90) );
    cubeCamera->setAspectRatio( 1 );
    cubeCamera->setFixedYawAxis( false );
    cubeCamera->setNearClipDistance( 0.1f );
    cubeCamera->setFarClipDistance( yGraphicsServices::getGraphicsCameraManager().getMainCamera()->getFarClipDistance()*10 ); //*10 just in case
    cubeCamera->setLodBias( FLT_MAX );

    cubeCamera->detachFromParent();
    mCubeCameraNode->attachObject(cubeCamera);


    mCubeTexture = Ogre::TextureManager::getSingletonPtr()->createManual(
                "captureCubeTexture",
                Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
                Ogre::TEX_TYPE_CUBE_MAP,
                1024,
                1024,
                0,
                Ogre::PF_R8G8B8,
                Ogre::TU_RENDERTARGET,
                nullptr,
                true,
                0
                );


    Ogre::CompositorChannelVec externalChannels( 1 );
    externalChannels[0].target = mCubeTexture->getBuffer(0)->getRenderTarget(); //Any of the render targets will do
    externalChannels[0].textures.push_back( mCubeTexture );

    mCubeWorkspace = Ogre::Root::getSingletonPtr()->getCompositorManager2()->addWorkspace(
                sceneManager,
                externalChannels,
                cubeCamera,
                "cubeCaptureWorkspace", false );

}
This one is called everytime I open the secondary window in case I change cubemap conversion mode:

Code: Select all

void yCaptureManager::initCubemapConversion( bool useRenderWindow ){

    Ogre::SceneManager* sceneManager = yGraphicsServices::getGraphicsSceneNodeManager().getMainSceneManager();


    //Use Equirectangular or CubemapCollage (aka grid)
    std::string workspaceName;
    if( mUseEquirectangular ){
        workspaceName = "CubeToEquirectangularWorkspace";

        Ogre::Pass *byPassMaterialPass = Ogre::MaterialManager::getSingletonPtr()->getByName("CubeToEquirecMat")->getTechnique(0)->getPass(0);
        byPassMaterialPass->getTextureUnitState(0)->setTexture( mCubeTexture );
    }
    else{
        workspaceName = "CubeToCollageWorkspace";

        Ogre::Pass *byPassMaterialPass = Ogre::MaterialManager::getSingletonPtr()->getByName("CubeToCollageMat")->getTechnique(0)->getPass(0);
        byPassMaterialPass->getTextureUnitState(0)->setTexture( mCubeTexture );
    }

    if( mCubemapConversionWorkspace ){
        mCubemapConversionWorkspace->setEnabled( false );
        Ogre::Root::getSingletonPtr()->getCompositorManager2()->removeWorkspace( mCubemapConversionWorkspace );
    }

    mCubemapConversionWorkspace = Ogre::Root::getSingletonPtr()->getCompositorManager2()->addWorkspace(
                    sceneManager,
                    m360RenderWindow->getOgreRenderWindow(),
                    yGraphicsServices::getGraphicsCameraManager().getMainCamera(),
                    workspaceName, false );

}
And this is how I display the window:
the m360RenderWindow is just a wraper for a qt window that contains the Ogre Window (before I created an Ogre window directly and the problems were the same)

Code: Select all

 
        //show the window
        m360RenderWindow->getMainWindow()->show();

	//create the texture if not already
        if( mCubeTexture.isNull() ){
            init360Capture();
        }
        //init workspace for converting cubemap to equirectangular o cubemapgrid	
        initCubemapConversion( true );

	//enable both cubemaps
        mCubeWorkspace->setEnabled( true );
        mCubemapConversionWorkspace->setEnabled( true );
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 909
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 50

Re: [2.1] Some problems with cubemap rendering

Post by xrgo » Wed Sep 05, 2018 4:40 am

i think solved 1). I was updating my workspaces manually (so I can skip frames) by calling:

Code: Select all

        currentWorkspace->_beginUpdate( false );
        currentWorkspace->_update();
        currentWorkspace->_endUpdate( false );
I changed it by toggling setEnabled( true/false ); and it seems to be solved
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 909
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 50

Re: [2.1] Some problems with cubemap rendering

Post by xrgo » Sun Sep 09, 2018 12:29 am

fixed 2)... I was just missing "setLightFixedToShadowMap" for the shadowNode of the cubemap workspace
0 x

Post Reply