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

#include "stdcycles.h"

shader node_uv_map(int from_dupli = 0,
                   string attribute = "",
                   string bump_offset = "center",
                   output point UV = point(0.0, 0.0, 0.0))
{
  if (from_dupli) {
    getattribute("geom:dupli_uv", UV);
  }
  else {
    if (attribute == "")
      getattribute("geom:uv", UV);
    else
      getattribute(attribute, UV);
  }

  if (bump_offset == "dx") {
    if (!from_dupli) {
      UV += Dx(UV);
    }
  }
  else if (bump_offset == "dy") {
    if (!from_dupli) {
      UV += Dy(UV);
    }
  }
}
