Example #1
0
		virtual Ogre::CompositorWorkspace* setupCompositor()
		{
			//We reuse the ShadowMapDebugging sample's workspace. Pretty handful.
			Ogre::CompositorManager2 *compositorManager = mpRoot->getCompositorManager2();
			return compositorManager->addWorkspace(mpSceneManager, mpRenderWindow, mpCamera,
				"Test2Workspace",
				//				"ShadowMapDebuggingWorkspace", // KYLE :: ORIG 
				true);
		}
Example #2
0
	void OgreModule::multiViewportWorkspace(const std::vector<OgViewport*>& viewports, Ogre::RenderTarget* target)
	{
		Ogre::CompositorManager2* compositorManager = mOgreRoot.getCompositorManager2();
		Ogre::CompositorNodeDef* nodeDef = compositorManager->addNodeDefinition("AutoGen " + (Ogre::IdString("MultiViewportWorkspace") + Ogre::IdString("/Node")).getReleaseText());

		//Input texture
		nodeDef->addTextureSourceName("WindowRT", 0, Ogre::TextureDefinitionBase::TEXTURE_INPUT);
		nodeDef->setNumTargetPass(1);
		{
			Ogre::CompositorTargetDef* targetDef = nodeDef->addTargetPass("WindowRT");
			targetDef->setNumPasses(2 * viewports.size());
			{
				for(OgViewport* viewport : viewports)
				{
					{
						Ogre::CompositorPassClearDef* passClear = static_cast<Ogre::CompositorPassClearDef*>(targetDef->addPass(Ogre::PASS_CLEAR));
						passClear->mColourValue = Ogre::ColourValue(0.3f, 0.3f, 0.3f);
						passClear->mVpWidth = viewport->width() / target->getWidth();
						passClear->mVpHeight = viewport->height() / target->getHeight();
						passClear->mVpLeft = viewport->left() / target->getWidth();
						passClear->mVpTop = viewport->top() / target->getHeight();
					}
					{
						Ogre::CompositorPassSceneDef* passScene = static_cast<Ogre::CompositorPassSceneDef*>(targetDef->addPass(Ogre::PASS_SCENE));
						//passScene->mShadowNode = Ogre::IdString();
						passScene->mVpWidth = viewport->width() / target->getWidth();
						passScene->mVpHeight = viewport->height() / target->getHeight();
						passScene->mVpLeft = viewport->left() / target->getWidth();
						passScene->mVpTop = viewport->top() / target->getHeight();
						passScene->mCameraName = viewport->ogreCamera()->getName();
					}
				}
			}
		}

		Ogre::CompositorWorkspaceDef* workDef = compositorManager->addWorkspaceDefinition("MultiViewportWorkspace");
		workDef->connectOutput(nodeDef->getName(), 0);

		for(OgViewport* viewport : viewports)
			compositorManager->addWorkspace(viewport->sceneManager(), target, viewport->ogreCamera(), "MultiViewportWorkspace", true);
	}
		void SetUpCustomContent()
		{
			Ogre::String CustomCameraName = "TestRenderTargetCamera";
			Ogre::String CustomTextureName = "TestRenderTargetTexture";
			Ogre::String CustomMaterialName = "CustomRenderTargetMaterial";
			Ogre::String CustomWorkSpaceName = "TestCustomRenderTargetWorkSpaceName";

			m_CustomRTTCamera = mSceneManager->createCamera(CustomCameraName);
			m_CustomRTTCamera->setPosition(0, 30, 0);
			m_CustomRTTCamera->lookAt(0, 0, 0);
			m_CustomRTTCamera->setFarClipDistance(1000);
			m_CustomRTTCamera->setNearClipDistance(0.1);

			m_CustomRenderTexture = Ogre::TextureManager::getSingleton().createManual(CustomTextureName, 
				Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 
				512, 512, 1, Ogre::PF_A8B8G8R8, Ogre::TU_RENDERTARGET);
			m_CustomRenderTexture->load();

			Ogre::RenderTexture* rtt = m_CustomRenderTexture->getBuffer(0)->getRenderTarget();


			Ogre::CompositorManager2 *compositorManager = mRoot->getCompositorManager2();

			const Ogre::IdString workspaceName(CustomWorkSpaceName);
			if( !compositorManager->hasWorkspaceDefinition( workspaceName ) )
			{
				compositorManager->createBasicWorkspaceDef( workspaceName, mBackgroundColour,
					Ogre::IdString() );
			}

			m_CustomRenderTarget = compositorManager->addWorkspace( mSceneManager, (Ogre::RenderTarget*)rtt, m_CustomRTTCamera,
					workspaceName, false );
			//m_CustomRenderTarget->setEnabled(false);			// not auto update
#if 0
			// create manual object
			Ogre::MaterialPtr CustomMaterial = Ogre::MaterialManager::getSingleton().create(CustomMaterialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
			CustomMaterial->getTechnique(0)->removeAllPasses();
			Ogre::Pass* pass = CustomMaterial->getTechnique(0)->createPass();
			Ogre::TextureUnitState* tu = pass->createTextureUnitState();
			tu->setTextureName(CustomTextureName);
#endif
			Ogre::HlmsManager *hlmsManager = Ogre::Root::getSingleton().getHlmsManager();
			Ogre::Hlms *hlms = hlmsManager->getHlms( Ogre::HLMS_UNLIT );
			Ogre::HlmsDatablock *datablock = hlms->createDatablock( CustomMaterialName, CustomMaterialName,
				Ogre::HlmsMacroblock(), Ogre::HlmsBlendblock(), Ogre::HlmsParamVec() );
			Ogre::HlmsUnlitDatablock *unlitDb = static_cast<Ogre::HlmsUnlitDatablock*>( datablock );
			unlitDb->setTexture( 0, 0, m_CustomRenderTexture );
			
#if 1
			Ogre::ManualObject* CustomManualObject = mSceneManager->createManualObject();
			CustomManualObject->begin(CustomMaterialName);
			CustomManualObject->position(-100, -100, -100);
			CustomManualObject->textureCoord(0, 0);
			CustomManualObject->position(100, -100, -100);
			CustomManualObject->textureCoord(1, 0);
			CustomManualObject->position(100, 100, -100);
			CustomManualObject->textureCoord(1, 1);
			CustomManualObject->position(-100, 100, -100);
			CustomManualObject->textureCoord(0, 1);
			CustomManualObject->quad(0, 1, 2, 3);
			CustomManualObject->end();
//			CustomManualObject->setDatablock(0, CustomMaterialName);

			Ogre::SceneNode *sceneNodeLines = mSceneManager->getRootSceneNode( Ogre::SCENE_DYNAMIC )->
				createChildSceneNode( Ogre::SCENE_DYNAMIC );
			sceneNodeLines->attachObject(CustomManualObject);
			sceneNodeLines->scale(0.4f, 0.4f, 0.4f);
			sceneNodeLines->translate(0.0f, 0.0f, 0.0f, Ogre::SceneNode::TS_WORLD);
#endif
		}
 virtual Ogre::CompositorWorkspace* setupCompositor()
 {
     Ogre::CompositorManager2 *compositorManager = mRoot->getCompositorManager2();
     return compositorManager->addWorkspace( mSceneManager, mRenderWindow, mCamera,
                                             "PbsMaterialsWorkspace", true );
 }