Пример #1
0
//-----------------------------------------------------------------------
CompositorInstance *CompositorManager::addCompositor(Viewport *vp, const String &compositor, int addPosition)
{
    CompositorPtr comp = getByName(compositor);
    if(comp.isNull())
        return 0;
    CompositorChain *chain = getCompositorChain(vp);
    return chain->addCompositor(comp, addPosition==-1 ? CompositorChain::LAST : (size_t)addPosition);
}
//-----------------------------------------------------------------------
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);
}
Пример #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);
	}

}
Пример #4
0
        void _init(void)
        {
            CompositorPtr compositor = CompositorManager::getSingleton().create(
                _theType(), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
			CompositionTechnique *t;
            CompositionTechnique::TextureDefinition *td;
            CompositionTargetPass *tp;
            CompositionPass *pass;

            t = compositor->createTechnique();
            td = t->createTextureDefinition("scene");
            td->width.viewport = 1;
            td->height.viewport = 1;
            td->format = PF_X8R8G8B8;
            td = t->createTextureDefinition("heat");
            td->width.viewport = 0.5;
            td->height.viewport = 0.5;
            td->format = PF_X8R8G8B8;

            tp = t->createTargetPass();
            tp->setInputMode(CompositionTargetPass::IM_PREVIOUS);
            tp->setOutputName("scene");

            tp = t->createTargetPass();
			tp->setInputMode(CompositionTargetPass::IM_NONE);
            tp->setOutputName("heat");
            pass = tp->createPass();
            pass->setType(CompositionPass::PT_RENDERQUAD);
            pass->setMaterialName("PostFilters/HeatVision/LightToHeat");
            pass->setInput(0, "scene");
            pass->setIdentifier(0xDEADBADE);

            tp = t->getOutputTargetPass();
			tp->setInputMode(CompositionTargetPass::IM_NONE);
            pass = tp->createPass();
            pass->setType(CompositionPass::PT_RENDERQUAD);
            pass->setMaterialName("PostFilters/HeatVision/Blur");
            pass->setInput(0, "heat");
        }
//-----------------------------------------------------------------------
CompositorInstance* CompositorChain::addCompositor(CompositorPtr filter, size_t addPosition, const String& scheme)
{
	// Init on demand
	if (!mOriginalScene)
	{
		mViewport->getTarget()->addListener(this);
		
		/// Create base "original scene" compositor
		CompositorPtr base = CompositorManager::getSingleton().load("Ogre/Scene",
			ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME);
		mOriginalScene = OGRE_NEW CompositorInstance(base->getSupportedTechnique(), this);
	}


	filter->touch();
    CompositionTechnique *tech = filter->getSupportedTechnique(scheme);
	if(!tech)
	{
		/// Warn user
		LogManager::getSingleton().logMessage(
			"CompositorChain: Compositor " + filter->getName() + " has no supported techniques.", LML_CRITICAL
			);
		return 0;
	}
    CompositorInstance *t = OGRE_NEW CompositorInstance(tech, this);
    
    if(addPosition == LAST)
        addPosition = mInstances.size();
    else
        assert(addPosition <= mInstances.size() && "Index out of bounds.");
    mInstances.insert(mInstances.begin()+addPosition, t);
    
    mDirty = true;
	mAnyCompositorsEnabled = true;
    return t;
}
Пример #6
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);
}
Пример #7
0
        void _init(void)
        {
            CompositorPtr compositor = CompositorManager::getSingleton().create(
                _theType(), ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
			CompositionTechnique *t;
            CompositionTechnique::TextureDefinition *td;
            CompositionTargetPass *tp;
            CompositionPass *pass;

            t = compositor->createTechnique();
            td = t->createTextureDefinition("scene");
            td->width.viewport = 1;
            td->height.viewport = 1;
            td->format = PF_X8R8G8B8;
            td = t->createTextureDefinition("blur0");
            td->width.viewport = 0.5;
            td->height.viewport = 0.5;
            td->format = PF_X8R8G8B8;
            td = t->createTextureDefinition("blur1");
            td->width.viewport = 0.5;
            td->height.viewport = 0.5;
            td->format = PF_X8R8G8B8;

            tp = t->createTargetPass();
            tp->setInputMode(CompositionTargetPass::IM_PREVIOUS);
            tp->setOutputName("scene");

            tp = t->createTargetPass();
			tp->setInputMode(CompositionTargetPass::IM_NONE);
            tp->setOutputName("blur0");
            pass = tp->createPass();
            pass->setType(CompositionPass::PT_RENDERQUAD);
            pass->setMaterialName("PostFilters/Floodlighting/DownSample");
            pass->setInput(0, "scene");

            tp = t->createTargetPass();
			tp->setInputMode(CompositionTargetPass::IM_NONE);
            tp->setOutputName("blur1");
            pass = tp->createPass();
            pass->setType(CompositionPass::PT_RENDERQUAD);
            pass->setMaterialName("PostFilters/Floodlighting/BlurHorizontal");
            pass->setInput(0, "blur0");

            tp = t->createTargetPass();
			tp->setInputMode(CompositionTargetPass::IM_NONE);
            tp->setOutputName("blur1");
            pass = tp->createPass();
            pass->setType(CompositionPass::PT_RENDERQUAD);
            pass->setMaterialName("PostFilters/Floodlighting/BlurVertical");
            pass->setInput(0, "blur0");

            tp = t->getOutputTargetPass();
			tp->setInputMode(CompositionTargetPass::IM_NONE);
            pass = tp->createPass();
            pass->setType(CompositionPass::PT_RENDERQUAD);
            pass->setMaterialName("PostFilters/Floodlighting/Blend");
            pass->setInput(0, "scene");
            pass->setInput(1, "blur1");
            pass->setIdentifier(0xDEADBADE);

            mBlurAmount = 0.2f;
            mShineAmount = 0.3f;
            // receive default parameters from material script
            if (!pass->getMaterial().isNull())
            {
                GpuProgramParametersSharedPtr parameters = pass->getMaterial()->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
#if OGRE_VERSION >= 0x010300
                const GpuConstantDefinition* def;
                
                def = parameters->_findNamedConstantDefinition("blur_amount");
                if (def)
                    parameters->_readRawConstants(def->physicalIndex, 1, &mBlurAmount);
                def = parameters->_findNamedConstantDefinition("shine_amount");
                if (def)
                    parameters->_readRawConstants(def->physicalIndex, 1, &mShineAmount);
#else
                GpuProgramParameters::RealConstantEntry* entry;

                entry = parameters->getNamedRealConstantEntry("blur_amount");
                if (entry && entry->isSet)
                    mBlurAmount = entry->val[0];

                entry = parameters->getNamedRealConstantEntry("shine_amount");
                if (entry && entry->isSet)
                    mShineAmount = entry->val[0];
#endif
            }
        }