예제 #1
0
	void CBlurCompositor::gaussBlur(ISceneManager* smgr, bool lastCompositor)
	{
		IVideoDriver* driver = smgr->getVideoDriver();
		ITextureManager* tmgr = ITextureManager::getInstance();

		IRenderTarget* input = driver->getRenderTarget();
		IRenderTarget* output = tmgr->getTempRenderTarget(input->getWidth(), input->getHeight(), input->getFormat());

		IMeshNode* quad = smgr->getQuadNode();
		quad->setMaterial(&mMaterial);

		IPipelineManager* pipelineManager = IPipelineManager::getInstance();
		IPipeline* vblurPipeline = pipelineManager->get("gf/gauss_vertical_blur");
		IPipeline* hblurPipeline = pipelineManager->get("gf/gauss_horizontal_blur");

		// render pass - 1
		for (u32 i = 0; i < mPassCount - 1; i++)
		{
			// vertical blur
			mMaterial.setPipeline(vblurPipeline);
			renderQuad(driver, smgr, quad, input, output);

			// horizontal blur
			mMaterial.setPipeline(hblurPipeline);
			renderQuad(driver, smgr, quad, output, input);
		}

		// render last pass
		mMaterial.setPipeline(vblurPipeline);
		renderQuad(driver, smgr, quad, input, output);

		mMaterial.setPipeline(hblurPipeline);
		if (lastCompositor)
		{
			renderQuad(driver, smgr, quad, output, nullptr);
			tmgr->releaseTempRenderTarget(output);
		}
		else
		{
			renderQuad(driver, smgr, quad, output, input);
		}

		tmgr->releaseTempRenderTarget(input);
	}
예제 #2
0
	void CBlurCompositor::squareBlur(ISceneManager* smgr, bool lastCompositor)
	{
		IVideoDriver* driver = smgr->getVideoDriver();
		ITextureManager* tmgr = ITextureManager::getInstance();

		IRenderTarget* input = driver->getRenderTarget();
		IRenderTarget* output = nullptr;

		IMeshNode* quad = smgr->getQuadNode();
		quad->setMaterial(&mMaterial);

		if (mPassCount == 1)
		{
			if (!lastCompositor)
				output = tmgr->getTempRenderTarget(input->getWidth(), input->getHeight(), input->getFormat());

			renderQuad(driver, smgr, quad, input, output);
			tmgr->releaseTempRenderTarget(input);
		}
		else
		{
			output = tmgr->getTempRenderTarget(input->getWidth(), input->getHeight(), input->getFormat());

			// render pass - 1 
			for (u32 i = 0; i < mPassCount - 1; i++)
			{
				renderQuad(driver, smgr, quad, input, output);
				std::swap(input, output);
			}

			// render the last pass
			if (!lastCompositor)
			{
				renderQuad(driver, smgr, quad, input, output);
			}
			else
			{
				renderQuad(driver, smgr, quad, input, nullptr);
				tmgr->releaseTempRenderTarget(output);
			}

			tmgr->releaseTempRenderTarget(input);
		}
	}