1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "rkcommon/math/math.ih"
OSPRAY_BEGIN_ISPC_NAMESPACE
struct PowerCosineDistribution
{
float exp;
};
inline float eval(
const PowerCosineDistribution &self, float cosThetaH, float &pdf)
{
pdf = powerCosineSampleHemispherePDF(cosThetaH, self.exp);
return (self.exp + 2) * one_over_two_pi * pow(abs(cosThetaH), self.exp);
// TODO: check with powerCosineSampleHemispherePDF
}
/*! Samples the power cosine distribution. */
inline vec3f sample(
const PowerCosineDistribution &self, float &pdf, const vec2f &s)
{
const vec3f wh = powerCosineSampleHemisphere(self.exp, s);
pdf = powerCosineSampleHemispherePDF(wh, self.exp);
return wh;
}
inline PowerCosineDistribution make_PowerCosineDistribution(float _exp)
{
PowerCosineDistribution m;
m.exp = _exp;
return m;
}
OSPRAY_END_ISPC_NAMESPACE
|