/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
 *
 * SPDX-License-Identifier: Apache-2.0 */

#include "node_fresnel.h"
#include "stdcycles.h"

shader node_glass_bsdf(color Color = 0.8,
                       string distribution = "ggx",
                       float Roughness = 0.2,
                       float IOR = 1.45,
                       normal Normal = N,
                       output closure color BSDF = 0)
{
  float r2 = Roughness * Roughness;
  float eta = max(IOR, 1e-5);
  eta = backfacing() ? 1.0 / eta : eta;
  color F0 = F0_from_ior(eta);
  color F90 = color(1.0);

  BSDF = generalized_schlick_bsdf(
      Normal, vector(0.0), Color, Color, r2, r2, F0, F90, -eta, distribution);
}
