Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-14 16:32:38 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-14 16:55:46 +0300
commitf6107af4cf4d907495e2e9c18e5866fd1d420650 (patch)
treeebac5a9d08145af572e5400c0697156797b73130 /intern/cycles/kernel
parentc8e661706fcdd88f1cf371f2e5e4eb76bf09fda3 (diff)
Cycles: change Index output of Hair and Particle Info to Random, in 0..1 range.
These are used for randomization, so it's convenient if the index is already hashed and consistent with the Object Info node.
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r--intern/cycles/kernel/geom/geom_object.h2
-rw-r--r--intern/cycles/kernel/kernel_types.h2
-rw-r--r--intern/cycles/kernel/osl/osl_services.cpp15
-rw-r--r--intern/cycles/kernel/osl/osl_services.h3
-rw-r--r--intern/cycles/kernel/shaders/node_hair_info.osl4
-rw-r--r--intern/cycles/kernel/shaders/node_particle_info.osl4
-rw-r--r--intern/cycles/kernel/svm/svm_geometry.h6
-rw-r--r--intern/cycles/kernel/svm/svm_types.h4
8 files changed, 17 insertions, 23 deletions
diff --git a/intern/cycles/kernel/geom/geom_object.h b/intern/cycles/kernel/geom/geom_object.h
index fa0dff4bd57..a63d180d450 100644
--- a/intern/cycles/kernel/geom/geom_object.h
+++ b/intern/cycles/kernel/geom/geom_object.h
@@ -352,7 +352,7 @@ ccl_device int shader_pass_id(KernelGlobals *kg, const ShaderData *sd)
/* Particle data from which object was instanced */
-ccl_device_inline float particle_index(KernelGlobals *kg, int particle)
+ccl_device_inline float particle_random(KernelGlobals *kg, int particle)
{
int offset = particle*PARTICLE_SIZE;
float4 f = kernel_tex_fetch(__particles, offset + 0);
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 0bb5873e75c..aeb63b4a65e 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -772,7 +772,7 @@ typedef enum AttributeStandard {
ATTR_STD_MOTION_VERTEX_NORMAL,
ATTR_STD_PARTICLE,
ATTR_STD_CURVE_INTERCEPT,
- ATTR_STD_CURVE_INDEX,
+ ATTR_STD_CURVE_RANDOM,
ATTR_STD_PTEX_FACE_ID,
ATTR_STD_PTEX_UV,
ATTR_STD_VOLUME_DENSITY,
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index 3789073f344..c4128e84f5c 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -82,7 +82,7 @@ ustring OSLRenderServices::u_geom_dupli_generated("geom:dupli_generated");
ustring OSLRenderServices::u_geom_dupli_uv("geom:dupli_uv");
ustring OSLRenderServices::u_material_index("material:index");
ustring OSLRenderServices::u_object_random("object:random");
-ustring OSLRenderServices::u_particle_index("particle:index");
+ustring OSLRenderServices::u_particle_random("particle:random");
ustring OSLRenderServices::u_particle_age("particle:age");
ustring OSLRenderServices::u_particle_lifetime("particle:lifetime");
ustring OSLRenderServices::u_particle_location("particle:location");
@@ -96,11 +96,10 @@ ustring OSLRenderServices::u_geom_polyvertices("geom:polyvertices");
ustring OSLRenderServices::u_geom_name("geom:name");
ustring OSLRenderServices::u_geom_undisplaced("geom:undisplaced");
ustring OSLRenderServices::u_is_smooth("geom:is_smooth");
-#ifdef __HAIR__
ustring OSLRenderServices::u_is_curve("geom:is_curve");
ustring OSLRenderServices::u_curve_thickness("geom:curve_thickness");
ustring OSLRenderServices::u_curve_tangent_normal("geom:curve_tangent_normal");
-#endif
+ustring OSLRenderServices::u_curve_random("geom:curve_random");
ustring OSLRenderServices::u_path_ray_length("path:ray_length");
ustring OSLRenderServices::u_path_ray_depth("path:ray_depth");
ustring OSLRenderServices::u_path_diffuse_depth("path:diffuse_depth");
@@ -653,9 +652,9 @@ bool OSLRenderServices::get_object_standard_attribute(KernelGlobals *kg, ShaderD
}
/* Particle Attributes */
- else if(name == u_particle_index) {
+ else if(name == u_particle_random) {
int particle_id = object_particle_id(kg, sd->object);
- float f = particle_index(kg, particle_id);
+ float f = particle_random(kg, particle_id);
return set_attribute_float(f, type, derivatives, val);
}
else if(name == u_particle_age) {
@@ -701,11 +700,7 @@ bool OSLRenderServices::get_object_standard_attribute(KernelGlobals *kg, ShaderD
return set_attribute_int(3, type, derivatives, val);
}
else if((name == u_geom_trianglevertices || name == u_geom_polyvertices)
-#ifdef __HAIR__
&& sd->type & PRIMITIVE_ALL_TRIANGLE)
-#else
- )
-#endif
{
float3 P[3];
@@ -730,7 +725,6 @@ bool OSLRenderServices::get_object_standard_attribute(KernelGlobals *kg, ShaderD
float f = ((sd->shader & SHADER_SMOOTH_NORMAL) != 0);
return set_attribute_float(f, type, derivatives, val);
}
-#ifdef __HAIR__
/* Hair Attributes */
else if(name == u_is_curve) {
float f = (sd->type & PRIMITIVE_ALL_CURVE) != 0;
@@ -744,7 +738,6 @@ bool OSLRenderServices::get_object_standard_attribute(KernelGlobals *kg, ShaderD
float3 f = curve_tangent_normal(kg, sd);
return set_attribute_float3(f, type, derivatives, val);
}
-#endif
else
return false;
}
diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h
index 642529655bf..2f2dc124a98 100644
--- a/intern/cycles/kernel/osl/osl_services.h
+++ b/intern/cycles/kernel/osl/osl_services.h
@@ -146,7 +146,7 @@ public:
static ustring u_geom_dupli_uv;
static ustring u_material_index;
static ustring u_object_random;
- static ustring u_particle_index;
+ static ustring u_particle_random;
static ustring u_particle_age;
static ustring u_particle_lifetime;
static ustring u_particle_location;
@@ -163,6 +163,7 @@ public:
static ustring u_is_curve;
static ustring u_curve_thickness;
static ustring u_curve_tangent_normal;
+ static ustring u_curve_random;
static ustring u_path_ray_length;
static ustring u_path_ray_depth;
static ustring u_path_diffuse_depth;
diff --git a/intern/cycles/kernel/shaders/node_hair_info.osl b/intern/cycles/kernel/shaders/node_hair_info.osl
index 79995bdbfc3..19216f67579 100644
--- a/intern/cycles/kernel/shaders/node_hair_info.osl
+++ b/intern/cycles/kernel/shaders/node_hair_info.osl
@@ -21,12 +21,12 @@ shader node_hair_info(
output float Intercept = 0.0,
output float Thickness = 0.0,
output normal TangentNormal = N,
- output float Index = 0)
+ output float Random = 0)
{
getattribute("geom:is_curve", IsStrand);
getattribute("geom:curve_intercept", Intercept);
getattribute("geom:curve_thickness", Thickness);
getattribute("geom:curve_tangent_normal", TangentNormal);
- getattribute("geom:curve_index", Index);
+ getattribute("geom:curve_random", Random);
}
diff --git a/intern/cycles/kernel/shaders/node_particle_info.osl b/intern/cycles/kernel/shaders/node_particle_info.osl
index 768b7753d02..05358400bf8 100644
--- a/intern/cycles/kernel/shaders/node_particle_info.osl
+++ b/intern/cycles/kernel/shaders/node_particle_info.osl
@@ -17,7 +17,7 @@
#include "stdosl.h"
shader node_particle_info(
- output float Index = 0.0,
+ output float Random = 0.0,
output float Age = 0.0,
output float Lifetime = 0.0,
output point Location = point(0.0, 0.0, 0.0),
@@ -25,7 +25,7 @@ shader node_particle_info(
output vector Velocity = point(0.0, 0.0, 0.0),
output vector AngularVelocity = point(0.0, 0.0, 0.0))
{
- getattribute("particle:index", Index);
+ getattribute("particle:random", Random);
getattribute("particle:age", Age);
getattribute("particle:lifetime", Lifetime);
getattribute("particle:location", Location);
diff --git a/intern/cycles/kernel/svm/svm_geometry.h b/intern/cycles/kernel/svm/svm_geometry.h
index 6c88d150b60..2f85a801112 100644
--- a/intern/cycles/kernel/svm/svm_geometry.h
+++ b/intern/cycles/kernel/svm/svm_geometry.h
@@ -114,9 +114,9 @@ ccl_device void svm_node_particle_info(KernelGlobals *kg,
uint out_offset)
{
switch(type) {
- case NODE_INFO_PAR_INDEX: {
+ case NODE_INFO_PAR_RANDOM: {
int particle_id = object_particle_id(kg, sd->object);
- stack_store_float(stack, out_offset, particle_index(kg, particle_id));
+ stack_store_float(stack, out_offset, particle_random(kg, particle_id));
break;
}
case NODE_INFO_PAR_AGE: {
@@ -180,7 +180,7 @@ ccl_device void svm_node_hair_info(KernelGlobals *kg,
}
case NODE_INFO_CURVE_INTERCEPT:
break; /* handled as attribute */
- case NODE_INFO_CURVE_INDEX:
+ case NODE_INFO_CURVE_RANDOM:
break; /* handled as attribute */
case NODE_INFO_CURVE_THICKNESS: {
data = curve_thickness(kg, sd);
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index b3a2cf6e9ae..9e19ab4444d 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -160,7 +160,7 @@ typedef enum NodeObjectInfo {
} NodeObjectInfo;
typedef enum NodeParticleInfo {
- NODE_INFO_PAR_INDEX,
+ NODE_INFO_PAR_RANDOM,
NODE_INFO_PAR_AGE,
NODE_INFO_PAR_LIFETIME,
NODE_INFO_PAR_LOCATION,
@@ -177,7 +177,7 @@ typedef enum NodeHairInfo {
/*fade for minimum hair width transpency*/
/*NODE_INFO_CURVE_FADE,*/
NODE_INFO_CURVE_TANGENT_NORMAL,
- NODE_INFO_CURVE_INDEX,
+ NODE_INFO_CURVE_RANDOM,
} NodeHairInfo;
typedef enum NodeLightPath {