Advertisement
djdee

polar.shader file

Apr 7th, 2024
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. //Polar coordinates shader by Ben Hickling
  2.  
  3.  
  4.  
  5. #define PI 3.14159265359
  6.  
  7. uniform float texture_offset = 0.0;
  8.  
  9. uniform float rotation = 0.0;
  10. uniform float scale = 1.0;
  11.  
  12.  
  13.  
  14. float4 mainImage(VertData v_in) : TARGET
  15. {
  16. float2 tex_coord = v_in.uv;
  17. float2 uv = v_in.uv - float2(0.5, 0.5);
  18.  
  19. float ang = atan2(uv.y, uv.x);
  20. float len = length(uv);
  21.  
  22. tex_coord.x = len;
  23. tex_coord.y = ang * 0.5 / PI + 0.5 + rotation;
  24.  
  25. return image.Sample(textureSampler, frac((tex_coord + float2(texture_offset,0)) * scale));
  26.  
  27. }
Tags: shader fx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement