protected override Color3 Indirect( Point WorldHit, Point ModelHit,
                                            Vector WorldViewer, Vector ModelViewer,
                                            SurfaceNormal Normal,
                                            Random Rng, RayTracerBase Tracer )
        {
            if ( Tracer == null )
            {
                return Color3.Black;
            }

            Vector ReverseViewer = -WorldViewer;
            Vector WorldNormal = Normal.WorldNormal;

            BrdfSample Sample = brdf.Sample( ReverseViewer, WorldNormal, Rng );

            if ( Sample.Reflectance.IsBlack() || Sample.Pdf <= 0.0f )
            {
                return Color3.Black;
            }

            Color3 Reflectance = Sample.Reflectance * Math.Abs( Vector.DotProduct( Sample.Outgoing, WorldNormal ) ) / Sample.Pdf;

            float RouletteProbability = Math.Max( Math.Max( Sample.Reflectance.R, Sample.Reflectance.G ), Sample.Reflectance.B );

            return Reflectance * Tracer.Trace( new Ray( WorldHit, Sample.Outgoing ), RouletteProbability );
        }
        protected override Color3 Indirect( Point WorldHit, Point ModelHit,
                                            Vector WorldViewer, Vector ModelViewer,
                                            SurfaceNormal Normal,
                                            Random Rng, RayTracerBase Tracer )
        {
            if ( Tracer == null || Color.IsBlack() )
            {
                return Color3.Black;
            }

            Vector Direction = IrisMath.CosineSampleHemisphere( Normal.NormalizedWorldNormal, Rng );
            return Color * Tracer.Trace( new Ray( WorldHit, Direction ), RouletteProbability );
        }
        protected override Color3 Indirect( Point WorldHit, Point ModelHit,
                                            Vector WorldViewer, Vector ModelViewer,
                                            SurfaceNormal Normal,
                                            Random Rng, RayTracerBase Tracer )
        {
            if ( Tracer == null || Specular.IsBlack() )
            {
                return Color3.Black;
            }

            Vector ReflectedDirection = IrisMath.Reflect( WorldViewer, Normal.NormalizedWorldNormal );
            return Specular * Tracer.Trace( new Ray( WorldHit, ReflectedDirection ) );
        }
Exemple #4
0
            public ThreadLocalState( SceneBase Scene, RenderMethod Method, byte MaxDepth, float Epsilon, 
                                     byte RouletteDepth, float MaximumTerminationProbability )
            {
                this.Rng = new Random();

                switch ( Method )
                {
                    case RenderMethod.PathTrace:
                        this.RayTracer = new PathTracer( Scene, MaxDepth, Epsilon, Rng,
                                                         RouletteDepth, MaximumTerminationProbability );
                        break;
                    default: // RenderMethod.RecursiveRayTrace
                        this.RayTracer = new RecursiveRayTracer( Scene, MaxDepth, Epsilon, Rng,
                                                                 RouletteDepth, MaximumTerminationProbability );
                        break;
                }
            }