Beispiel #1
0
        public override Spectrum f(Vector3 wo, Vector3 wi)
        {
            if (!Utils.SameHemisphere(wo, wi))
            {
                return(Spectrum.ZeroSpectrum);
            }

            // Cos term
            // Adicijski izrek: cos(x +- y) = cos(x) * cos(y) -+ sin(x) * sin(y)
            double cosDiff = Utils.CosPhi(wi) * Utils.CosPhi(wo) + Utils.SinPhi(wi) * Utils.SinPhi(wo);

            // Sin and tan terms
            double sinAlpha, tanBeta;

            if (Utils.AbsCosTheta(wi) > Utils.AbsCosTheta(wo))               // oTheta > iTheta
            {
                sinAlpha = Utils.SinTheta(wo);
                tanBeta  = Utils.SinTheta(wi) / Utils.AbsCosTheta(wi);
            }
            else                 // iTheta >= oTheta
            {
                sinAlpha = Utils.SinTheta(wi);
                tanBeta  = Utils.SinTheta(wo) / Utils.AbsCosTheta(wo);
            }

            return(kd * Utils.PiInv * (A + B * Math.Max(0, cosDiff) * sinAlpha * tanBeta));
        }
Beispiel #2
0
        public override Spectrum f(Vector3 wo, Vector3 wi)
        {
            if (!Utils.SameHemisphere(wo, wi))
            {
                return(Spectrum.ZeroSpectrum);
            }

            double A = 1 - (this.cov) / (2 * (this.cov + 0.33));
            double B = 0.45 * (this.cov) / (this.cov + 0.09);

            double r_o = Math.Sqrt(wo.x * wo.x + wo.y * wo.y + wo.z * wo.z);
            double r_i = Math.Sqrt(wi.x * wi.x + wi.y * wi.y + wi.z * wi.z);

            //double alpha = Math.Max(Math.Acos(wo.z / r_o), Math.Acos(wi.z / r_i));
            //double beta = Math.Min(Math.Acos(wo.z / r_o), Math.Acos(wi.z / r_i));

            //double cosPhi_o = Utils.CosPhi(wo);
            //double cosPhi_i = Utils.CosPhi(wi);

            //double cosTheta_o = Utils.CosTheta(wo);
            //double cosTheta_i = Utils.CosTheta(wi);

            double alpha = Math.Max(Math.Acos(wo.z / r_o), Math.Acos(wi.z / r_i));
            double beta  = Math.Min(Math.Acos(wo.z / r_o), Math.Acos(wi.z / r_i));

            double phi_o = Math.Atan(wo.y / wo.x);
            double phi_i = Math.Atan(wi.y / wo.x);

            return(kd * Utils.PiInv * (A + B * Math.Max(0, Math.Cos(phi_i - phi_o)) * Math.Sin(alpha) * Math.Tan(beta)));
        }
Beispiel #3
0
 public override Spectrum f(Vector3 wo, Vector3 wi)
 {
     if (!Utils.SameHemisphere(wo, wi))
     {
         return(Spectrum.ZeroSpectrum);
     }
     return(kd * Utils.PiInv);
 }
Beispiel #4
0
        public override double Pdf(Vector3 wo, Vector3 wi)
        {
            if (!Utils.SameHemisphere(wo, wi))
            {
                return(0.0);
            }

            return(Math.Abs(wi.z) * Utils.PiInv);
        }
Beispiel #5
0
        public static double CosineHemispherePdf(Vector3 wo, Vector3 wi)
        {
            if (!Utils.SameHemisphere(wo, wi))
            {
                return(0);
            }

            return(Math.Abs(wi.z) * Utils.PiInv);
        }