BRDFSlices.DisplayForm.WarpSlice_Compress C# (CSharp) Method

WarpSlice_Compress() protected method

protected WarpSlice_Compress ( int _ThetaHIndex, int _ThetaDIndex, double _Warp, Vector3 &_Result ) : void
_ThetaHIndex int
_ThetaDIndex int
_Warp double
_Result Vector3
return void
        protected void WarpSlice_Compress( int _ThetaHIndex, int _ThetaDIndex, double _Warp, ref Vector3 _Result )
        {
            double	ThetaD = Math.PI * _ThetaDIndex / 180.0;
            double	PhiD = Math.PI * _Warp / 180.0;
            double	ThetaH_Max = Math.Atan( Math.Tan( 0.5*Math.PI - ThetaD ) / Math.Cos( PhiD ) );

            // 			double	ThetaH = Math.PI * _ThetaHIndex / 180.0;
            // 			LookupBRDFTrilinear( m_BRDF, ThetaH, ThetaD, 0.5*Math.PI, ref _Result );

            int		ThetaH_MaxIndex = Math.Max( 1, (int) (ThetaH_Max * 180 / Math.PI) );

            // Add a security slice
            ThetaH_MaxIndex = Math.Min( 89, ThetaH_MaxIndex+4 );

            int		WarpedThetaHIndex = (int) (89 * _ThetaHIndex / ThetaH_MaxIndex);	// Scale so we reach 90° at max ThetaH
            if ( WarpedThetaHIndex > 89 )
            {
                _Result = new Vector3();	// Out of range
                return;
            }

            int	ThetaH = (int) (89 * Math.Sqrt( WarpedThetaHIndex / 89.0 ));	// Square ThetaH

            _Result = m_BRDF[ThetaH,_ThetaDIndex,90];
        }