Maniphest T71713

Mantaflow gas emission by texture image sequences not updating
Closed, ResolvedBUG

Assigned To
Philipp Oeser (lichtwerk)
Authored By
Maxim Ponomarov (ponomarovmax)
Nov 20 2019, 10:40 PM
Tags
  • BF Blender
  • Physics
  • Nodes & Physics
Subscribers
Christian Beckers (Beckersc)
Germano Cavalcante (mano-wii)
Jacques Lucke (JacquesLucke)
Maxim Ponomarov (ponomarovmax)
Philipp Oeser (lichtwerk)
Sebastián Barschkis (sebbas)
Tokens
"Love" token, awarded by Beckersc.

Description

System Information
Operating system: Windows-10-10.0.18362 64 Bits

Blender Version
Broken: version: 2.82 (sub 6), branch: master, commit date: 2020-01-09 10:40, hash: rB002f5b826c7c
Worked: 2.79b latest

Short description of error
Auto refresh for image sequences broken (image texture node, texture for smoke masking)

Video example

Exact steps for others to reproduce the error
Open:

  • Select the plane.
  • In the Dynamic Paint settings, select Bake Image Sequence (if you have not generated the images before).
  • In Fluid settings, enable the texture checkbox, choose the Texture -> UV mapping -> UVMap.
  • (Check if the image sequence is being displayed.).
  • Select the domain Cube and Bake Simulation.
  • Check result.

Related Objects

Event Timeline

Maxim Ponomarov (ponomarovmax) created this task.Nov 20 2019, 10:40 PM
Jacques Lucke (JacquesLucke) changed the task status from Needs Triage to Needs Information from User.Jan 8 2020, 1:51 PM
Jacques Lucke (JacquesLucke) added a subscriber: Jacques Lucke (JacquesLucke).

Is this still an issue with Mantaflow in the newest builds from https://builder.blender.org/download/?

Maxim Ponomarov (ponomarovmax) added a comment.Jan 9 2020, 11:04 AM

Yes.

  1. Create new file with latest blender build.
  2. Create plane as dynamic paint canvas, icosphere as brush.
  3. Configure dynamic paint for image sequence baking with initial canvas color black, brush color white.
  4. Bake images sequence.
  5. Create material for plane to preview baking result (Principled BSDF and image texture, 250 images sequence, autorefresh on)
  6. Looks okay on playback, ever after file reopened several times.
  7. Create Cube for domain. Set Flud->Domain, Smoke in physics tab.
  8. Configure Plane as Fluid->Flow, Smoke, Inflow in physics tab.
  9. Also set texture to control flow.
  10. Bake...

As result: different frame picked "randomly" as texture without animation during playback.
After blender restart sometimes other frame could be loaded.
Looks like it takes frame that was on timeline whan blender saved file and closed.

P.S.
Most common way to use dynamic paint texture to control smoke density - some kind of car crash with dynamic fire and smoke source based on cars collision.
With blender 2.80+ it's impossible because of broken image texture caching system.

P.S.S.
New video demo with newest blender version.

Philipp Oeser (lichtwerk) changed the task status from Needs Information from User to Needs Triage.Jan 9 2020, 11:14 AM
Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Confirmed.Jan 10 2020, 2:11 PM
Germano Cavalcante (mano-wii) changed the subtype of this task from "Report" to "Bug".
Germano Cavalcante (mano-wii) added a project: Physics.
Germano Cavalcante (mano-wii) added a subscriber: Germano Cavalcante (mano-wii).

I can confirm.
Used to work on the previous system.

Germano Cavalcante (mano-wii) updated the task description.Jan 10 2020, 2:24 PM
Germano Cavalcante (mano-wii) added a project: Nodes & Physics.Jan 10 2020, 3:21 PM
Christian Beckers (Beckersc) awarded a token.Feb 9 2020, 2:57 PM
Christian Beckers (Beckersc) added a subscriber: Christian Beckers (Beckersc).
Philipp Oeser (lichtwerk) claimed this task.Jan 13 2021, 6:17 PM
Philipp Oeser (lichtwerk) added a subscriber: Philipp Oeser (lichtwerk).

Looked into this (this has taken more time than anticipated, learned one thing or the other) and I think I have a fix.

Philipp Oeser (lichtwerk) renamed this task from Auto refresh for image sequences not updates to Mantaflow gas emission by texture image sequences not updating.Jan 13 2021, 6:19 PM
Philipp Oeser (lichtwerk) changed the task status from Confirmed to Needs Information from User.Jan 15 2021, 12:33 PM
Philipp Oeser (lichtwerk) added a subscriber: Sebastián Barschkis (sebbas).

OK, after a lot of digging (and being on the wrong track for quite some time), it turns out this is actually working.

Taking a step back and contemplating:
I was carefully checking depsgraph refreshes of textures, images and ImageUser framenumbers and even made a patch to force-refresh the ImageUsers framenumber for the texture used in the fluid flow:
(but this was my fault not paying attention to enable Auto Refresh in the used texture from the texture tab [about 1:30 in the first video], each image use has its own ImageUser, so it is not enough to enable Auto Refresh in the Shader Editor on that sequence -- and without this option ON, the dependency graph will not update the framenumber on this ImageUser. I can hardly think of a situation where I would not want to update the image sequence, so I think this option should actually be always ON and hidden, but this is a whole different story)

1
2
3diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
4index 4356f1246ed..2ac8fc1ae44 100644
5--- a/source/blender/blenkernel/intern/fluid.c
6+++ b/source/blender/blenkernel/intern/fluid.c
7@@ -42,6 +42,7 @@
8 #include "BKE_effect.h"
9 #include "BKE_fluid.h"
10 #include "BKE_global.h"
11+#include "BKE_image.h"
12 #include "BKE_lib_id.h"
13 #include "BKE_modifier.h"
14 #include "BKE_pointcache.h"
15@@ -2833,6 +2834,13 @@ static void compute_flowsemission(Scene *scene,
16 }
17 /* Emission from mesh. */
18 else if (ffs->source == FLUID_FLOW_SOURCE_MESH) {
19+ /* Need to update the textures image user to the correct frame. */
20+ if ((ffs->flags & FLUID_FLOW_TEXTUREEMIT) && ffs->noise_texture) {
21+ Tex *noise_texture = ffs->noise_texture;
22+ if (BKE_image_is_animated(noise_texture->ima)) {
23+ BKE_image_user_frame_calc(noise_texture->ima, &noise_texture->iuser, frame);
24+ }
25+ }
26 if (subframes) {
27 emit_from_mesh(flowobj, fds, ffs, &bb_temp, subframe_dt);
28 }

But again: After all, this patch is not neccessary and I have made sure that this is working from scratch in 2.92 and also from the file bug.blend posted here

In 2.92:

  • open bug.blend
  • in Physics Properties tab for Plane
    • enable Texture
    • set Mapping to UV
    • select UV Map
  • in Texture tab for Plane
    • IMPORTANT: ensure Auto Refresh is ON (this is missing from the video)

optionally (for a bit more reliable cache handling/invalidation)

  • in Physics Properties tab for Cube
    • set Cache Type Modular
    • use Baking (instead of the Replay cache)
WARNING: in both cases it might be mandatory to restart blender and/or removing the cache directory before the bake/replay cache actually works correctly. This does not seem to be related to the use of image sequences as flow emission source though and can be seen in other situations as well (@Sebastián Barschkis (sebbas): correct me if I am wrong)

So since this was a bit back and forth, I would like others to confirm this is actually working for them as well [from scratch or from the steps I have provided after opening the example file posted here] before closing this report.
@Maxim Ponomarov (ponomarovmax) : can you confirm?

Maxim Ponomarov (ponomarovmax) added a comment.Jan 17 2021, 9:00 AM

@Philipp Oeser (lichtwerk) Tried to repeat bug with original bug.blend file (also used your last recomendations):

  1. Check settings (uv-mapping, autorefresh, modular cache)
  2. Bake new dynamic paint images (looks good)
  3. Save file. Restart blender.
  4. Enable Texture mode in inflow plane, select proper texture, uv-mapping.
  5. Bake... and nothing. No smoke.
  6. Disable Texture. Bake. Smoke appears from whole surface.
  7. Enable Texture -> No smoke.

Then I created new scene (same setup).
Baked new dynamic paint images, created Smoke physics setup with Texture.
And... it actualy worked as it expected.
Then I enabled Dissolve in Dyn. Paint, rebaked images again and flow rate changed as it expected.

I think with Mantaflow implementation something changed and now everything works fine (original bug was found in old blender fluid engine).
Now seems everything works OK.

Philipp Oeser (lichtwerk) closed this task as Resolved.Jan 17 2021, 9:41 PM
In T71713#1094971, @Maxim Ponomarov (ponomarovmax) wrote:

Now seems everything works OK.

Thx getting back!
Lets close this then, if issues creep up again, please keep reporting!