Skip to main content

PERSIST_FRAG

Constant PERSIST_FRAG 

Source
pub const PERSIST_FRAG: &str = "// persist.frag \u{2014} motion trails by remembering the last frame.\r\n//\r\n// The new frame is laid over what the previous one left behind, decayed.\r\n// Taking the brighter of the two rather than blending them keeps a moving\r\n// thing sharp and leaves a fading comet of where it was, which is what an\r\n// eye does with something bright moving fast in the dark. Static things\r\n// are the same in both frames and are unaffected.\r\n#version 330 core\r\n\r\nin vec2 f_uv;\r\nuniform sampler2D u_scene;\r\nuniform sampler2D u_history;\r\nuniform float u_persistence;\r\n\r\nout vec4 o_color;\r\n\r\nvoid main() {\r\n    vec4 now  = texture(u_scene, f_uv);\r\n    vec4 then = texture(u_history, f_uv) * u_persistence;\r\n    o_color = max(now, then);\r\n}\r\n";
Expand description

Motion trails: the brighter of this frame and the decayed last one.