svm_sepcomb_vector.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright 2011-2014 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. /* Vector combine / separate, used for the RGB and XYZ nodes */
  18. ccl_device void svm_node_combine_vector(
  19. ShaderData *sd, float *stack, uint in_offset, uint vector_index, uint out_offset)
  20. {
  21. float vector = stack_load_float(stack, in_offset);
  22. if (stack_valid(out_offset))
  23. stack_store_float(stack, out_offset + vector_index, vector);
  24. }
  25. ccl_device void svm_node_separate_vector(
  26. ShaderData *sd, float *stack, uint ivector_offset, uint vector_index, uint out_offset)
  27. {
  28. float3 vector = stack_load_float3(stack, ivector_offset);
  29. if (stack_valid(out_offset)) {
  30. if (vector_index == 0)
  31. stack_store_float(stack, out_offset, vector.x);
  32. else if (vector_index == 1)
  33. stack_store_float(stack, out_offset, vector.y);
  34. else
  35. stack_store_float(stack, out_offset, vector.z);
  36. }
  37. }
  38. CCL_NAMESPACE_END