Pulsing Emission value causing stuttering

I’m using a simple script to pulse the emission parts of my material. It works nicely as I want it to, but whenever it’s active it’s causing my game to stutter when my player moves around.

This is the code I am using:

public class emissionPulse : MonoBehaviour {

        public float frequency = 1f;
        public Material material;
        public Color emissionColor;

        // Use this for initialization
        void Start()
        {
        emissionColor = material.GetColor("_EmissionColor");
        }

        // Update is called once per frame
        void Update()
        {
            float glow = (2 + Mathf.Cos(Time.time * frequency));
            material.SetColor("_EmissionColor", emissionColor * glow);
        }
}

Anyone know why this is happening or another way to achieve this effect?

Thanks.

Put all that math inside your shader. Throw away your script. It’ll be much faster.

Using a shader is probably a better idea, thanks.

I don’t see how the performance would change at all unless the OP is missing out a ton of info like he’s spawned 100s of these.

Nope there is only one object.