Helper function to blur certain channel of a source render target to a destination render target with a blur type (Big/Small)
| 891 | |
| 892 | // Helper function to blur certain channel of a source render target to a destination render target with a blur type (Big/Small) |
| 893 | Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::Blur( Tr2GpuResourcePool::Texture src, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext, const PostProcessBlur::BlurContext& blurContext ) |
| 894 | { |
| 895 | GPU_REGION( renderContext, "Blur" ); |
| 896 | |
| 897 | auto lookup = m_blurEffects.find( blurContext.Hash() ); |
| 898 | |
| 899 | // Horizontal and vertical blur effects, IN THAT ORDER! |
| 900 | std::pair<Tr2EffectPtr, Tr2EffectPtr> effects; |
| 901 | if( lookup == m_blurEffects.end() ) |
| 902 | { |
| 903 | // create the effect |
| 904 | effects.first.CreateInstance(); |
| 905 | effects.first->StartUpdate(); |
| 906 | effects.first->SetEffectPathName( "res:/Graphics/Effect/Managed/Space/PostProcess/Blur.fx" ); |
| 907 | |
| 908 | effects.second.CreateInstance(); |
| 909 | effects.second->StartUpdate(); |
| 910 | effects.second->SetEffectPathName( "res:/Graphics/Effect/Managed/Space/PostProcess/Blur.fx" ); |
| 911 | effects.second->SetParameter( MEMOIZED_STRING( "Direction" ), Vector2( 0, 1 ) ); |
| 912 | |
| 913 | BlueSharedString blurTypeOption = PostProcessBlur::GetBlurTypeOptionValue( blurContext.type ); |
| 914 | effects.first->SetOption( MEMOIZED_STRING( "BLUR_TYPE" ), blurTypeOption ); |
| 915 | effects.second->SetOption( MEMOIZED_STRING( "BLUR_TYPE" ), blurTypeOption ); |
| 916 | |
| 917 | BlueSharedString blurChannelOption = PostProcessBlur::GetBlurChannelOptionValue( blurContext.channel ); |
| 918 | effects.first->SetOption( MEMOIZED_STRING( "BLUR_CHANNEL" ), blurChannelOption ); |
| 919 | effects.second->SetOption( MEMOIZED_STRING( "BLUR_CHANNEL" ), blurChannelOption ); |
| 920 | |
| 921 | BlueSharedString blurChannelProcessOption = PostProcessBlur::GetProcessTypeOptionValue( blurContext.process ); |
| 922 | effects.first->SetOption( MEMOIZED_STRING( "BLUR_PROCESS_TYPE" ), blurChannelProcessOption ); |
| 923 | effects.second->SetOption( MEMOIZED_STRING( "BLUR_PROCESS_TYPE" ), blurChannelProcessOption ); |
| 924 | |
| 925 | effects.first->SetOption( MEMOIZED_STRING( "BLUR_FINALIZE_TYPE" ), PostProcessBlur::GetFinalizeTypeOptionValue( PostProcessBlur::BF_None ) ); |
| 926 | effects.second->SetOption( MEMOIZED_STRING( "BLUR_FINALIZE_TYPE" ), PostProcessBlur::GetFinalizeTypeOptionValue( blurContext.finalize ) ); |
| 927 | |
| 928 | effects.first->EndUpdate(); |
| 929 | effects.second->EndUpdate(); |
| 930 | m_blurEffects.insert( std::pair( blurContext.Hash(), effects ) ); |
| 931 | } |
| 932 | else |
| 933 | { |
| 934 | effects = lookup->second; |
| 935 | } |
| 936 | |
| 937 | auto rt2 = gpuResourcePool.GetTempTexture( "Blur Temp 1", src->GetWidth(), src->GetHeight(), src->GetFormat(), RENDER_TARGET ); |
| 938 | TEMP_PARAM( effects.first, "BlitCurrent", src ); |
| 939 | DrawInto( rt2, Tr2LoadAction::DONT_CARE, effects.first, renderContext ); |
| 940 | src = {}; |
| 941 | |
| 942 | auto rt1 = gpuResourcePool.GetTempTexture( "Blur Temp 2", rt2->GetWidth(), rt2->GetHeight(), rt2->GetFormat(), RENDER_TARGET ); |
| 943 | TEMP_PARAM( effects.second, "BlitCurrent", rt2 ); |
| 944 | DrawInto( rt1, Tr2LoadAction::DONT_CARE, effects.second, renderContext ); |
| 945 | return rt1; |
| 946 | } |
| 947 | |
| 948 | Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::DownSampleDepth( const Tr2TextureAL& depth, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext ) |
| 949 | { |
nothing calls this directly
no test coverage detected