Advertisement
Guest User

Untitled

a guest
Jan 31st, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #![version="110"]
  2.  
  3. #[varying] static zed: Vec2;
  4. #[uniform] static prev_frame: Sampler2D;
  5. #[uniform] static _p_scale: f32;
  6.  
  7. fn complex_to_tex(p: Vec2) -> Vec2 {
  8. (0.5/_p_scale)*p + Vec2(0.5, 0.5)
  9. }
  10.  
  11. fn complex_mul(a: Vec2, b: Vec2) -> Vec2 {
  12. Vec2(a.x*b.x - a.y*b.y, a.x*b.y + a.y*b.x);
  13. }
  14.  
  15. fn in_bounds(p: Vec2) -> bool {
  16. macro_rules! check {
  17. ($i:ident) => ((p.$i >= -_p_scale) && (p.$i <= _p_scale))
  18. }
  19.  
  20. check!(p.x) && check!(p.y)
  21. }
  22.  
  23. #[uniform] static param: Vec2;
  24.  
  25. fn main() {
  26. let color: Vec3;
  27. let oldpoint: Vec2 = complex_mul(zed, zed) + 1.6*param;
  28.  
  29. if in_bounds(oldpoint) {
  30. let oldcoord: Vec2 = complex_to_tex(oldpoint);
  31. color = 1.8*texture2D(prev_frame, oldcoord).brg;
  32. } else {
  33. color = Vec3(1.0, 0.0, 0.0);
  34. }
  35.  
  36. gl_FragColor = Vec4(color, 1.0);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement