// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "BSDF.ih"
#include "ShadingContext.ih"

OSPRAY_BEGIN_ISPC_NAMESPACE

inline BSDF_SampleRes Transmission_sample(
    const varying BSDF *uniform self, const vec3f &wo, const vec2f &, float)
{
  BSDF_SampleRes res;

  res.wi = neg(wo);
  res.pdf = inf;
  res.type = BSDF_SPECULAR_TRANSMISSION;
  res.weight = self->albedo;
  return res;
}

inline void Transmission_Constructor(
    varying BSDF *uniform self, const varying linear3f *uniform frame, vec3f T)
{
  BSDF_Constructor(
      self, T, BSDF_SPECULAR_TRANSMISSION, BSDF_TYPE_TRANSMISSION, frame);
}

inline varying BSDF *uniform Transmission_create(
    uniform ShadingContext *uniform ctx,
    const varying linear3f *uniform frame,
    vec3f T)
{
  varying BSDF *uniform self =
      (varying BSDF * uniform) ShadingContext_alloc(ctx, sizeof(BSDF));
  Transmission_Constructor(self, frame, T);
  return self;
}

OSPRAY_END_ISPC_NAMESPACE
