M13.8: Advanced 3D iris depth of field, collapsed precomps, extruded strokes
Depth of field in Advanced 3D comps uses the camera's iris (Fast Rectangle, Triangle to Decagon, rotation, roundness, aspect, diffraction fringe) and highlight gain/threshold/ saturation through the Classic 3D bokeh kernel. Collapsed precomps in an Advanced 3D comp add their nested layers as real geometry (meshes, extrusions, cards) lit by the parent; 2D collapsed precomps draw nested 3D layers with the parent's renderer. Text and shape strokes extrude as bevelled meshes stacked in paint order (model extrude_stacked). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
553a51316c
commit
07da394ccb
@@ -299,3 +299,19 @@ pub fn extrude(outlines: &[Outline], p: &ExtrudeParams) -> Primitive {
|
||||
}
|
||||
prim
|
||||
}
|
||||
|
||||
/// Gap (pixels) between stacked extrusions of one layer: paint drawn later (a stroke over its
|
||||
/// fill, an upper shape group) sits this much nearer the camera per level, so coplanar front
|
||||
/// caps never fight in the depth buffer and the stacking order of the 2D layer is kept.
|
||||
pub const STACK_GAP: f64 = 0.02;
|
||||
|
||||
/// [`extrude`] at stacking level `level` (0 = bottom paint of the layer): the mesh moves
|
||||
/// `level × STACK_GAP` towards the camera (−z).
|
||||
pub fn extrude_stacked(outlines: &[Outline], p: &ExtrudeParams, level: usize) -> Primitive {
|
||||
let mut prim = extrude(outlines, p);
|
||||
let dz = (level as f64 * STACK_GAP) as f32;
|
||||
for v in &mut prim.positions {
|
||||
v[2] -= dz;
|
||||
}
|
||||
prim
|
||||
}
|
||||
|
||||
@@ -360,3 +360,16 @@ fn gltf_cameras_and_punctual_lights() {
|
||||
let d = lights[0].world.apply_vec(vec3(0.0, 0.0, -1.0));
|
||||
assert!((d.y + 1.0).abs() < 1e-6, "{d:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stacked_extrusions_move_towards_the_camera() {
|
||||
let square = Outline { outer: vec![[0.0, 0.0], [10.0, 0.0], [10.0, 10.0], [0.0, 10.0]], holes: vec![] };
|
||||
let p = ExtrudeParams { bevel: BevelStyle::None, bevel_depth: 0.0, hole_bevel: 1.0, depth: 10.0 };
|
||||
let base = extrude(std::slice::from_ref(&square), &p);
|
||||
let up = super::extrude::extrude_stacked(std::slice::from_ref(&square), &p, 3);
|
||||
assert_eq!(base.indices, up.indices);
|
||||
for (a, b) in base.positions.iter().zip(&up.positions) {
|
||||
assert!((a[2] - b[2] - 3.0 * super::extrude::STACK_GAP as f32).abs() < 1e-6);
|
||||
assert_eq!((a[0], a[1]), (b[0], b[1]));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user