diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-02-14 16:32:38 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-02-14 16:55:46 +0300 |
commit | f6107af4cf4d907495e2e9c18e5866fd1d420650 (patch) | |
tree | ebac5a9d08145af572e5400c0697156797b73130 /intern/cycles/render | |
parent | c8e661706fcdd88f1cf371f2e5e4eb76bf09fda3 (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/render')
-rw-r--r-- | intern/cycles/render/attribute.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 18 | ||||
-rw-r--r-- | intern/cycles/render/particles.cpp | 4 |
3 files changed, 15 insertions, 13 deletions
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp index 2d1100c9d88..2c22db8189d 100644 --- a/intern/cycles/render/attribute.cpp +++ b/intern/cycles/render/attribute.cpp @@ -267,8 +267,8 @@ const char *Attribute::standard_name(AttributeStandard std) return "particle"; case ATTR_STD_CURVE_INTERCEPT: return "curve_intercept"; - case ATTR_STD_CURVE_INDEX: - return "curve_index"; + case ATTR_STD_CURVE_RANDOM: + return "curve_random"; case ATTR_STD_PTEX_FACE_ID: return "ptex_face_id"; case ATTR_STD_PTEX_UV: @@ -453,7 +453,7 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name) case ATTR_STD_CURVE_INTERCEPT: attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_CURVE_KEY); break; - case ATTR_STD_CURVE_INDEX: + case ATTR_STD_CURVE_RANDOM: attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_CURVE); break; case ATTR_STD_GENERATED_TRANSFORM: diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index d2a03ceb76a..44c807065e4 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -3463,7 +3463,7 @@ NODE_DEFINE(ParticleInfoNode) { NodeType* type = NodeType::add("particle_info", create, NodeType::SHADER); - SOCKET_OUT_FLOAT(index, "Index"); + SOCKET_OUT_FLOAT(random, "Random"); SOCKET_OUT_FLOAT(age, "Age"); SOCKET_OUT_FLOAT(lifetime, "Lifetime"); SOCKET_OUT_POINT(location, "Location"); @@ -3484,7 +3484,7 @@ ParticleInfoNode::ParticleInfoNode() void ParticleInfoNode::attributes(Shader *shader, AttributeRequestSet *attributes) { - if(!output("Index")->links.empty()) + if(!output("Random")->links.empty()) attributes->add(ATTR_STD_PARTICLE); if(!output("Age")->links.empty()) attributes->add(ATTR_STD_PARTICLE); @@ -3510,9 +3510,9 @@ void ParticleInfoNode::compile(SVMCompiler& compiler) { ShaderOutput *out; - out = output("Index"); + out = output("Random"); if(!out->links.empty()) { - compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_INDEX, compiler.stack_assign(out)); + compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_RANDOM, compiler.stack_assign(out)); } out = output("Age"); @@ -3572,7 +3572,7 @@ NODE_DEFINE(HairInfoNode) #if 0 /*output for minimum hair width transparency - deactivated */ SOCKET_OUT_FLOAT(fade, "Fade"); #endif - SOCKET_OUT_FLOAT(index, "Index"); + SOCKET_OUT_FLOAT(index, "Random"); return type; } @@ -3590,8 +3590,8 @@ void HairInfoNode::attributes(Shader *shader, AttributeRequestSet *attributes) if(!intercept_out->links.empty()) attributes->add(ATTR_STD_CURVE_INTERCEPT); - if(!output("Index")->links.empty()) - attributes->add(ATTR_STD_CURVE_INDEX); + if(!output("Random")->links.empty()) + attributes->add(ATTR_STD_CURVE_RANDOM); } ShaderNode::attributes(shader, attributes); @@ -3627,9 +3627,9 @@ void HairInfoNode::compile(SVMCompiler& compiler) compiler.add_node(NODE_HAIR_INFO, NODE_INFO_CURVE_FADE, compiler.stack_assign(out)); }*/ - out = output("Index"); + out = output("Random"); if(!out->links.empty()) { - int attr = compiler.attribute(ATTR_STD_CURVE_INDEX); + int attr = compiler.attribute(ATTR_STD_CURVE_RANDOM); compiler.add_node(NODE_ATTR, attr, compiler.stack_assign(out), NODE_ATTR_FLOAT); } } diff --git a/intern/cycles/render/particles.cpp b/intern/cycles/render/particles.cpp index 06ff45b09bd..07e246a092a 100644 --- a/intern/cycles/render/particles.cpp +++ b/intern/cycles/render/particles.cpp @@ -19,6 +19,7 @@ #include "render/scene.h" #include "util/util_foreach.h" +#include "util/util_hash.h" #include "util/util_logging.h" #include "util/util_map.h" #include "util/util_progress.h" @@ -79,7 +80,8 @@ void ParticleSystemManager::device_update_particles(Device *, DeviceScene *dscen Particle& pa = psys->particles[k]; int offset = i*PARTICLE_SIZE; - particles[offset] = make_float4(pa.index, pa.age, pa.lifetime, pa.size); + float random = hash_int_01(pa.index); + particles[offset] = make_float4(random, pa.age, pa.lifetime, pa.size); particles[offset+1] = pa.rotation; particles[offset+2] = make_float4(pa.location.x, pa.location.y, pa.location.z, pa.velocity.x); particles[offset+3] = make_float4(pa.velocity.y, pa.velocity.z, pa.angular_velocity.x, pa.angular_velocity.y); |