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 40
|
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "BSDF.ih"
#include "math/sampling.ih"
OSPRAY_BEGIN_ISPC_NAMESPACE
inline BSDF_EvalRes Lambert_eval(
const varying BSDF *uniform self, const vec3f &, const vec3f &wi)
{
BSDF_EvalRes res;
float cosThetaI = max(dot(wi, getN(self)), 0.f);
res.pdf = cosineSampleHemispherePDF(cosThetaI);
res.value = self->albedo * (float)one_over_pi * cosThetaI;
return res;
}
inline BSDF_SampleRes Lambert_sample(
const varying BSDF *uniform self, const vec3f &, const vec2f &s, float)
{
const vec3f localDir = cosineSampleHemisphere(s);
BSDF_SampleRes res;
res.wi = getFrame(self) * localDir;
res.pdf = cosineSampleHemispherePDF(localDir);
res.type = BSDF_DIFFUSE_REFLECTION;
res.weight = self->albedo;
return res;
}
inline void Lambert_Constructor(varying BSDF *uniform self,
const varying linear3f *uniform frame,
const varying vec3f &R)
{
BSDF_Constructor(self, R, BSDF_DIFFUSE_REFLECTION, BSDF_TYPE_LAMBERT, frame);
}
OSPRAY_END_ISPC_NAMESPACE
|