Skip to content
This repository has been archived by the owner on Mar 19, 2020. It is now read-only.

Commit

Permalink
added trignometry.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaochun Tong committed Nov 7, 2019
1 parent 237af3a commit 71f5fe3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
16 changes: 16 additions & 0 deletions src/api/trignometry.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <api/math.hpp>

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
23 changes: 9 additions & 14 deletions src/core/lights/arealight.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -23,19 +23,16 @@
#include "arealight.h"
#include <api/mesh.h>


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;
Expand All @@ -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();
}
}
void AreaLight::sampleLe(const Point2f &u1, const Point2f &u2, LightRaySample &sample) { MIYUKI_NOT_IMPLEMENTED(); }
} // namespace miyuki::core

0 comments on commit 71f5fe3

Please sign in to comment.