Page MenuHome

Baked particles dont render in final frame
Open, Confirmed, MediumPublic

Description

System Information
Operating system: Windows-10-10.0.18362 64 Bits
Graphics card: GeForce GTX 980 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 431.60

Blender Version
Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: rBf6cb5f54494e
Worked: (optional)

Short description of error
Baked particles in final frame shows up in viewport but not in render.

Exact steps for others to reproduce the error
Load attached blend file.


Play animation, move to last frame. Render and you can see the particles fine.
Bake the particles, move to last frame. Render and now particles missing.

Details

Type
Bug

Event Timeline

Sybren A. Stüvel (sybren) triaged this task as Confirmed, Medium priority.

Confirmed on Blender 88a872dd6eac10e99afbd18243d39be68921642a. It has to do with the baking range, because when I change the scene end frame from 20 to 21, bake the particles, reset the scene end frame to 20, and render, it's fine.

I'm leaving this for a developer with more knowledge of the particle system. My findings so far:

  • There seems to be a relation between the described problem and what is saved on disk when enabling disk caching. When using a scene frame range 1-5, in 2.79 there are files xxx_000000_00.bphys to xxx_000005_00.bphys. In 2.80 that first file with zero index is missing.
  • BKE_ptcache_bake(): in 2.79 pid->totpoint(pid->calldata, 0) returns the number of particles; in 2.80 this returns 0.
  • BKE_ptcache_write(): same as above, resulting in cfra=0 not being written, which means that the 'info' data in the particle cache isn't written.
  • Forcing pid->totpoint(pid->calldata, cfra) to return 1000 (by hard-coding psys->totpart = 1000) fixes the reported problem, as well as causes the zero-index bphys file to be written.

I've managed to get the correct number of particles by applying the following patch.

diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
index bc2f1d6cef6..d68f076bb2c 100644
--- a/source/blender/editors/physics/physics_pointcache.c
+++ b/source/blender/editors/physics/physics_pointcache.c
@@ -38,6 +38,7 @@
 #include "BKE_pointcache.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
 
 #include "ED_particle.h"
 
@@ -165,7 +166,7 @@ static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all)
 
   if (!all) {
     PointerRNA ptr = CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache);
-    Object *ob = ptr.id.data;
+    Object *ob = DEG_get_evaluated_object(baker->depsgraph, ptr.id.data);
     PointCache *cache = ptr.data;
     baker->pid = BKE_ptcache_id_find(ob, baker->scene, cache);
   }

This does fix the missing zero-index bphys file, but still doesn't solve the render issue.