Blender  V2.93
svm_invert.h
Go to the documentation of this file.
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 
18 
19 ccl_device float invert(float color, float factor)
20 {
21  return factor * (1.0f - color) + (1.0f - factor) * color;
22 }
23 
25  ShaderData *sd, float *stack, uint in_fac, uint in_color, uint out_color)
26 {
27  float factor = stack_load_float(stack, in_fac);
28  float3 color = stack_load_float3(stack, in_color);
29 
30  color.x = invert(color.x, factor);
31  color.y = invert(color.y, factor);
32  color.z = invert(color.z, factor);
33 
34  if (stack_valid(out_color))
35  stack_store_float3(stack, out_color, color);
36 }
37 
unsigned int uint
Definition: BLI_sys_types.h:83
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(float *stack, uint a)
ccl_device_inline float stack_load_float(float *stack, uint a)
ccl_device_inline void stack_store_float3(float *stack, uint a, float3 f)
ccl_device_inline bool stack_valid(uint a)
#define ccl_device
#define CCL_NAMESPACE_END
ShaderData
float z
Definition: sky_float3.h:35
float y
Definition: sky_float3.h:35
float x
Definition: sky_float3.h:35
ccl_device void svm_node_invert(ShaderData *sd, float *stack, uint in_fac, uint in_color, uint out_color)
Definition: svm_invert.h:24
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition: svm_invert.h:19