Advertisement
davidusprime

pixel wave shader

Apr 12th, 2022
1,723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fixed2 uv = i.uv;
  2.  
  3. // for a 32x32 texture, could also be a parameter.
  4. fixed pixelWidth = 1.0 / 32.0;
  5. fixed pixelHeight = 1.0 / 32.0;
  6.  
  7. // make it so the UV is always a multiple of pixelWidth and pixelHeight.
  8. uv = fixed2(round(uv.x / pixelWidth) * pixelWidth, round(uv.y / pixelHeight) * pixelHeight);
  9.  
  10. // offset the UV according to the sine value of the current time.
  11. fixed waveSpeed = 0.0625;
  12. fixed waveLength = 8;
  13. fixed2 uvOffset = fixed2(sin(uv.y * waveLength + _Time.z) * waveSpeed, sin(uv.x * waveLength + _Time.z) * waveSpeed);
  14. uv.x += uvOffset.x;
  15. uv.y += uvOffset.y;
  16.  
  17. i.uv = uv;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement