| 955 | |
| 956 | |
| 957 | Tr2GpuResourcePool::Texture Tr2PostProcessRenderer::RenderBloom( Tr2GpuResourcePool::Texture& dest, Tr2GpuResourcePool& gpuResourcePool, Tr2RenderContext& renderContext, Tr2PPBloomEffect* bloom, Tr2PPDynamicExposureEffect* dynamicExposure ) |
| 958 | { |
| 959 | GPU_REGION( renderContext, "Bloom" ); |
| 960 | renderContext.m_esm.ApplyStandardStates( Tr2EffectStateManager::RM_FULLSCREEN ); |
| 961 | |
| 962 | bool hasDynamicExposure = dynamicExposure != nullptr; |
| 963 | bool exposureDependant = bloom->m_exposureDependency && hasDynamicExposure; |
| 964 | |
| 965 | if( !m_useNewBloom ) |
| 966 | { |
| 967 | m_bloomHighPassFilter->SetParameter( MEMOIZED_STRING( "LuminanceThreshold" ), std::max( 0.0f, bloom->m_luminanceThreshold ) ); |
| 968 | m_bloomHighPassFilter->SetParameter( MEMOIZED_STRING( "LuminanceScale" ), bloom->m_luminanceScale ); |
| 969 | m_bloomHighPassFilter->SetParameter( MEMOIZED_STRING( "ExposureDependency" ), exposureDependant ? 1.0f : 0.0f ); |
| 970 | auto rt1 = gpuResourcePool.GetTempTexture( "Bloom", TextureSize2D( dest->GetDesc() ) * 0.5f, dest->GetFormat(), RENDER_TARGET ); |
| 971 | TEMP_PARAM( m_bloomHighPassFilter, "BlitCurrent", dest ); |
| 972 | TEMP_PARAM( m_bloomHighPassFilter, "Exposure", GetExposureBuffer( gpuResourcePool ) ); |
| 973 | DrawInto( rt1, Tr2LoadAction::DONT_CARE, m_bloomHighPassFilter, renderContext ); |
| 974 | |
| 975 | return Blur( std::move( rt1 ), gpuResourcePool, renderContext, {} ); |
| 976 | } |
| 977 | |
| 978 | int depth = 0; |
| 979 | auto black = GetBlackTexture( gpuResourcePool ); |
| 980 | |
| 981 | float currentSize = 0.5f; |
| 982 | uint32_t minDim = std::min( dest->GetHeight(), dest->GetWidth() ); |
| 983 | |
| 984 | m_downSamplerLuminancePreserve->SetOption( MEMOIZED_STRING( "EXPOSURE_DEPENDANCE" ), hasDynamicExposure ? MEMOIZED_STRING( "EXPOSURE_DEPENDANCE_ON" ) : MEMOIZED_STRING( "EXPOSURE_DEPENDANCE_OFF" ) ); |
| 985 | m_downSamplerLuminancePreserve->SetParameter( MEMOIZED_STRING( "LuminanceThreshold" ), bloom->m_luminanceThreshold ); |
| 986 | |
| 987 | std::array<Tr2GpuResourcePool::Texture, Bloom::MAX_BLOOM_STEPS> downsampleTexture; |
| 988 | std::array<Tr2GpuResourcePool::Texture, Bloom::MAX_BLOOM_STEPS> upsampleHorizontalTexture; |
| 989 | std::array<Tr2GpuResourcePool::Texture, Bloom::MAX_BLOOM_STEPS> upsampleTexture; |
| 990 | |
| 991 | for( int i = 0; i < Bloom::MAX_BLOOM_STEPS; ++i ) |
| 992 | { |
| 993 | if( (uint32_t)( (float)minDim * currentSize ) == 0 ) |
| 994 | { |
| 995 | break; |
| 996 | } |
| 997 | |
| 998 | auto size = TextureSize2D( dest->GetDesc() ) * currentSize; |
| 999 | |
| 1000 | auto name = "Downsample_" + std::to_string( i ); |
| 1001 | downsampleTexture[i] = gpuResourcePool.GetTempTexture( name.c_str(), size, dest->GetFormat(), RENDER_TARGET ); |
| 1002 | |
| 1003 | name = "Upsample_" + std::to_string( i ); |
| 1004 | upsampleTexture[i] = gpuResourcePool.GetTempTexture( name.c_str(), size, dest->GetFormat(), RENDER_TARGET ); |
| 1005 | |
| 1006 | if( m_bloomDebugMode != BloomDebugMode::BLOOM_DEBUG_NONE ) |
| 1007 | { |
| 1008 | name = "Upsample_Horizontal_" + std::to_string( i ); |
| 1009 | upsampleHorizontalTexture[i] = gpuResourcePool.GetTempTexture( name.c_str(), size, dest->GetFormat(), RENDER_TARGET ); |
| 1010 | } |
| 1011 | |
| 1012 | currentSize *= 0.5f; |
| 1013 | ++depth; |
| 1014 | } |
nothing calls this directly
no test coverage detected