Exemplo n.º 1
0
void GlowEffect::RenderToWindow(OrthoWindow *orthoWindow){
	pOrthoWindow = orthoWindow;

	// Down sample the render texture to a smaller sized texture.
	DownSampleTexture();

	RetainTextureBrightness();

	// Render the blur effect to the texture
	RenderBlurToTexture();

	// Up sample the final blurred render texture to screen size again.
	UpSampleTexture();

	// Render the blurred up sampled render texture to the screen.
	Render2DTextureScene();
}
//===============================================================================================================================
void BlurredEnvironment::Render()
{
	if( Quickwire() )
	{
		m_pCube->SetWireframe( true );
		m_pNoBlurCube->SetWireframe( true );
		m_D3DSystem->TurnOnWireframe();
	}

	m_D3DSystem->TurnOnZBuffer();
	
	// Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing.
	ZShadeSandboxMesh::MeshRenderParameters mrp;
	mrp.camera = m_CameraSystem;
	m_pCube->Render(mrp);
	//m_pNoBlurCube->Render(mCamera, TriangleList, false, true);

	/*if (m_VertextProcessEnable)
	{
		ID3D11ShaderResourceView* pInputSRV = mD3DSystem->GetColorRenderTarget()->GetSRV();
		DepthStencilBuffer* pDepth = mD3DSystem->GetDepthStencilBuffer();
		ID3D11RenderTargetView* pOutputRTV = mD3DSystem->GetBackBufferRTV();

		m_pSimplePP->Render(pInputSRV, pOutputRTV);

		Reset the backbuffer and viewports after Vertext processing and turn the z buffer back on
		mD3DSystem->SetBackBufferRenderTarget(m_VertextProcessEnable);
		mD3DSystem->ResetViewport();
		mD3DSystem->TurnOnZBuffer();
	}*/

	RenderSceneToTexture();
	DownSampleTexture();
	RenderHorizontalBlurToTexture();
	RenderVerticalBlurToTexture();
	UpSampleTexture();
	Render2DTextureScene();
}
Exemplo n.º 3
0
bool GraphicsManager::RenderPostProcessing(Camera* cam)
{
	bool result;

	// First render the scene to a render texture.
	result = RenderSceneToTexture(cam);
	if(!result)
	{
		return false;
	}

	//// Next down sample the render texture to a smaller sized texture.
	//result = DownSampleTexture(cam, m_RenderTexture);
	//if(!result)
	//{
	//	return false;
	//}

	//Render glow map
	result = CreateGlowMap(cam, m_RenderTexture, D3DXVECTOR4(0.33f, 0.33f, 0.33f, 0.0f));
	if(!result)
	{
		return false;
	}

	for (int pass = 0; pass < 1; pass++)
	{
		//// Perform a convolution pass.
		//result = ApplyConvolutionTexture(cam, m_RenderTexture, D3DXVECTOR4(0.0f, -1.0f, 0.0f, 0.0f), D3DXVECTOR4(-1.0f, 5.0f, -1.0f, 0.0f), D3DXVECTOR4(0.0f, -1.0f, 0.0f, 0.0f));
		//if(!result)
		//{
		//	return false;
		//}

		// Horizontal blur the down sampled texture.
		result = BlurTextureHorizontally(cam, m_GlowMapTexture);
		if(!result)
		{
			return false;
		}

		// Vertical blur the horizontal blur texture.
		result = BlurTextureVertically(cam, m_HorizontalBlurTexture);
		if(!result)
		{
			return false;
		}
	}

	// Up sample the final blurred render texture to screen size again.
	result = UpSampleTexture(cam, m_VerticalBlurTexture);
	if(!result)
	{
		return false;
	}

	RenderTestToTexture(cam, m_MiniMapTexture);
	result = ApplyConvolutionTexture(cam, m_MiniMapTexture, m_convolutionRow1, m_convolutionRow2, m_convolutionRow3);
	if(!result)
	{
			return false;
	}

	//Perform glow on texture
	result = GlowTexture(cam, m_RenderTexture, 1.1f);
	if(!result)
	{
		return false;
	}

	// Render the blurred up sampled render texture to the screen.
	result = Render2DTextureScene(cam, m_GlowTexture);
	if(!result)
	{
		return false;
	}
	
	return true;
}