Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Merge main into fix/particle-birth-history

tylerjenningsw20d8501ea28d
diff --cc crates/render/src/cache.rs
index 47b2c0ebd,89e9fd1c9..bbec7c96a
--- a/crates/render/src/cache.rs
+++ b/crates/render/src/cache.rs
@@@ -481,14 -494,13 +494,14 @@@ fn hash_values(h: &mut KeyHasher, ctx:
}
/// Cache key for the processed (source → masks → effects) buffer of `layer` at the context
- /// time, or `None` when the layer must not be cached (footage, precomps, cameras, adjustment
+ /// time, or `None` when the layer must not be cached (movie footage, precomps, cameras, adjustment
/// layers…).
pub fn layer_key(ctx: &EvalCtx, layer: &Layer, scale: f64, draft: bool, blur: bool) -> Option<u64> {
- // Time effects see property values at other times. Keyframes are part of the hashed
- // structure (and the layer time is folded in), but expressions may read other layers at
- // those times, which the key cannot see: such layers are not cached.
- if reads_other_times(layer) && layer.props.children.iter().any(|c| matches!(c, Node::Group(g) if g.match_id != "transform" && has_expression(g))) {
+ // Time effects (and CC Particle World's Birth Rate history) see property values at other
+ // times. Keyframes are part of the hashed structure (and the layer time is folded in), but
+ // expressions may read other layers at those times, which the key cannot see: such layers
+ // are not cached.
+ if history_unkeyable(layer, None) {
return None;
}
key_with(ctx, layer, scale, draft, blur, false)
@@@ -521,12 -527,34 +534,40 @@@ fn reads_other_times(layer: &Layer, eff
})
}
+/// The layer reads values at other times (see [`reads_other_times`]) and has expressions
+/// (outside Transform), whose results at those times the key can't see.
+fn history_unkeyable(layer: &Layer, effects: Option<usize>) -> bool {
+ reads_other_times(layer, effects) && layer.props.children.iter().any(|c| matches!(c, Node::Group(g) if g.match_id != "transform" && has_expression(g)))
+}
+
+ /// A still image (no proxy): its layer is cached like a text or shape layer, so the GPU
+ /// compositor uploads it once, not every frame (#1812: four 21120 px plates re-uploaded by every
+ /// preview worker ran the GPU out of memory). Movies and sequences stay in the media pool only.
+ fn still_footage(ctx: &EvalCtx, item: effectcraft_project::ItemId) -> bool {
+ ctx.project.item(item).is_some_and(|it| it.proxy.is_none() && matches!(&it.kind, ItemKind::Footage(f) if f.kind == FootageKind::Still))
+ }
+
+ /// Does the layer have an animated mask that motion blur may draw at other times (Layer ▸ Mask ▸
+ /// Motion Blur On, or Same As Layer with the layer blurred)?
+ fn mask_motion_blur(ctx: &EvalCtx, layer: &Layer, blur: bool) -> bool {
+ use effectcraft_project::{GroupKind, MaskMotionBlur};
+ fn animated(g: &PropGroup) -> bool {
+ g.children.iter().any(|c| match c {
+ Node::Prop(p) => !p.keys.is_empty() || p.has_expression(),
+ Node::Group(sub) => animated(sub),
+ })
+ }
+ ctx.comp.enable_motion_blur
+ && layer.masks().is_some_and(|m| {
+ m.groups().any(|g| match g.kind {
+ GroupKind::Mask { motion_blur, .. } => {
+ (motion_blur == MaskMotionBlur::On || (motion_blur == MaskMotionBlur::SameAsLayer && blur)) && animated(g)
+ }
+ _ => false,
+ })
+ })
+ }
+
fn has_expression(g: &PropGroup) -> bool {
g.children.iter().any(|c| match c {
Node::Prop(p) => p.has_expression(),