PostProcessing::PostProcessing(video::IVideoDriver* video_driver) { // Check if post-processing is supported on this hardware m_supported = false; if( irr_driver->isGLSL() ) { m_supported = true; } //Check which texture dimensions are supported on this hardware bool nonsquare = video_driver->queryFeature(video::EVDF_TEXTURE_NSQUARE); bool nonpower = video_driver->queryFeature(video::EVDF_TEXTURE_NPOT); if (!nonpower) { Log::warn("PostProcessing", "Only power of two textures are supported."); } if (!nonsquare) { Log::warn("PostProcessing", "Only square textures are supported."); } // Initialization if(m_supported) { // Render target core::dimension2du opt = video_driver->getScreenSize() .getOptimalSize(!nonpower, !nonsquare); m_render_target = video_driver->addRenderTargetTexture(opt, "postprocess"); if(!m_render_target) { Log::warn("PostProcessing", "Couldn't create the render target " "for post-processing, disabling it."); UserConfigParams::m_postprocess_enabled = false; } // Material and shaders IGPUProgrammingServices* gpu = video_driver->getGPUProgrammingServices(); s32 material_type = gpu->addHighLevelShaderMaterialFromFiles( (file_manager->getShaderDir() + "motion_blur.vert").c_str(), "main", video::EVST_VS_2_0, (file_manager->getShaderDir() + "motion_blur.frag").c_str(), "main", video::EPST_PS_2_0, this, video::EMT_SOLID); m_blur_material.MaterialType = (E_MATERIAL_TYPE)material_type; m_blur_material.setTexture(0, m_render_target); m_blur_material.Wireframe = false; m_blur_material.Lighting = false; m_blur_material.ZWriteEnable = false; } } // PostProcessing
/** Initialization */ void PostProcessing::init(video::IVideoDriver* video_driver) { // Check if post-processing is supported on this hardware m_supported = false; if( video_driver->queryFeature(video::EVDF_ARB_GLSL) && video_driver->queryFeature(video::EVDF_PIXEL_SHADER_2_0) && video_driver->queryFeature(video::EVDF_RENDER_TO_TARGET)) { m_supported = true; } //Check which texture dimensions are supported on this hardware bool nonsquare = video_driver->queryFeature(video::EVDF_TEXTURE_NSQUARE); bool nonpower = video_driver->queryFeature(video::EVDF_TEXTURE_NPOT); if (!nonpower) { fprintf(stdout, "WARNING: Only power of two textures are supported.\n"); } if (!nonsquare) { fprintf(stdout, "WARNING: Only square textures are supported.\n"); } // Initialization if(m_supported) { // Render target m_render_target = video_driver->addRenderTargetTexture(video_driver->getScreenSize().getOptimalSize(!nonpower, !nonsquare), "postprocess"); if(!m_render_target) { fprintf(stderr, "Couldn't create the render target for post-processing, disabling it\n"); UserConfigParams::m_postprocess_enabled = false; } // Material and shaders IGPUProgrammingServices* gpu = video_driver->getGPUProgrammingServices(); s32 material_type = gpu->addHighLevelShaderMaterialFromFiles( (file_manager->getDataDir() + "shaders/motion_blur.vert").c_str(), "main", video::EVST_VS_2_0, (file_manager->getDataDir() + "shaders/motion_blur.frag").c_str(), "main", video::EPST_PS_2_0, this, video::EMT_SOLID); m_material.MaterialType = (E_MATERIAL_TYPE)material_type; m_material.setTexture(0, m_render_target); m_material.Wireframe = false; m_material.Lighting = false; m_material.ZWriteEnable = false; } }