//===============================================================================================================================
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();
}
bool GraphicsClass::Render()
{
    D3DXMATRIX worldMatrix, viewMatrix, projectionMatrix, translateMatrix;
    float posX, posY, posZ;


    // First render the scene to a texture.
    RenderSceneToTexture();

    // Next render the shadowed scene in black and white.
    RenderBlackAndWhiteShadows();

    // Then down sample the black and white scene texture.
    DownSampleTexture();

    // Perform a horizontal blur on the down sampled texture.
    RenderHorizontalBlurToTexture();

    // Now perform a vertical blur on the texture.
    RenderVerticalBlurToTexture();

    // Finally up sample the final blurred render to texture that can now be used in the soft shadow shader.
    UpSampleTexture();

    // Clear the buffers to begin the scene.
    m_D3D->BeginScene(0.0f, 0.0f, 0.0f, 1.0f);

    // Generate the view matrix based on the camera's position.
    m_Camera->Render();

    // Get the world, view, and projection matrices from the camera and d3d objects.
    m_D3D->GetWorldMatrix(worldMatrix);
    m_Camera->GetViewMatrix(viewMatrix);
    m_D3D->GetProjectionMatrix(projectionMatrix);

    // Setup the translation matrix for the cube model.
    m_CubeModel->GetPosition(posX, posY, posZ);
    D3DXMatrixTranslation(&worldMatrix, posX, posY, posZ);

    // Render the cube model using the soft shadow shader.
    m_CubeModel->Render(m_D3D->GetDevice());
    m_SoftShadowShader->Render(m_D3D->GetDevice(), m_CubeModel->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_CubeModel->GetTexture(),
                               m_UpSampleTexure->GetShaderResourceView(), m_Light->GetPosition(), m_Light->GetAmbientColor(), m_Light->GetDiffuseColor());

    // Reset the world matrix.
    m_D3D->GetWorldMatrix(worldMatrix);

    // Setup the translation matrix for the sphere model.
    m_SphereModel->GetPosition(posX, posY, posZ);
    D3DXMatrixTranslation(&worldMatrix, posX, posY, posZ);

    // Render the sphere model using the soft shadow shader.
    m_SphereModel->Render(m_D3D->GetDevice());
    m_SoftShadowShader->Render(m_D3D->GetDevice(), m_SphereModel->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_SphereModel->GetTexture(),
                               m_UpSampleTexure->GetShaderResourceView(), m_Light->GetPosition(), m_Light->GetAmbientColor(), m_Light->GetDiffuseColor());

    // Reset the world matrix.
    m_D3D->GetWorldMatrix(worldMatrix);

    // Setup the translation matrix for the ground model.
    m_GroundModel->GetPosition(posX, posY, posZ);
    D3DXMatrixTranslation(&worldMatrix, posX, posY, posZ);

    // Render the ground model using the soft shadow shader.
    m_GroundModel->Render(m_D3D->GetDevice());
    m_SoftShadowShader->Render(m_D3D->GetDevice(), m_GroundModel->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_GroundModel->GetTexture(),
                               m_UpSampleTexure->GetShaderResourceView(), m_Light->GetPosition(), m_Light->GetAmbientColor(), m_Light->GetDiffuseColor());

    // Present the rendered scene to the screen.
    m_D3D->EndScene();

    return true;
}