Unity 5 Shader : Pulsing Emission range via scripting
Im trying to get a pulsing emission shader with a randomiser to mimic the effect of a candle inside an object. I created the shader already and it works but when I applying the following code to the object it turn purple when I press play.
Here is the shader code:
I cant seem to access the EmissiveIntensity and change the range of it.
Answer by Papercuter · Oct 21, 2015 at 06:34 PM
After some Tweaking, I finally managed to make it work using a Csharp script.
here it is (now just need to adjust the speed of the transitions):
void Start () {
}
// Update is called once per frame
void Update () {
float random = Random.Range(0.5f, 1.5f);
float intensity = Mathf.PerlinNoise(random, Time.time);
gameObject.GetComponent<Renderer>().material.SetFloat("_EmissiveIntensity", intensity);
}
}
Answer by Ziplock9000 · Apr 15, 2016 at 12:42 AM
Emission range is not the same as intensity. Do to know how to change the former?
Your answer
![](https://koobas.hobune.stream/wayback/20220612042157im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Shader Help : Add emission to my shader. 2 Answers
How can i fix/properly use this code ? 0 Answers
Emissive Blended Decal 0 Answers
Water shader change 0 Answers
How would I exclued parts of a texture from the lighting system? 0 Answers