I want to customize unity's standard shader, I have downloaded it's source code and just want to customize it, so that smoothness of albedo alpha property should change by x(for example 0.1f) per frame. Sorry if this is bad question, but I googled everything i could but found nothing. Thanks in advance.
Here is the image to make my question more clear, I want to change this value on every frame from shader script
It is possible to do animations inside the shader if that's what you want, but keep in mind that a shader cannot remember any kind of information about the state of your model except what is going on at this exact frame. If you want that, you'll need to use Iggy's solution, by setting values from code.
You can however animate things using the current time, and potentially together with some math like sine waves for a pulsating effect. I wouldn't try to modify the standard shader if i were you though, that is a can of worms you do not want to open. In fact, Unity designed surface shaders for this exact purpose. A surface shader can be configured to do anything that the standard shader does, but with far less code.
If you go Create>Shader>Surface Shader, you get a good base. You can also find more information here and here. For readability i will not write down the code for all the parameters in my examples, but you can see in the template roughly how it works.
In your case, you can use the _Time
variable to animate the glossiness. _Time is a 4d vector, where the x, y, z, and w values represent different speeds of time (t/20, t, t*2, t*3). For instance, you could do something like this:
void surf (Input IN, inout SurfaceOutput o) {
// This will make the smoothness pulsate with time.
o.Smoothness = sin(_Time.z);
}
If you really need an effect to start at a certain time, then you can define an offset timestamp and set it from code like in Iggy's answer. If you want the shader to only trigger once you set the stamp, you can use some kind of condition based on the value of the timestamp.
float _StartTime
void surf (Input IN, inout SurfaceOutput o) {
// This will make the smoothness pulsate with time.
// saturate() clamps the value between 0 and 1.
if (_StartTime > 0)
o.Smoothness = sin(saturate(_Time.y - _StartTime));
else
o.Smoothness = 0;
}