Mantaflow gas emission by texture image sequences not updating #71713

Closed
opened 2019-11-20 22:40:53 +01:00 by Maxim Ponomarov · 18 comments

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: 002f5b826c
Worked: 2.79b latest

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

Video example bug.mp4

Exact steps for others to reproduce the error
Open:
bug.blend

  • 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.
**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: `002f5b826c` Worked: 2.79b latest **Short description of error** Auto refresh for image sequences broken (image texture node, texture for smoke masking) Video example [bug.mp4](https://archive.blender.org/developer/F8149182/bug.mp4) **Exact steps for others to reproduce the error** Open: [bug.blend](https://archive.blender.org/developer/F8149176/bug.blend) - 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.

Added subscriber: @ponomarovmax

Added subscriber: @ponomarovmax
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

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

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

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.
caching_bug.mp4

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. 8) Also set texture to control flow. 9) 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. [caching_bug.mp4](https://archive.blender.org/developer/F8267321/caching_bug.mp4)
Member

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

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

I can confirm. Used to work on the previous system. ![GIF.gif](https://archive.blender.org/developer/F8268577/GIF.gif)

Added subscriber: @BeckersC

Added subscriber: @BeckersC
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Philipp Oeser self-assigned this 2021-01-13 18:17:50 +01:00
Member

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

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 changed title from Auto refresh for image sequences not updates to Mantaflow gas emission by texture image sequences not updating 2021-01-13 18:19:46 +01:00
Member

Changed status from 'Confirmed' to: 'Needs User Info'

Changed status from 'Confirmed' to: 'Needs User Info'
Member

Added subscriber: @sebbas

Added subscriber: @sebbas
Member

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)
P1888: T71713_snippet



diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 4356f1246ed..2ac8fc1ae44 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -42,6 +42,7 @@
 #include "BKE_effect.h"
 #include "BKE_fluid.h"
 #include "BKE_global.h"
+#include "BKE_image.h"
 #include "BKE_lib_id.h"
 #include "BKE_modifier.h"
 #include "BKE_pointcache.h"
@@ -2833,6 +2834,13 @@ static void compute_flowsemission(Scene *scene,
         }
         /* Emission from mesh. */
         else if (ffs->source == FLUID_FLOW_SOURCE_MESH) {
+          /* Need to update the textures image user to the correct frame. */
+          if ((ffs->flags & FLUID_FLOW_TEXTUREEMIT) && ffs->noise_texture) {
+            Tex *noise_texture = ffs->noise_texture;
+            if (BKE_image_is_animated(noise_texture->ima)) {
+              BKE_image_user_frame_calc(noise_texture->ima, &noise_texture->iuser, frame);
+            }
+          }
           if (subframes) {
             emit_from_mesh(flowobj, fds, ffs, &bb_temp, subframe_dt);
           }

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 (@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.
@ponomarovmax : can you confirm?

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) [P1888: T71713_snippet](https://archive.blender.org/developer/P1888.txt) ``` diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 4356f1246ed..2ac8fc1ae44 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -42,6 +42,7 @@ #include "BKE_effect.h" #include "BKE_fluid.h" #include "BKE_global.h" +#include "BKE_image.h" #include "BKE_lib_id.h" #include "BKE_modifier.h" #include "BKE_pointcache.h" @@ -2833,6 +2834,13 @@ static void compute_flowsemission(Scene *scene, } /* Emission from mesh. */ else if (ffs->source == FLUID_FLOW_SOURCE_MESH) { + /* Need to update the textures image user to the correct frame. */ + if ((ffs->flags & FLUID_FLOW_TEXTUREEMIT) && ffs->noise_texture) { + Tex *noise_texture = ffs->noise_texture; + if (BKE_image_is_animated(noise_texture->ima)) { + BKE_image_user_frame_calc(noise_texture->ima, &noise_texture->iuser, frame); + } + } if (subframes) { emit_from_mesh(flowobj, fds, ffs, &bb_temp, subframe_dt); } ``` 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 (@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. @ponomarovmax : can you confirm?

@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.

@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.
Member

Changed status from 'Needs User Info' to: 'Resolved'

Changed status from 'Needs User Info' to: 'Resolved'
Member

In #71713#1094971, @ponomarovmax wrote:
Now seems everything works OK.

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

> In #71713#1094971, @ponomarovmax wrote: > Now seems everything works OK. Thx getting back! Lets close this then, if issues creep up again, please keep reporting!
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#71713
No description provided.