void CMiniViewportEngineRenderArea::InitSceneMaterials() { if ( m_ScreenBuffer ) return; if ( g_pMaterialSystem->IsTextureLoaded( "_rt_LayoffResult" ) ) { ITexture *pTexture = g_pMaterialSystem->FindTexture( "_rt_LayoffResult", TEXTURE_GROUP_RENDER_TARGET ); m_ScreenBuffer.Init( pTexture ); } else { // For now, layoff dimensions match aspect of back buffer int nBackBufferWidth, nBackBufferHeight; g_pMaterialSystem->GetBackBufferDimensions( nBackBufferWidth, nBackBufferHeight ); float flAspect = nBackBufferWidth / (float)nBackBufferHeight; int nPreviewWidth = min( DEFAULT_PREVIEW_WIDTH, nBackBufferWidth ); int nPreviewHeight = ( int )( nPreviewWidth / flAspect + 0.5f ); g_pMaterialSystem->BeginRenderTargetAllocation(); // Begin allocating RTs which IFM can scribble into // LDR final result of either HDR or LDR rendering m_ScreenBuffer.Init( g_pMaterialSystem->CreateNamedRenderTargetTextureEx2( "_rt_LayoffResult", nPreviewWidth, nPreviewHeight, RT_SIZE_OFFSCREEN, g_pMaterialSystem->GetBackBufferFormat(), MATERIAL_RT_DEPTH_SHARED, TEXTUREFLAGS_BORDER ) ); g_pMaterialSystem->EndRenderTargetAllocation(); // End allocating RTs which IFM can scribble into } KeyValues *pVMTKeyValues = NULL; pVMTKeyValues= new KeyValues( "UnlitGeneric" ); pVMTKeyValues->SetString( "$basetexture", m_ScreenBuffer->GetName() ); pVMTKeyValues->SetInt( "$nofog", 1 ); m_ScreenMaterial.Init( "MiniViewportEngineRenderAreaSceneMaterial", pVMTKeyValues ); m_ScreenMaterial->Refresh(); }