svm_mapping.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 2011-2013 Blender Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. CCL_NAMESPACE_BEGIN
  17. /* Mapping Node */
  18. ccl_device void svm_node_mapping(
  19. KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset)
  20. {
  21. float3 v = stack_load_float3(stack, vec_offset);
  22. Transform tfm;
  23. tfm.x = read_node_float(kg, offset);
  24. tfm.y = read_node_float(kg, offset);
  25. tfm.z = read_node_float(kg, offset);
  26. float3 r = transform_point(&tfm, v);
  27. stack_store_float3(stack, out_offset, r);
  28. }
  29. ccl_device void svm_node_min_max(
  30. KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset)
  31. {
  32. float3 v = stack_load_float3(stack, vec_offset);
  33. float3 mn = float4_to_float3(read_node_float(kg, offset));
  34. float3 mx = float4_to_float3(read_node_float(kg, offset));
  35. float3 r = min(max(mn, v), mx);
  36. stack_store_float3(stack, out_offset, r);
  37. }
  38. CCL_NAMESPACE_END