Hi!
This is a sort of continuation of the same eye material seen in
this post from a little while back.
I'm at it again in this rabbit hole of creating planar eyes instead of spherical ones, making my work endlessly more difficult - but as I'm starting to see some results, I like to think it will be worth it in the end.
My next challenge after setting up the eye material with offset parameters, has been setting up a character blueprint that allows the value of the skeletal mesh's eye bone rotations (using a scene object parented to each eye bone in order to reset the value, because there are some apparent rotation offsets I don't want to deal with) to control the texture offset of each eye. That event graph looks like this:
This is meant to overwrite the existing eye material on runtime with a Material Instance Dynamic (I wish I didn't have to do it like this so I had more control when editing). The eye material itself can be seen here (I will add further parameters to this, but it serves its purpose for now):
I have almost solved this entire issue, but I have
two remaining issues for the eye material (eyelid material might have its own issues, who knows):
1: As you can see in this test trying to line up the material offset values with the actual eye bone rotation values so it's as close as reasonably possible, there's some flickering going on, where the eye material is reverting back to its default values. Running some print strings, it's not the eye bone rotations, and it's not the offset values (displayed in the gif, Y | X), at least as far as I can tell in the event graph. I can't debug in the material editor to my knowledge, and that material is being replaced anyway. This is part of why I don't like replacing the material at runtime.
2: The material instance dynamic does not work with sequencer. Again, because the material instance dynamic is generated at runtime, and the movie render queue doesn't render at runtime, I get no eye animation. I need this in order to render my target footage later on. I don't know how eventual cutscenes are handled, but I might need the material instance dynamic there too.
At this time I'm a bit lost, but I'm so close to solving this. Any ideas?
Replies
I'd immediately attribute it to either some sort of desynch or a number getting out of acceptable ranges on the way into the material
your'e not doing something silly like creating your materialinstancedynamic on tick are you ?
As you can see, there are clearly frames where the eyes are looking straight forward while being green. Correct me if I'm wrong, but that means only the offset is doing weird things. Does this narrow things down?
And yes, I made sure to create the material instance dynamic on begin play, not tick 🙂
you can't really tell what's going on based on the green value - it's almost certainly gone out of 0-1 range due to the offset amount and anything past 1 or less than 0 isn't going to be apparent
for the left eye's x rotation you have a value anywhere between -1.5 and 1.5
In your material you add .35 so we're between -1.15 and 1.85
you apply that as an offset value to your scaled (*.34) UVs
at maximum rotation it looks like the right edge of your texture is at a uv coord of 2.19 - which is probably not what you're hoping for (i'm tired so my mental arithmetic is probably off - don't laugh at me)
I think your offset is too big and it's causing the UVs to wrap round - the might not be the cause of the flickering but it's weird and won't be helping you to debug.
what happens if you try this..?
multiply the scaled and offset UVs by a number (3/4/5), floor the result and divide by the same number, pass that into the eyeball color
You should be able to see if the UVs are getting out of range because the eyeball will get brighter
Personally I'd be remapping the rotation to a value between -1 and 1 in the blueprint and then scaling when it gets into the material
- also that branch where you set green can be replaced by a max()
Sorry I seemed to abandon this thread, but the summer holiday is somewhat sacred here.
I reopened the project and started to create a separate material using the same offset. I compiled, and Unreal crashed. I opened the project, and the skeletal mesh was gone from the blueprint. Fortunately the blueprints were still there, but the test animation for the eyes was gone. I don't even remember how I made that now, because there's no exported animation anywhere in my project folders, or in the Unreal project. I think I made the test animation using Sequencer. So I made a new one in Maya, exported that, and inexplicably, now it works! Same values, I believe. 90 degrees in all four directions, material offset exceeding a value of 1 like before - but now it never fails. Was it the fact that I (IIRC) made the previous animation using Sequencer?
It's wonderful that it works now, but I'd love to know what was causing that.
Now, that is only one of two issues I have. The other, is that the material instance dynamic is created on runtime, which prevents me from using this way of animating the eyes for anything that is meant to be pre-rendered. Is there any way to create this material instance dynamic from the movie render queue? That's the only way I see it working, other than manually animating the eye offset for pre-rendered scenes, and would be less accurate and more time consuming.