I need to change _GlowPower value within the range of 1 to 6 in runtime.
I’ve tried this:
float _GlowPower;
float _UpDown = 0;
float _TimeElapsed = 0;
void surf(Input IN, inout SurfaceOutput o) {
if (_UpDown == 0) {
_GlowPower += _Time.z - _TimeElapsed;
}
if (_UpDown == 1) {
_GlowPower -= _Time.z - _TimeElapsed;
}
if (_GlowPower <= 1) {
_UpDown = 0;
}
if (_GlowPower >= 6) {
_UpDown = 1;
}
_TimeElapsed = _Time.z;
IN.color = _ColorTint;
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb * IN.color;
half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
o.Emission = _GlowColor.rgb * pow(rim, _GlowPower);
}
_GlowPower always goes up, never down.
How could achieve this inside the shader?
I know I can do this by script, but I need to keep this clean.
Thanks in advice.