[Bf-codereview] Particle Info node for Cycles (issue 6242069)

lukas.toenne at googlemail.com lukas.toenne at googlemail.com
Fri Jun 8 12:59:04 CEST 2012


http://codereview.appspot.com/6242069/diff/1/intern/cycles/blender/blender_object.cpp
File intern/cycles/blender/blender_object.cpp (right):

http://codereview.appspot.com/6242069/diff/1/intern/cycles/blender/blender_object.cpp#newcode274
intern/cycles/blender/blender_object.cpp:274: sync_particles(object,
b_ob);
On 2012/06/01 14:33:32, brechtvl wrote:
> This should be done only on demand, by adding a
ParticleInfoNode::attributes(..)
> callback, which adds a ATTR_STD_PARTICLE request, which can then be
checked here
> with object->mesh->need_attribute(scene, ATTR_STD_PARTICLE);

> This is usually for mesh element attributes but actually was intended
to work
> for requesting per object attributes as well.

Done. There is now a function object_use_particles to check object
particle systems for all shader users, depending on render mode.
Currently only does dupli object/group, but has code for future
billboards (assuming those will be stored to the object's own mesh).

http://codereview.appspot.com/6242069/diff/1/intern/cycles/blender/blender_object.cpp#newcode329
intern/cycles/blender/blender_object.cpp:329: int particle_index =
(b_index > num_particles ? 0 : b_index + particle_offset);
On 2012/06/01 14:33:32, brechtvl wrote:
> This is not going to work for particles inside dupligroups, trying to
match
> these indices is not reliable. I think the proper solution is to put
the
> particle index in the DupliObject.

Done. I've added an explicit particle_index to DupliObject, which is the
lowest level (visible) particle index. Does not work with particles on
top of particles (second index is ignored), but should cover most use
cases with groups and the like.

http://codereview.appspot.com/6242069/diff/1/intern/cycles/blender/blender_sync.cpp
File intern/cycles/blender/blender_sync.cpp (right):

http://codereview.appspot.com/6242069/diff/1/intern/cycles/blender/blender_sync.cpp#newcode83
intern/cycles/blender/blender_sync.cpp:83: if(b_ob->is_updated() ||
b_ob->is_updated_data()) {
On 2012/06/01 14:33:32, brechtvl wrote:
> Why is this needed?

In fact it isn't ... Don't remember why this is still here, i think i
was trying to get updates when only particles change, but that seems to
work now without this. Removed.

http://codereview.appspot.com/6242069/diff/1/intern/cycles/blender/blender_util.h
File intern/cycles/blender/blender_util.h (right):

http://codereview.appspot.com/6242069/diff/1/intern/cycles/blender/blender_util.h#newcode277
intern/cycles/blender/blender_util.h:277: if(parent.ptr.data) {
On 2012/06/01 14:33:32, brechtvl wrote:
> This change can be reverted.

Done.

http://codereview.appspot.com/6242069/diff/1/intern/cycles/render/object.cpp
File intern/cycles/render/object.cpp (right):

http://codereview.appspot.com/6242069/diff/1/intern/cycles/render/object.cpp#newcode213
intern/cycles/render/object.cpp:213: object_map[offset_map] =
make_uint4(ob->pass_id, ob->random_id, ob->particle_id, 0);
On 2012/06/01 14:33:32, brechtvl wrote:
> Why not stick the particle_id in the make_float4 above? __int_as_float
and
> __float_as_int can be used to avoid any precision loss.

> The loss of precision for pass_id is not a problem because it ends up
in a float
> buffer or as a float in shader nodes anyway.

> I try to not use too many textures because OpenCL/CUDA can only handle
a limited
> number of arrays.

Done.

http://codereview.appspot.com/6242069/diff/1/intern/cycles/render/object.cpp#newcode286
intern/cycles/render/object.cpp:286: /* create a dummy 1-particle
texture to avoid invalid lookups */
On 2012/06/01 14:33:32, brechtvl wrote:
> This avoids invalid lookups in case you have no objects with
particles, but the
> particle info node is still used.

> But for the case you have some objects with particles, and another
object with a
> particle info node but no particles, it will still do an invalid
lookup. Maybe
> the first element in the arrays should always be this dummy element?

Done.

http://codereview.appspot.com/6242069/


More information about the Bf-codereview mailing list