//-----------------------------------------------------------------------
void CompositorChain::preViewportUpdate(const RenderTargetViewportEvent& evt)
{
	// Only set up if there is at least one compositor enabled, and it's this viewport
    if(evt.source != mViewport || !mAnyCompositorsEnabled)
        return;

	// set original scene details from viewport
	CompositionPass* pass = mOriginalScene->getTechnique()->getOutputTargetPass()->getPass(0);
	CompositionTargetPass* passParent = pass->getParent();
	if (pass->getClearBuffers() != mViewport->getClearBuffers() ||
		pass->getClearColour() != mViewport->getBackgroundColour() ||
		passParent->getVisibilityMask() != mViewport->getVisibilityMask() ||
		passParent->getMaterialScheme() != mViewport->getMaterialScheme() ||
		passParent->getShadowsEnabled() != mViewport->getShadowsEnabled())
	{
		// recompile if viewport settings are different
		pass->setClearBuffers(mViewport->getClearBuffers());
		pass->setClearColour(mViewport->getBackgroundColour());
		passParent->setVisibilityMask(mViewport->getVisibilityMask());
		passParent->setMaterialScheme(mViewport->getMaterialScheme());
		passParent->setShadowsEnabled(mViewport->getShadowsEnabled());
		_compile();
	}

	Camera *cam = mViewport->getCamera();
	if (cam)
	{
		/// Prepare for output operation
		preTargetOperation(mOutputOperation, mViewport, cam);
	}
}
//-----------------------------------------------------------------------
void CompositorChain::createOriginalScene()
{
    /// Create "default" compositor
    /** Compositor that is used to implicitly represent the original
        render in the chain. This is an identity compositor with only an output pass:
    compositor Ogre/Scene
    {
        technique
        {
            target_output
            {
				pass clear
				{
					/// Clear frame
				}
                pass render_scene
                {
					visibility_mask FFFFFFFF
					render_queues SKIES_EARLY SKIES_LATE
                }
            }
        }
    };
    */

	mOriginalSceneScheme = mViewport->getMaterialScheme();
	String compName = "Ogre/Scene/" + mOriginalSceneScheme;
	CompositorPtr scene = CompositorManager::getSingleton().getByName(compName, ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
	if (scene.isNull())
	{
		scene = CompositorManager::getSingleton().create(compName, ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
		CompositionTechnique *t = scene->createTechnique();
		t->setSchemeName(StringUtil::BLANK);
		CompositionTargetPass *tp = t->getOutputTargetPass();
		tp->setVisibilityMask(0xFFFFFFFF);
		{
			CompositionPass *pass = tp->createPass();
			pass->setType(CompositionPass::PT_CLEAR);
		}
		{
			CompositionPass *pass = tp->createPass();
			pass->setType(CompositionPass::PT_RENDERSCENE);
			/// Render everything, including skies
			pass->setFirstRenderQueue(RENDER_QUEUE_BACKGROUND);
			pass->setLastRenderQueue(RENDER_QUEUE_SKIES_LATE);
		}


		/// Create base "original scene" compositor
		scene = CompositorManager::getSingleton().load(compName,
			ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);



	}
	mOriginalScene = OGRE_NEW CompositorInstance(scene->getSupportedTechnique(), this);
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------
void CompositorManager::initialise(void)
{
    /// Create "default" compositor
    /** Compositor that is used to implicitly represent the original
        render in the chain. This is an identity compositor with only an output pass:
    compositor Ogre/Scene
    {
        technique
        {
            target_output
            {
				pass clear
				{
					/// Clear frame
				}
                pass render_scene
                {
					visibility_mask FFFFFFFF
					render_queues SKIES_EARLY SKIES_LATE
                }
            }
        }
    };
    */
    CompositorPtr scene = create("Ogre/Scene", ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
    CompositionTechnique *t = scene->createTechnique();
    CompositionTargetPass *tp = t->getOutputTargetPass();
    tp->setVisibilityMask(0xFFFFFFFF);
	{
		CompositionPass *pass = tp->createPass();
		pass->setType(CompositionPass::PT_CLEAR);
	}
	{
		CompositionPass *pass = tp->createPass();
		pass->setType(CompositionPass::PT_RENDERSCENE);
		/// Render everything, including skies
		pass->setFirstRenderQueue(RENDER_QUEUE_SKIES_EARLY);
		pass->setLastRenderQueue(RENDER_QUEUE_SKIES_LATE);
	}

}
Exemplo n.º 4
0
//-----------------------------------------------------------------------
void CompositorChain::createOriginalScene()
{
    /// Create "default" compositor
    /** Compositor that is used to implicitly represent the original
        render in the chain. This is an identity compositor with only an output pass:
    compositor Ogre/Scene
    {
        technique
        {
            target_output
            {
    			pass clear
    			{
    				/// Clear frame
    			}
                pass render_scene
                {
    				visibility_mask FFFFFFFF
    				render_queues SKIES_EARLY SKIES_LATE
                }
            }
        }
    };
    */

    // If two viewports use the same scheme but differ in settings like visibility masks, shadows, etc we don't
    // want compositors to share their technique.  Otherwise both compositors will have to recompile every time they
    // render.  Thus we generate a unique compositor per viewport.
    String compName("Ogre/Scene/");
    compName += StringConverter::toString((intptr_t)mViewport);

    mOriginalSceneScheme = mViewport->getMaterialScheme();
    CompositorPtr scene = CompositorManager::getSingleton().getByName(compName, ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
    if (scene.isNull())
    {
        scene = CompositorManager::getSingleton().create(compName, ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
        CompositionTechnique *t = scene->createTechnique();
        t->setSchemeName(StringUtil::BLANK);
        CompositionTargetPass *tp = t->getOutputTargetPass();
        tp->setVisibilityMask(0xFFFFFFFF);
        {
            CompositionPass *pass = tp->createPass();
            pass->setType(CompositionPass::PT_CLEAR);
        }
        {
            CompositionPass *pass = tp->createPass();
            pass->setType(CompositionPass::PT_RENDERSCENE);
            /// Render everything, including skies
            pass->setFirstRenderQueue(RENDER_QUEUE_BACKGROUND);
            pass->setLastRenderQueue(RENDER_QUEUE_SKIES_LATE);
        }


        /// Create base "original scene" compositor
        scene = CompositorManager::getSingleton().load(compName,
                ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);



    }
    mOriginalScene = OGRE_NEW CompositorInstance(scene->getSupportedTechnique(), this);
}