2023-06-14 16:52:36 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
2019-09-04 23:17:13 +02:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-09-04 23:17:13 +02:00
|
|
|
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:
|
2022-06-23 14:29:17 +02:00
|
|
|
return safe_divide(transform_direction_transposed(&rotationTransform, (vector - location)),
|
|
|
|
|
scale);
|
2019-09-04 23:17:13 +02:00
|
|
|
case NODE_MAPPING_TYPE_VECTOR:
|
|
|
|
|
return transform_direction(&rotationTransform, (vector * scale));
|
|
|
|
|
case NODE_MAPPING_TYPE_NORMAL:
|
2022-06-23 14:29:17 +02:00
|
|
|
return safe_normalize(transform_direction(&rotationTransform, safe_divide(vector, scale)));
|
2019-09-04 23:17:13 +02:00
|
|
|
default:
|
|
|
|
|
return make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|