0
$\begingroup$

I am trying to manually change particle information so that I can use it to control the color of individual particles.

Here is my setup for a minimum example:

  1. Add an Icosphere (subdivisions=1, so 20 vertices) and a cube to the scene;

  2. Remove the faces and edges of the Icosphere;

  3. Add a particle system to the Icosphere, with the following setup:
    a. Emission number = 20, start frame 0, end frame 0, lifetime 10
    b. Emit from Verts;
    c. Velocity: emitter Geometry normal = 1.0 (default); No physics;
    d. Render Unborn and Died (just to make sure all particles are shown);
    e. Render Object: choose the cube

  4. Set up material for the cube using node editor (cycles)
    a. Particle Info[velocity]->
    b. [Vector]SeparateXYZ[0]->
    c. [Fac]ColorRamp(0:Blue, 0.5:White, 1:Red)[Color]->
    d. [Color]DiffusionBSDF[BSDF]->
    e. [Surface]Material output

enter image description here

At this point, the rendering result looks like this (the colors probably reflect the initial velocity generated by the particle system.):

enter image description here

Then I tried to alter the values stored in particle velocity

particles=bpy.data.objects['Icosphere'].particle_systems[0].particles
for p in particles:
    p.velocity[0] = 0.5

This should change the color of cube particles to white, and it does the job in 3D viewport: enter image description here

However, these changes are not preserved when I try to render. No matter if I use the render button or use the command

bpy.ops.render.render(write_still=True)

The changes I made to the velocity seems to be lost, and the rendered particle system is the same as in Figure 2. 3D viewport also returns to the state before I made the changes. And when I examine the actual data from the console, particle velocities are back to their original value (the same as before I changed them all to 0.5).

I am just trying to render still images, so it does not involve animation/frame changing, etc. My guess is the render command might be forcing the particle system to refresh. Is there a way to prevent this and preserve the changes I make to the particle system during the rendering process?

Thank you very much!

Blender version: 2.79

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.