diff --git a/src/api/trignometry.hpp b/src/api/trignometry.hpp new file mode 100644 index 0000000..aabaae3 --- /dev/null +++ b/src/api/trignometry.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include + +namespace miyuki { + + inline Float CosTheta(const Vec3f &w) { return w.y; } + inline Float AbsCosTheta(const Vec3f &w) { return std::abs(CosTheta(w)); } + inline Float Cos2Theta(const Vec3f &w) { return w.y * w.y; } + inline Float Sin2Theta(const Vec3f &w) { return 1 - Cos2Theta(w); } + inline Float SinTheta(const Vec3f &w) { return std::sqrt(std::fmax(0.0f, Sin2Theta(w))); } + inline Float Tan2Theta(const Vec3f &w) { return Sin2Theta(w) / Cos2Theta(w); } + inline Float TanTheta(const Vec3f &w) { return std::sqrt(std::fmax(0.0f, Tan2Theta(w))); } + inline bool SameHemisphere(const Vec3f &wo, const Vec3f &wi) { return wo.y * wi.y >= 0; } + +} // namespace miyuki \ No newline at end of file diff --git a/src/core/lights/arealight.cpp b/src/core/lights/arealight.cpp index 8ba1703..4f94f92 100644 --- a/src/core/lights/arealight.cpp +++ b/src/core/lights/arealight.cpp @@ -1,17 +1,17 @@ // MIT License -// +// // Copyright (c) 2019 椎名深雪 -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -23,19 +23,16 @@ #include "arealight.h" #include - namespace miyuki::core { void AreaLight::setTriangle(MeshTriangle *shape) { this->triangle = shape; emission = triangle->getMaterial()->emission; } - Spectrum AreaLight::Li(ShadingPoint &sp) const { - return emission->evaluate(sp); - } + Spectrum AreaLight::Li(ShadingPoint &sp) const { return emission->evaluate(sp); } - void - AreaLight::sampleLi(const Point2f &u, Intersection &isct, LightSample &sample, VisibilityTester &tester) const { + void AreaLight::sampleLi(const Point2f &u, Intersection &isct, LightSample &sample, + VisibilityTester &tester) const { SurfaceSample surfaceSample; triangle->sample(u, surfaceSample); auto wi = surfaceSample.p - isct.p; @@ -59,7 +56,5 @@ namespace miyuki::core { return 1.0f / SA; } - void AreaLight::sampleLe(const Point2f &u1, const Point2f &u2, LightRaySample &sample) { - MIYUKI_NOT_IMPLEMENTED(); - } -} \ No newline at end of file + void AreaLight::sampleLe(const Point2f &u1, const Point2f &u2, LightRaySample &sample) { MIYUKI_NOT_IMPLEMENTED(); } +} // namespace miyuki::core \ No newline at end of file