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

#pragma once

#include "BSDF.ih"

OSPRAY_BEGIN_ISPC_NAMESPACE

inline BSDF_EvalRes Reflection_eval(const varying BSDF *uniform,
    const vec3f &,
    const vec3f &,
    const uniform FeatureFlagsHandler &)
{
  return make_BSDF_EvalRes_zero();
}

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

  res.wi = reflect(wo, getN(self));
  res.pdf = inf;
  res.type = BSDF_SPECULAR_REFLECTION;
  res.weight = self->albedo;
  return res;
}

inline varying BSDF *uniform Reflection_create(
    uniform ShadingContext *uniform ctx,
    const varying linear3f *uniform frame,
    vec3f reflectance)
{
  varying BSDF *uniform self =
      (varying BSDF * uniform) ShadingContext_alloc(ctx, sizeof(BSDF));
  BSDF_Constructor(self,
      reflectance,
      BSDF_SPECULAR_REFLECTION,
      BSDF_TYPE_REFLECTION,
#ifdef OSPRAY_TARGET_SYCL
      NULL,
      NULL,
#else
      Reflection_eval,
      Reflection_sample,
#endif
      frame);
  return self;
}

OSPRAY_END_ISPC_NAMESPACE
