Vec3f Leafcutter::EvalutateLight(const DirLight& light, DifferentialGeometry& dp, const Vec3f &wo, Material *ms) { Vec3f wi = -light.normal; BxdfUnion msu; ms->SampleReflectance(dp, msu); Vec3f brdf = msu.EvalSmoothCos(wo, wi, dp); Vec3f estimate = brdf; if(!estimate.IsZero()) { Ray shadowRay(dp.P, wi, RAY_INFINITY, 0.0f); if(!_engine->IntersectAny(shadowRay)) { return light.le * estimate; } } return Vec3f::Zero(); }
Vec3f Leafcutter::EvalutateLight(const OrientedLight& light, DifferentialGeometry& dp, const Vec3f &wo, Material *ms) { Vec3f wi = (light.position - dp.P).GetNormalized(); float maxDist = (light.position - dp.P).GetLength(); float cosAngle = max(0.0f, light.normal % (-wi)); float lenSqrEst = max(0.1f, (light.position - dp.P).GetLengthSqr()); //float lenSqrEst = (light.position - dp.P).GetLengthSqr(); BxdfUnion msu; ms->SampleReflectance(dp, msu); Vec3f brdf = msu.EvalSmoothCos(wo, wi, dp); Vec3f estimate = brdf * cosAngle / lenSqrEst; if(!estimate.IsZero()) { Ray shadowRay(dp.P, wi, maxDist, 0.0f); if(!_engine->IntersectAny(shadowRay)) { return light.le * estimate; } } return Vec3f::Zero(); }