public OutputPanelHammersley( IContainer container )
        {
            container.Add( this );

            InitializeComponent();

            WMath.Hammersley	QRNG = new WMath.Hammersley();
            double[,]		Sequence = QRNG.BuildSequence( SAMPLES_COUNT, 2 );
            for ( int SampleIndex=0; SampleIndex < SAMPLES_COUNT; SampleIndex++ )
            {
                float	Angle = 2.0f * (float) Math.PI * (float) Sequence[SampleIndex,0];
                float	Radius = (float) Math.Sqrt( Sequence[SampleIndex,1] );	// Uniform
            //				float	Radius = (float) Sequence[SampleIndex,1];

                m_Samples[SampleIndex] = new WMath.Vector2D( Radius * (float) Math.Cos( Angle ), Radius * (float) Math.Sin( Angle ) );
            }

            string	Format = "const uint		SHADOW_SAMPLES_COUNT = " + SAMPLES_COUNT + ";\r\n"
                           + "const float2	SamplesOffset[SHADOW_SAMPLES_COUNT] = {\r\n";

            for ( int SampleIndex=0; SampleIndex < SAMPLES_COUNT; SampleIndex++ )
            {
                Format += "	float2( " + m_Samples[SampleIndex].x + ", " + m_Samples[SampleIndex].y + " ),\r\n";
            }

            Format += "};\r\n\r\n";

            OnSizeChanged( EventArgs.Empty );
        }
Beispiel #2
0
        public OutputPanelHammersley(IContainer container)
        {
            container.Add(this);

            InitializeComponent();

            WMath.Hammersley QRNG = new WMath.Hammersley();
            double[,]               Sequence = QRNG.BuildSequence(SAMPLES_COUNT, 2);
            for (int SampleIndex = 0; SampleIndex < SAMPLES_COUNT; SampleIndex++)
            {
                float Angle  = 2.0f * (float)Math.PI * (float)Sequence[SampleIndex, 0];
                float Radius = (float)Math.Sqrt(Sequence[SampleIndex, 1]);                      // Uniform
//				float	Radius = (float) Sequence[SampleIndex,1];

                m_Samples[SampleIndex] = new WMath.Vector2D(Radius * (float)Math.Cos(Angle), Radius * (float)Math.Sin(Angle));
            }

            string Format = "const uint		SHADOW_SAMPLES_COUNT = "+ SAMPLES_COUNT + ";\r\n"
                            + "const float2	SamplesOffset[SHADOW_SAMPLES_COUNT] = {\r\n";

            for (int SampleIndex = 0; SampleIndex < SAMPLES_COUNT; SampleIndex++)
            {
                Format += "	float2( " + m_Samples[SampleIndex].x + ", " + m_Samples[SampleIndex].y + " ),\r\n";
            }

            Format += "};\r\n\r\n";

            OnSizeChanged(EventArgs.Empty);
        }