Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![version="110"]
- #[varying] static zed: Vec2;
- #[uniform] static prev_frame: Sampler2D;
- #[uniform] static _p_scale: f32;
- fn complex_to_tex(p: Vec2) -> Vec2 {
- (0.5/_p_scale)*p + Vec2(0.5, 0.5)
- }
- fn complex_mul(a: Vec2, b: Vec2) -> Vec2 {
- Vec2(a.x*b.x - a.y*b.y, a.x*b.y + a.y*b.x);
- }
- fn in_bounds(p: Vec2) -> bool {
- macro_rules! check {
- ($i:ident) => ((p.$i >= -_p_scale) && (p.$i <= _p_scale))
- }
- check!(p.x) && check!(p.y)
- }
- #[uniform] static param: Vec2;
- fn main() {
- let color: Vec3;
- let oldpoint: Vec2 = complex_mul(zed, zed) + 1.6*param;
- if in_bounds(oldpoint) {
- let oldcoord: Vec2 = complex_to_tex(oldpoint);
- color = 1.8*texture2D(prev_frame, oldcoord).brg;
- } else {
- color = Vec3(1.0, 0.0, 0.0);
- }
- gl_FragColor = Vec4(color, 1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement