示例#1
0
        private void EvalBrdf(out RgbSpectrum fs, ref Vector lwi, ref Vector lwo)
        {
            float sinthetai = SinTheta(ref lwi);
            float sinthetao = SinTheta(ref lwo);
            // Compute cosine term of Oren--Nayar model
            float sinphii = SinPhi(ref lwi), cosphii = CosPhi(ref lwi);
            float sinphio = SinPhi(ref lwo), cosphio = CosPhi(ref lwo);
            float dcos = cosphii*cosphio + sinphii*sinphio;
#if VERBOSE
            Assert.IsNotNaN(cosphii,"cosphii "+lwi.ToString());
            Assert.IsNotNaN(cosphio, "cosphio " + lwo.ToString());
            Assert.IsNotNaN(sinphii, "sinphii " + lwi.ToString());
            Assert.IsNotNaN(sinphio, "sinphio " + lwo.ToString());
#endif
            float maxcos = Math.Max(0f, dcos);
            // Compute sine and tangent terms of Oren--Nayar model
            float sinalpha, tanbeta;
            if (Math.Abs(CosTheta(ref lwi)) > Math.Abs(CosTheta(ref lwo)))
            {
                sinalpha = sinthetao;
                tanbeta = sinthetai/Math.Abs(CosTheta(ref lwi));
            }
            else
            {
                sinalpha = sinthetai;
                tanbeta = sinthetao/Math.Abs(CosTheta(ref lwo));
            }
            

            fs = R*MathLab.INVPI*
                 (A + B*maxcos*sinalpha*tanbeta);
#if VERBOSE
            if (fs.IsNegative())
            {
                Tracer.TraceLine("OrenNayar - f - negative");
            }
            if (fs.IsBlack())
            {
                Tracer.TraceLine("OrenNayar - f - black");
            }
#endif

        }