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 19:02:28 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-02-14 23:45:57 +0300
commitb5fe00d1ac43c16ec8f74d3ad7689599dfb2ef00 (patch)
treee2dcae056cde3c6eaa3bcaf2c1b9117a0a5e87a1 /intern/cycles/render
parentf6107af4cf4d907495e2e9c18e5866fd1d420650 (diff)
Cycles: restore Particle Info Index for now, keep it next to Random.
It seems to be useful still in cases where the particle are distributed in a particular order or pattern, to colorize them along with that. This isn't really well defined, but might as well avoid breaking backwards compatibility for now.
Diffstat (limited to 'intern/cycles/render')
-rw-r--r--intern/cycles/render/nodes.cpp8
-rw-r--r--intern/cycles/render/particles.cpp3
2 files changed, 9 insertions, 2 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 44c807065e4..48613a9324c 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -3463,6 +3463,7 @@ NODE_DEFINE(ParticleInfoNode)
{
NodeType* type = NodeType::add("particle_info", create, NodeType::SHADER);
+ SOCKET_OUT_FLOAT(random, "Index");
SOCKET_OUT_FLOAT(random, "Random");
SOCKET_OUT_FLOAT(age, "Age");
SOCKET_OUT_FLOAT(lifetime, "Lifetime");
@@ -3484,6 +3485,8 @@ ParticleInfoNode::ParticleInfoNode()
void ParticleInfoNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
+ if(!output("Index")->links.empty())
+ attributes->add(ATTR_STD_PARTICLE);
if(!output("Random")->links.empty())
attributes->add(ATTR_STD_PARTICLE);
if(!output("Age")->links.empty())
@@ -3510,6 +3513,11 @@ void ParticleInfoNode::compile(SVMCompiler& compiler)
{
ShaderOutput *out;
+ out = output("Index");
+ if(!out->links.empty()) {
+ compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_INDEX, compiler.stack_assign(out));
+ }
+
out = output("Random");
if(!out->links.empty()) {
compiler.add_node(NODE_PARTICLE_INFO, NODE_INFO_PAR_RANDOM, compiler.stack_assign(out));
diff --git a/intern/cycles/render/particles.cpp b/intern/cycles/render/particles.cpp
index 07e246a092a..3ee620c9d01 100644
--- a/intern/cycles/render/particles.cpp
+++ b/intern/cycles/render/particles.cpp
@@ -80,8 +80,7 @@ void ParticleSystemManager::device_update_particles(Device *, DeviceScene *dscen
Particle& pa = psys->particles[k];
int offset = i*PARTICLE_SIZE;
- float random = hash_int_01(pa.index);
- particles[offset] = make_float4(random, pa.age, pa.lifetime, pa.size);
+ particles[offset] = make_float4(__uint_as_float(pa.index), 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);