Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mapping_util.h « svm « kernel « cycles « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 13257c762e7d01cee7fa0426e87d570499b7912a (plain)
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
/* SPDX-License-Identifier: Apache-2.0
 * Copyright 2011-2022 Blender Foundation */

#pragma once

CCL_NAMESPACE_BEGIN

ccl_device float3
svm_mapping(NodeMappingType type, float3 vector, float3 location, float3 rotation, float3 scale)
{
  Transform rotationTransform = euler_to_transform(rotation);
  switch (type) {
    case NODE_MAPPING_TYPE_POINT:
      return transform_direction(&rotationTransform, (vector * scale)) + location;
    case NODE_MAPPING_TYPE_TEXTURE:
      return safe_divide(transform_direction_transposed(&rotationTransform, (vector - location)),
                         scale);
    case NODE_MAPPING_TYPE_VECTOR:
      return transform_direction(&rotationTransform, (vector * scale));
    case NODE_MAPPING_TYPE_NORMAL:
      return safe_normalize(transform_direction(&rotationTransform, safe_divide(vector, scale)));
    default:
      return make_float3(0.0f, 0.0f, 0.0f);
  }
}

CCL_NAMESPACE_END