- Home /
Jerky Procedural Material Animation
I am trying to animate a procedural material "Electric Liquid". I was able get the material animated but the animation is jerky (looks like a "framerate" of under 10) while the frame rate in the stats window shows well above 200.
I also looked at the Procedural material animation update rate, and even that was above 40+.
I know the animation can be smooth as silk and beautiful, but how do i get it there? What am I doing wrong?
There are very few objects in the scene.
Thanks
using UnityEngine;
using System.Collections;
public class liquidEnergyAnimC : MonoBehaviour {
public ProceduralMaterial substance;
public float flow = 1;
void Start()
{
substance = renderer.sharedMaterial as ProceduralMaterial ;
}
void LateUpdate()
{
flow = flow + (2 * Time.smoothDeltaTime);
substance.SetProceduralFloat("Flow", flow);
substance.RebuildTextures();
}
}
No not yet... I may need to abandon the animated texture all together. Transport portals just don't look right with static maps.
Wait a $$anonymous$$ute, do we need to pre-render the sequence of images with the procedural materials, then just run it as a normal animation? Domt really know enough about Unity to say for sure.
Let's keep each other posted if we find solutions.
Answer by Banister88 · Sep 13, 2012 at 02:44 AM
We figured this out, for everyone interested. The reason that the animation was jerky (for us any way) was that the value that we were exposing and using (via the .SetProceduralFloat(..)) was in the beginning of our node graph in substance designer. So what happened was that we would increase/decrease the value for that float in code, then the substance generator would have to push it all the way down the render pipe, performing all the math and calculations that come with that. So, we had our artists get creative and figure out a way to move it towards the output node in substance designer. So now, that float variable is one of the last nodes to be calculated by the substance, before it outputs, making it so that most of the work is done before hand! Therefore, the texture generation is significantly faster and the animation plays very, very smooth. I'm the programmer, not the artist, so I'm not sure what kind of tricks were used in order to perform the operation later on in the graph, but that is what solved the problem. The farther a node is from the output, the more things need to be performed on this node, making it longer to generate the texture (and when moved in code, appear jerky). Hope this helps!!
excellent find! appreciate the info! I'll get to work on the solution. thanks!
O$$anonymous$$ i know this is and old topic, but trying to do the same thing myself, using the code above i get it to work only playing in game mode and adding the "Electric_Liquid" back into the "Substance" box. its there before i go into game play mode but gets replace by "none (Procedural $$anonymous$$aterial)" after i enter it. I'm Pretty new to working with Unity but would really like to get the to work
Edit: the console is telling me this when i enter game mode "NullReferenceException: Object reference not set to an instance of an object liquidEnergyAnimC.LateUpdate () (at Assets/liquidEnergyAnimC.cs:17)"
Answer by ThermalFusion · Sep 06, 2012 at 05:28 PM
Try using RebuildTexturesImmediately function instead of RebuildTextures.
Yep same issue, in the case of immediate it stutters the runtime completely ins$$anonymous$$d of just the texture. :(