Beispiel #1
0
        private void ApplyBilateralFiltering( Renderer.Texture2D _Source, Renderer.Texture2D _Target, float _BilateralRadius, float _BilateralTolerance, bool _Wrap, int _ProgressBarMax )
        {
            _Source.SetCS( 0 );
            _Target.SetCSUAV( 0 );

            // 			m_CB_Filter.m.Radius = _BilateralRadius;
            // 			m_CB_Filter.m.Tolerance = _BilateralTolerance;
            m_CB_Filter.m.Sigma_Radius = (float) (-0.5 * Math.Pow( _BilateralRadius / 3.0f, -2.0 ));
            m_CB_Filter.m.Sigma_Tolerance = _BilateralTolerance > 0.0f ? (float) (-0.5 * Math.Pow( _BilateralTolerance, -2.0 )) : -1e6f;
            m_CB_Filter.m.Tile = (uint) (_Wrap ? 1 : 0);

            m_CS_BilateralFilter.Use();

            uint	h = Math.Max( 1, MAX_LINES*1024 / W );
            uint	CallsCount = (uint) Math.Ceiling( (float) H / h );
            for ( uint i=0; i < CallsCount; i++ ) {
                m_CB_Filter.m.Y0 = (UInt32) (i * h);
                m_CB_Filter.UpdateData();

                m_CS_BilateralFilter.Dispatch( W, h, 1 );

                m_device.Present( true );

                progressBar.Value = (int) (0.01f * (0 + _ProgressBarMax * (i+1) / CallsCount) * progressBar.Maximum);
            //				for ( int a=0; a < 10; a++ )
                    Application.DoEvents();
            }

            // Single gulp (crashes the driver on large images!)
            //			m_CS_BilateralFilter.Dispatch( W, H, 1 );

            _Target.RemoveFromLastAssignedSlotUAV();	// So we can use it as input for next stage
        }