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 41 42 43 44 45 46 47 48 49 50 51 52 53
|
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "BSDF.ih"
#include "Fresnel.ih"
OSPRAY_BEGIN_ISPC_NAMESPACE
struct Conductor
{
BSDF super;
Fresnel *uniform fresnel;
};
inline BSDF_SampleRes Conductor_sample(
const varying BSDF *uniform super, const vec3f &wo, const vec2f &, float)
{
const varying Conductor *uniform self =
(const varying Conductor *uniform)super;
BSDF_SampleRes res;
res.wi = reflect(wo, getN(super));
res.pdf = inf;
res.type = BSDF_SPECULAR_REFLECTION;
res.weight = Fresnel_dispatch_eval(self->fresnel, dot(wo, getN(super)));
return res;
}
inline void Conductor_Constructor(varying Conductor *uniform self,
const varying linear3f *uniform frame,
Fresnel *uniform fresnel)
{
BSDF_Constructor(&self->super,
Fresnel_dispatch_evalAvg(fresnel),
BSDF_SPECULAR_REFLECTION,
BSDF_TYPE_CONDUCTOR,
frame);
self->fresnel = fresnel;
}
inline varying BSDF *uniform Conductor_create(
uniform ShadingContext *uniform ctx,
const varying linear3f *uniform frame,
Fresnel *uniform fresnel)
{
varying Conductor *uniform self = (varying Conductor * uniform)
ShadingContext_alloc(ctx, sizeof(Conductor));
Conductor_Constructor(self, frame, fresnel);
return &self->super;
}
OSPRAY_END_ISPC_NAMESPACE
|