Cycles: Implement index output for hair node
[blender.git] / intern / cycles / kernel / svm / svm_geometry.h
index 0ec61fdebf0971e94904975f64d30e71575efcce..6c88d150b609894a7545aaa884aac7b625fc4cad 100644 (file)
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License
+ * limitations under the License.
  */
 
 CCL_NAMESPACE_BEGIN
 
 /* Geometry Node */
 
-ccl_device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device_inline void svm_node_geometry(KernelGlobals *kg,
+                                         ShaderData *sd,
+                                         float *stack,
+                                         uint type,
+                                         uint out_offset)
 {
        float3 data;
 
@@ -33,6 +37,7 @@ ccl_device void svm_node_geometry(KernelGlobals *kg, ShaderData *sd, float *stac
 #ifdef __UV__
                case NODE_GEOM_uv: data = make_float3(sd->u, sd->v, 0.0f); break;
 #endif
+               default: data = make_float3(0.0f, 0.0f, 0.0f);
        }
 
        stack_store_float3(stack, out_offset, data);
@@ -85,7 +90,15 @@ ccl_device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *s
                }
                case NODE_INFO_OB_INDEX: data = object_pass_id(kg, sd->object); break;
                case NODE_INFO_MAT_INDEX: data = shader_pass_id(kg, sd); break;
-               case NODE_INFO_OB_RANDOM: data = object_random_number(kg, sd->object); break;
+               case NODE_INFO_OB_RANDOM: {
+                       if(sd->lamp != LAMP_NONE) {
+                               data = lamp_random_number(kg, sd->lamp);
+                       }
+                       else {
+                               data = object_random_number(kg, sd->object);
+                       }
+                       break;
+               }
                default: data = 0.0f; break;
        }
 
@@ -94,7 +107,11 @@ ccl_device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *s
 
 /* Particle Info */
 
-ccl_device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_particle_info(KernelGlobals *kg,
+                                       ShaderData *sd,
+                                       float *stack,
+                                       uint type,
+                                       uint out_offset)
 {
        switch(type) {
                case NODE_INFO_PAR_INDEX: {
@@ -117,13 +134,13 @@ ccl_device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float
                        stack_store_float3(stack, out_offset, particle_location(kg, particle_id));
                        break;
                }
-               #if 0   /* XXX float4 currently not supported in SVM stack */
+#if 0  /* XXX float4 currently not supported in SVM stack */
                case NODE_INFO_PAR_ROTATION: {
                        int particle_id = object_particle_id(kg, sd->object);
                        stack_store_float4(stack, out_offset, particle_rotation(kg, particle_id));
                        break;
                }
-               #endif
+#endif
                case NODE_INFO_PAR_SIZE: {
                        int particle_id = object_particle_id(kg, sd->object);
                        stack_store_float(stack, out_offset, particle_size(kg, particle_id));
@@ -146,7 +163,11 @@ ccl_device void svm_node_particle_info(KernelGlobals *kg, ShaderData *sd, float
 
 /* Hair Info */
 
-ccl_device void svm_node_hair_info(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset)
+ccl_device void svm_node_hair_info(KernelGlobals *kg,
+                                   ShaderData *sd,
+                                   float *stack,
+                                   uint type,
+                                   uint out_offset)
 {
        float data;
        float3 data3;
@@ -159,6 +180,8 @@ ccl_device void svm_node_hair_info(KernelGlobals *kg, ShaderData *sd, float *sta
                }
                case NODE_INFO_CURVE_INTERCEPT:
                        break; /* handled as attribute */
+               case NODE_INFO_CURVE_INDEX:
+                       break; /* handled as attribute */
                case NODE_INFO_CURVE_THICKNESS: {
                        data = curve_thickness(kg, sd);
                        stack_store_float(stack, out_offset, data);