Hey all!
I’m not sure where this post fits, so I’m leaving it here. I do hope I can get some direction on where I’m going wrong with a shader that, I think, is probably pretty simple for someone with more experience. I hope that once I get an answer, this post can be helpful to someone else in a similar predicament. I currently have a shader that I am using to go from a static image, to one that scrolls (think: a conveyor for Megaman X). This works pretty well when going from a speed of 0 to a desired speed. It will slowly speed up to the new speed via a trigger. However, I would also like to slow it back down to a crawl, or even a stop. My issue is that the texture doesn’t slow down the scroll, but actually starts to appear to reverse direction completely until reaching the newly set speed, which uses a mathf.movetowards command. I’d like the scroll speed to simply speed up or slow down if changed (unless going form positive to negative, obviously). My current shader code is as follows:
fixed4 frag (v2f i) : SV_Target
{
_XSpeed = _XSpeed * _Time.w;
_Difference += _XSpeed;
i.uv.x += _Difference;
fixed4 col = tex2D(_MainTex, i.uv);
// UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
I hope someone can see where I’m going wrong here. Thanks in advance for any information!
EDIT: Sorry for the double post!