How it works...

The scrolling system starts with the declaration of a couple of properties, which will allow the user of this shader to increase or decrease the speed of the scrolling effect itself. At their core, they are float values being passed from the material's Inspector tab to the surface function of the shader. For more information on shader properties, see Chapter 2, Creating Your First Shader.

Once we have these float values from the material's Inspector tab, we can use them to offset our UV values in the shader.

To begin this process, we first store the UVs in a separate variable called scrolledUV. This variable has to be float2/fixed2 because the UV values are being passed to us from the Input structure:

struct Input { float2 ...

Get Unity 2018 Shaders and Effects Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.