- Home /
Shader and Texture Scrolling depending on Direction
I am trying to scroll a texture using its uv but I don't get the result I need.
The aim is to have two components, the speed and the direction. I would like to define the direction in normalized values and the speed should influence the velocity of the scrolling according to the direction.
If I change the speed at runtime, I don't want to have some hiccups but maybe this should not be handled but the GPU.
How can I do that in a better way, maybe using matrix ?
Here is an example but the result is not as good as expected.
uv.xy = uv.xy + frac(_Time.y * float2(_Direction.x, _Direction.y));
Answer by helarts · Nov 04, 2015 at 06:53 PM
I think you have to use your own time value (and get rid of the frac) if you want to change the speed without hiccups. You can take a look at 'unity_DeltaTime' shader variable if you want to do the same on the GPU but you'll have to figure how to store your time value.
public float speed = 1f;
float myTime = 0f;
Update()
{
myTime += Time.deltaTime * speed;
material.SetFloat("_MyTime", myTime);
}
Your answer
Follow this Question
Related Questions
Assigning UV Map to model at runtime 0 Answers
Transparent shader and scrolling 0 Answers
Alpha Texture Deserves a Separate File? 1 Answer
Visible seams on borders when tiling texture 1 Answer
Making textures Scroll/ animate textures 5 Answers