Page MenuHome

Video texture / Image Sequence not refreshing under eevee
Closed, ResolvedPublic

Tokens
"Love" token, awarded by evilvoland."Love" token, awarded by franalburquerque."Party Time" token, awarded by pistoltoto."Love" token, awarded by philm."Love" token, awarded by Yanis."Heartbreak" token, awarded by ogierm."Pterodactyl" token, awarded by vsautter."Love" token, awarded by riidom."Love" token, awarded by esdw22."Love" token, awarded by Nallic.
Authored By

Description

System Information
Mac OSX and gtx 980 ti

Blender Version
Broken: 2.80.0 3bc8bc0709a

When navigating in timeline, shader with video texture doesn't refresh with eevee , but it's working when I switch to cycles

EDIT: same result in viewport or render (ctrl F12)

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Ahh.. but it doesn't work for looping videos.

And for some even more bazaar reason - it won't go past frame 97. I guess it's a memory problem? Tried the same scene with a few different videos in the same scene so far... but I might make this reporting bugs on a script rather than Blender if I'm not careful. I guess I'll be putting my greenscreen nodegroup for material nodes on hold.

@Mike Futcher (yogyog) let's just hope this get's fixed properly :)

Surely video textures and image sequences will be debugged if the Spring movie team requires their use! ;-)
Very nice work in progress to see on the cloud of blender :-)

Philipp Oeser (lichtwerk) renamed this task from Video texture not refreshing under eevee to Video texture / Image Sequence not refreshing under eevee.

Thanks for the script Daniel
However, it seems that it doesn't work when you change the Start Frame to something higher.
But a very good workaround till the bug is solved.

Well I hoped something like that would work:

diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index e9d874bd1ee..2cf3494802d 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -40,6 +40,8 @@
 #include "BLI_link_utils.h"
 #include "BLI_mempool.h"
 
+#include "DEG_depsgraph_query.h"
+
 #include "intern/gpu_codegen.h"
 
 struct GPUVertFormat *g_pos_format = NULL;
@@ -802,7 +804,7 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp, struct
 			GPUTexture *tex = NULL;
 
 			if (input->ima) {
-				double time = 0.0; /* TODO make time variable */
+				double time = DEG_get_ctime(DST.draw_ctx.depsgraph);
 				tex = GPU_texture_from_blender(input->ima, input->iuser, GL_TEXTURE_2D, input->image_isdata, time);
 			}
 			else {

But GPU_texture_from_blender does not do anything with time...

Also had a quick look and as a starting point it seems GPUInput input->iuser Image User was always NULL. [without the image user you dont have access to framnumber etc...]
I tried to fix this and building upon what @Clément Foucault (fclem) tried I get something that updates movies [sequences also -- but only if the image node has a keyframe, that's another issue to solve...] with flickering. [eh, another issue to solve]

Thought I should drop this here so it is not lost:

1
2
3diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
4index 6584b6953d5..615adeb61f1 100644
5--- a/source/blender/draw/intern/draw_manager_data.c
6+++ b/source/blender/draw/intern/draw_manager_data.c
7@@ -40,6 +40,8 @@
8 #include "BLI_link_utils.h"
9 #include "BLI_mempool.h"
10
11+#include "DEG_depsgraph_query.h"
12+
13 #include "intern/gpu_codegen.h"
14
15 struct GPUVertFormat *g_pos_format = NULL;
16@@ -802,7 +804,7 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp, struct
17 GPUTexture *tex = NULL;
18
19 if (input->ima) {
20- double time = 0.0; /* TODO make time variable */
21+ double time = DEG_get_ctime(DST.draw_ctx.depsgraph);
22 tex = GPU_texture_from_blender(input->ima, input->iuser, GL_TEXTURE_2D, input->image_isdata, time);
23 }
24 else {
25diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
26index 6f939261729..a6fd71585e6 100644
27--- a/source/blender/gpu/intern/gpu_draw.c
28+++ b/source/blender/gpu/intern/gpu_draw.c
29@@ -285,7 +285,7 @@ GPUTexture *GPU_texture_from_blender(
30 ImageUser *iuser,
31 int textarget,
32 bool is_data,
33- double UNUSED(time))
34+ double time)
35 {
36 if (ima == NULL) {
37 return NULL;
38@@ -293,9 +293,11 @@ GPUTexture *GPU_texture_from_blender(
39
40 /* Test if we already have a texture. */
41 GPUTexture **tex = gpu_get_image_gputexture(ima, textarget);
42+ /*
43 if (*tex) {
44 return *tex;
45 }
46+ */
47
48 /* Check if we have a valid image. If not, we return a dummy
49 * texture with zero bindcode so we don't keep trying. */
50@@ -312,6 +314,7 @@ GPUTexture *GPU_texture_from_blender(
51 }
52
53 /* check if we have a valid image buffer */
54+ BKE_image_user_frame_calc(iuser, (int)time);
55 ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
56 if (ibuf == NULL) {
57 *tex = GPU_texture_from_bindcode(textarget, bindcode);
58diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
59index 524f7a5c8e2..c13a1064794 100644
60--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
61+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
62@@ -75,8 +75,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
63 };
64
65 Image *ima = (Image *)node->id;
66- ImageUser *iuser = NULL;
67 NodeTexImage *tex = node->storage;
68+ ImageUser *iuser = &tex->iuser;
69 const char *gpu_node_name = (tex->projection == SHD_PROJ_BOX)
70 ? names_box[tex->interpolation]
71 : names[tex->interpolation];

maybe we should get @Brecht Van Lommel (brecht) and @Sergey Sharybin (sergey) on board?

@Brecht Van Lommel (brecht), @Sergey Sharybin (sergey): not sure whom to assign this to? (I could spend more time investigating, but maybe it is obvious to one of you?)

btw. we have this working (refreshing sequences and movies) in camera background images, see view3d_draw_bgpic, but implementation is different/separate from GPU_texture_from_blender in that it does the whole drawing [not just the texture refresh...]

Brecht Van Lommel (brecht) raised the priority of this task from Confirmed, Medium to Confirmed, High.Jan 14 2019, 4:33 AM

Marking as high priority since this gets reported often.

This is a rather complicated issue caused mainly by copy-on-write changes. Previously on each frame change Blender would loop over (most) image users, recalculate the frame number and free the GPU texture if needed.

It did not do this for Cycles/Eevee image texture nodes in materials, only BI materials. That is easily solved, though for best playback performance it could be done in a smarter way than before.

The main issue however is copy-on-write. Both the original and COW datablocks need to be updated. This could be done as part of the depsgraph now for image users that are in the depsgraph, marking such materials or objects as depending on time.

Refreshing the GPU texture is problematic as well. Currently each image datablock stores and owns a single GPU texture at a single frame. However it is now possible to have multiple depsgraphs each at their own time. A proper solution to this likely means moving ownership of the GPU texture from the image to the image user or depsgraph, or having some kind of caching system.

Hey,

Some news about this?

And for some even more bazaar reason - it won't go past frame 97. I guess it's a memory problem? Tried the same scene with a few different videos in the same scene so far... but I might make this reporting bugs on a script rather than Blender if I'm not careful. I guess I'll be putting my greenscreen nodegroup for material nodes on hold.

I just discovered that if you toggle the sidebar (N) in the image editor, it gives you options to change the amount of frames to use in a movie/image sequence. This seems to be unaffected by the settings on the image texture node.

Still trying to figure out how to use more than one image sequence texture....any solutions?

@Daniel Craven (Craven) , Yep.
The working variant for several objects with video textures is to open several working windows with image editors and in each of them open different textures:

Daniel Craven (Craven) - thankyou! I will be putting a tutorial together on this in the next week.

Same problem here in two scenarios:

  • Image sequence textures under Eevee
  • Image Empties using a video with autorefresh (the usual way) in viewport, no matter which render engine is set

When will the bug get fixed?

@Philipp Oeser (lichtwerk) , i try to compile blender (da1da3053d75) with your solution, but your variant don't give needed result (black material with video texture and pink - with sequences).
Working variant with this code in node_shader_tex_image.c :

	Image *ima = (Image *)node->id;
	ImageUser *iuser = NULL;
	NodeTexImage *tex = node->storage;
	//ImageUser *iuser = &tex->iuser;

That give expected result (video and sequences update in viewport but render - sequences is flickering), but only when object is selected and active.

Someone can help with it? I don't understand some strings:
in all BKE_image update/check frame/etc uses cfra as integer.

But in GPU_texture_from_blender used time in double.

Ofcourse, in sequences/video textures logically to use integer (as frames). So, why using double?

This comment was removed by pistol ioan (pistoltoto).

I would like to send some resources for this problem particularly to speed the process, is it possible?

I would like to send some resources for this problem particularly to speed the process, is it possible?

I support. Ready to transfer money for a speedy solution to the problem. Where to transfer?

It's being worked on, just requires some deep changes to the dependency graph and GPU image loading code to work properly in 2.8.

It's being worked on, just requires some deep changes to the dependency graph and GPU image loading code to work properly in 2.8.

Thanks for the heads up @Brecht Van Lommel (brecht)

It's being worked on, just requires some deep changes to the dependency graph and GPU image loading code to work properly in 2.8.

Thank you @Brecht Van Lommel (brecht) I'm broadcast tv director. We are designing a tv show with a real time dynamic CGenerated scenography. Because of Eevee Blender can be ideal for that. But the real time movie clip elements insertion\playback is obviously crucial. We need a lot of video contribution in scenography. Have you an idea of how much time will take the fix? Thank you so much.

Also very interested in this!!

As another workaround:

import bpy

def my_handler(scene):
    print("Frame Change", scene.frame_current)
    bpy.data.images['YOUR_IMAGESEQENCE.0001.png'].reload()

bpy.app.handlers.frame_change_pre.append(my_handler)

Now you can scrub the timeline and see the changes.

ah, well...nevermind... workaround has been posted before

I would like to send some resources for this problem particularly to speed the process, is it possible?

I support. Ready to transfer money for a speedy solution to the problem. Where to transfer?

+1

It's being worked on, just requires some deep changes to the dependency graph and GPU image loading code to work properly in 2.8.

... so, for this problem I think 1000$ is not enough.

Thank goodness!
Thank you Brecht Van Lommel 👍👍👍

You were always my hero, right after you created Cycles!
I knew you could do it!

@Brecht Van Lommel (brecht) , I do not refuse my words, please tell me where to transfer money?

Thank you so much!

@Vladimir (evilvoland): anyone is welcome to contribute to the development fund, this bugfix was funded by it.
https://fund.blender.org/

@Brecht Van Lommel (brecht) , I wanted to thank You personally, but the support of the whole team is also important. Thank you very much for the work!

If you're not already subscribed to https://fund.blender.org/ go do it now! You can start as low as $6 a month :)

Thanks @Brecht Van Lommel (brecht) !

Thanks so much Blender team - you are the most awesome people ! - I am so gratefull for the work you do! This fix was really important to me as well :)