I have an actor with a static mesh. The static mesh has a material for which the opacity should be controlled by a texture that is a 10 second 24fps animation. This actor is spawned multiple times in the game and I want each separate instance to have its material animation being played separately and independently. How to do this?
A flipbook doesn’t work because 10 seconds at 24 fps at 756x756px gives a total size of the sprite sheet of 7560x18144px, an image which Unreal cannot handle.
A media player with a media texture doesn’t work because each instance of the actor and the material becomes linked and when a new one spawns the animation starts all over again on all existing instances of the actor.
A solution would be to dynamically create new media players and new media textures and new dynamic material instances for each new spawning of the actor, using Construct Object From Class and link them all accordingly. Spawning media players works. Spawning media textures doesn’t - they spawn succesfully but do not play the video from the linked media player, instead staying all white. Apparently this is a known bug that’s been around for years and still hasn’t been fixed. I hear some people got it to work by constructing the media texture in construction script, but that hasn’t worked for me.
Are there any other options to do this? This seems like such basic functionality.
What does “controlled by a texture” mean in the sense of “not wanting to use a flipbook?”
How does the texture control the opacity? Do you have a few opacity textures, and you want to switch between them at predetermined times?
You could create a blueprint or a sequence with a curve that animates some parameter to the material instance.
You can also create your material to lerp opacity between two configured textures, and use a curve to update the lerp, and use specific property animations to update the texture parameters of the material instance.
Jam it all into a blueprint that creates a new MaterialInstanceDynamic for each instance of your object, and they should all be separately controlled.
It’s just a texture plugged into the opacity socket. There doesn’t need to be multiple textures, just one, but it’s a movie, not a static image. It’s a 10-second animation. I would be down to use a flipbook but like i said the sprite sheet for that would be enormous and Unreal doesn’t support textures over 8K
You are basically telling me to recreate my animation with math inside the material editor. I have considered this, but I honestly am not good enough with node math to do that. Here is the animation in question: https://gfycat.com/quarterlyactualkoi
If you can tell me how to recreate a circular unveiling mask like that with just node math, I will gladly use it.
But at the same time I really hope there is another way that would allow me to actually play my video on the texture because the next time I run into this problem I might need a more complex animation.
You’re talking about the flipbook-function in a material, but there are also flipbook assets which don’t use spritesheets thus support more frames. But I also wouldn’t recommend to use them for longer animations since they’re very demanding in terms of VRAM. I had a 10 second animation in a flipbook and it used 300 MB of VRAM. The movie assets are loading the movies directly from the disc, I guess, what is also demanding in other terms.
I think the best approach for simple animations are particle systems, level sequences or animated materials with something like a “progress”-parameter. You can rebind actors to a new level sequence player also to play multiple instances of the level sequence at the same time.
But in this case I would use a material, yes. You could animate the “progress”-parameter with a level sequence or a curve.
For the mask something like this:
That’s a good answer, thank you! I ended up using something very similar to your node setup, just with a pre-generated radial gradient texture. It works very well and I think in this case it should be the best performance-wise.
For future reference, can you tell me in short what you mean by using particle systems or level sequences? Is there an option in those to import a movie file that I’m unaware of, or are you speaking of completely different use cases where other types of animations can be emulated in them?
I mean to make the animation with a particle system or level sequencer. With a particle system like this: https://www.youtube.com/watch?v=aE0EbWdnjTI&t=4s. Looks on the floor like an imported animation, but it are different rotating planes with materials.
However, this works best with repeating animations or animations with one scene. It’s hard to make a particle system for a more complex movie, e.g. on frame 0 create a rectangle, on frame 23 move it 200 cm up, on frame 48 rotate it for 90 degrees on it’s z-axis and so on. This is where level sequences are better https://docs.unrealengine.com/en-US/…iew/index.html. It’s basically like making animations on the timeline with After Effects (but is of course not so complex like After Effects. Do achieve the same effects one needs to combine materials, textures, particle systems, code…).
You can recreate that in a shader graph! Either use trigonometry, or simply use a ramped spiral gradient texture and set a cut-off value that increases over time.