Repository navigation
New nodes: 'Drop Shadow', 'Inner Shadow', and 'Outer Glow'; make the 'Blur' node work on any graphic - #4976
New nodes: 'Drop Shadow', 'Inner Shadow', and 'Outer Glow'; make the 'Blur' node work on any graphic#4976Keavon wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
6 issues found across 44 files
Confidence score: 3/5
- Non-uniform and sheared transforms can clip or distort effects in
vello_effects.rsandraster_effects.rs. Preserve per-axis reach when calculating effect bounds. - Nested shadows, glows, and blurs can be clipped by the parent opacity/blend layer in
renderer.rs. Include nested effects reach in the layer bounds. InnerShadow::reachineffects.rsomits spread, so inner shadows can disappear when offset and blur are zero. Include spread in the reach calculation.- Serialized JavaScript inputs can forge effect extents through
UpdateEffectsReachindocument_message.rs. Mark the internal message variant as skipped during serialization.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="node-graph/libraries/graphic-types/src/effects.rs">
<violation number="1" location="node-graph/libraries/graphic-types/src/effects.rs:157">
P2: `InnerShadow::reach` leaves out `spread`, but the renderer dilates the inverted silhouette by `spread`. With offset 0 and blur 0, the margin becomes 0, so an opaque raster gets no inner shadow at all. Include `spread` in the reach, as the other shadow arms do.</violation>
</file>
<file name="editor/src/messages/portfolio/document/utility_types/network_interface/structure.rs">
<violation number="1" location="editor/src/messages/portfolio/document/utility_types/network_interface/structure.rs:206">
P2: `update_effects_reach` replaces `layer_effects_reach` without calling `self.document_metadata.mark_changed()`. The cached `document_bounds` with stroke and effects reads this value, so it can go stale until the next `mark_changed`. Add the call like the other render-reported setters in this file.</violation>
</file>
<file name="node-graph/libraries/wgpu-executor/src/vello_effects.rs">
<violation number="1" location="node-graph/libraries/wgpu-executor/src/vello_effects.rs:202">
P2: Effects collapse non-uniform transforms to a geometric-mean scale, so blur and spread are clipped or distorted whenever an item is stretched differently on each axis. Preserve per-axis scales (and the transformed kernel bounds) instead of using `sqrt(abs(det))` for both axes.</violation>
</file>
<file name="node-graph/libraries/rendering/src/renderer.rs">
<violation number="1" location="node-graph/libraries/rendering/src/renderer.rs:1210">
P2: The parent opacity/blend layer clips nested effects because its clip includes only the parent's own reach, not `nested_effects_reach(element)`. Inflate this layer by both reaches so child shadows, glows, and blurs remain visible.</violation>
</file>
<file name="node-graph/libraries/raster-kernels/src/raster_effects.rs">
<violation number="1" location="node-graph/libraries/raster-kernels/src/raster_effects.rs:51">
P2: The margin calculation underestimates effect reach for sheared transforms, so CPU-evaluated shadows and blurs can be clipped. Compute the per-axis bound from the row norms of `document_to_pixels` rather than reciprocal column lengths.</violation>
</file>
<file name="editor/src/messages/portfolio/document/document_message.rs">
<violation number="1" location="editor/src/messages/portfolio/document/document_message.rs:328">
P2: `UpdateEffectsReach` is an internal render-output message but lacks `#[serde(skip)]`, so serialized JS inputs can forge arbitrary effect extents and alter export bounds. Mark this variant as skipped like the two internal metadata-update variants above.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| match self { | ||
| Self::Blur { radius, .. } => 3. * radius.max(0.), | ||
| Self::DropShadow { offset, blur, spread, .. } => offset.length() + spread.max(0.) + 3. * blur.max(0.), | ||
| Self::InnerShadow { offset, blur, .. } => offset.length() + 3. * blur.max(0.), |
There was a problem hiding this comment.
P2: InnerShadow::reach leaves out spread, but the renderer dilates the inverted silhouette by spread. With offset 0 and blur 0, the margin becomes 0, so an opaque raster gets no inner shadow at all. Include spread in the reach, as the other shadow arms do.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At node-graph/libraries/graphic-types/src/effects.rs, line 157:
<comment>`InnerShadow::reach` leaves out `spread`, but the renderer dilates the inverted silhouette by `spread`. With offset 0 and blur 0, the margin becomes 0, so an opaque raster gets no inner shadow at all. Include `spread` in the reach, as the other shadow arms do.</comment>
<file context>
@@ -0,0 +1,275 @@
+ match self {
+ Self::Blur { radius, .. } => 3. * radius.max(0.),
+ Self::DropShadow { offset, blur, spread, .. } => offset.length() + spread.max(0.) + 3. * blur.max(0.),
+ Self::InnerShadow { offset, blur, .. } => offset.length() + 3. * blur.max(0.),
+ Self::OuterGlow { blur, spread, .. } => spread.max(0.) + 3. * blur.max(0.),
+ }
</file context>
| Self::InnerShadow { offset, blur, .. } => offset.length() + 3. * blur.max(0.), | |
| Self::InnerShadow { offset, blur, spread } => offset.length() + spread.max(0.) + 3. * blur.max(0.), |
|
|
||
| /// Update how far each layer's effects paint past its content. | ||
| pub fn update_effects_reach(&mut self, new_layer_effects_reach: HashMap<LayerNodeIdentifier, f64>) { | ||
| self.document_metadata.layer_effects_reach = new_layer_effects_reach; |
There was a problem hiding this comment.
P2: update_effects_reach replaces layer_effects_reach without calling self.document_metadata.mark_changed(). The cached document_bounds with stroke and effects reads this value, so it can go stale until the next mark_changed. Add the call like the other render-reported setters in this file.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At editor/src/messages/portfolio/document/utility_types/network_interface/structure.rs, line 206:
<comment>`update_effects_reach` replaces `layer_effects_reach` without calling `self.document_metadata.mark_changed()`. The cached `document_bounds` with stroke and effects reads this value, so it can go stale until the next `mark_changed`. Add the call like the other render-reported setters in this file.</comment>
<file context>
@@ -200,4 +200,9 @@ impl NodeNetworkInterface {
+
+ /// Update how far each layer's effects paint past its content.
+ pub fn update_effects_reach(&mut self, new_layer_effects_reach: HashMap<LayerNodeIdentifier, f64>) {
+ self.document_metadata.layer_effects_reach = new_layer_effects_reach;
+ }
}
</file context>
| self.document_metadata.layer_effects_reach = new_layer_effects_reach; | |
| self.document_metadata.mark_changed(); | |
| self.document_metadata.layer_effects_reach = new_layer_effects_reach; |
| textures, | ||
| size: UVec2::new(content.width(), content.height()), | ||
| }; | ||
| let length_scale = lengths_to_pixels.determinant().abs().sqrt(); |
There was a problem hiding this comment.
P2: Effects collapse non-uniform transforms to a geometric-mean scale, so blur and spread are clipped or distorted whenever an item is stretched differently on each axis. Preserve per-axis scales (and the transformed kernel bounds) instead of using sqrt(abs(det)) for both axes.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At node-graph/libraries/wgpu-executor/src/vello_effects.rs, line 202:
<comment>Effects collapse non-uniform transforms to a geometric-mean scale, so blur and spread are clipped or distorted whenever an item is stretched differently on each axis. Preserve per-axis scales (and the transformed kernel bounds) instead of using `sqrt(abs(det))` for both axes.</comment>
<file context>
@@ -0,0 +1,592 @@
+ textures,
+ size: UVec2::new(content.width(), content.height()),
+ };
+ let length_scale = lengths_to_pixels.determinant().abs().sqrt();
+
+ // The content at full strength, which casts every silhouette, and the content faded by the fill, which shows in the result
</file context>
| RenderBoundingBox::None | ||
| }; | ||
| let layer_rect = match bounds { | ||
| RenderBoundingBox::Rectangle(bounds) => Some(inflate_bounds(bounds, compositing.reach())), |
There was a problem hiding this comment.
P2: The parent opacity/blend layer clips nested effects because its clip includes only the parent's own reach, not nested_effects_reach(element). Inflate this layer by both reaches so child shadows, glows, and blurs remain visible.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At node-graph/libraries/rendering/src/renderer.rs, line 1210:
<comment>The parent opacity/blend layer clips nested effects because its clip includes only the parent's own reach, not `nested_effects_reach(element)`. Inflate this layer by both reaches so child shadows, glows, and blurs remain visible.</comment>
<file context>
@@ -885,54 +1186,63 @@ fn render_graphic_item_to_vello<'a>(
+ RenderBoundingBox::None
+ };
+ let layer_rect = match bounds {
+ RenderBoundingBox::Rectangle(bounds) => Some(inflate_bounds(bounds, compositing.reach())),
+ _ => None,
+ };
</file context>
| RenderBoundingBox::Rectangle(bounds) => Some(inflate_bounds(bounds, compositing.reach())), | |
| RenderBoundingBox::Rectangle(bounds) => Some(inflate_bounds(bounds, compositing.reach() + nested_effects_reach(element))), |
| let pixels_per_length = DVec2::new(pixels_to_document.x_axis.length(), pixels_to_document.y_axis.length()).recip(); | ||
|
|
||
| // A margin around the image to hold the blur and shadows cast past its edges, cut short for an image that would grow too large | ||
| let mut margin = (effects.reach() * pixels_per_length).ceil(); |
There was a problem hiding this comment.
P2: The margin calculation underestimates effect reach for sheared transforms, so CPU-evaluated shadows and blurs can be clipped. Compute the per-axis bound from the row norms of document_to_pixels rather than reciprocal column lengths.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At node-graph/libraries/raster-kernels/src/raster_effects.rs, line 51:
<comment>The margin calculation underestimates effect reach for sheared transforms, so CPU-evaluated shadows and blurs can be clipped. Compute the per-axis bound from the row norms of `document_to_pixels` rather than reciprocal column lengths.</comment>
<file context>
@@ -0,0 +1,202 @@
+ let pixels_per_length = DVec2::new(pixels_to_document.x_axis.length(), pixels_to_document.y_axis.length()).recip();
+
+ // A margin around the image to hold the blur and shadows cast past its edges, cut short for an image that would grow too large
+ let mut margin = (effects.reach() * pixels_per_length).ceil();
+ let grown_size = size + 2. * margin;
+ if grown_size.x * grown_size.y > MAX_PIXELS_WITH_MARGIN {
</file context>
| UpdateAppearanceAttributes { | ||
| appearance_attributes: HashMap<NodeId, Arc<Appearance>>, | ||
| }, | ||
| UpdateEffectsReach { |
There was a problem hiding this comment.
P2: UpdateEffectsReach is an internal render-output message but lacks #[serde(skip)], so serialized JS inputs can forge arbitrary effect extents and alter export bounds. Mark this variant as skipped like the two internal metadata-update variants above.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At editor/src/messages/portfolio/document/document_message.rs, line 328:
<comment>`UpdateEffectsReach` is an internal render-output message but lacks `#[serde(skip)]`, so serialized JS inputs can forge arbitrary effect extents and alter export bounds. Mark this variant as skipped like the two internal metadata-update variants above.</comment>
<file context>
@@ -325,6 +325,9 @@ pub enum DocumentMessage {
UpdateAppearanceAttributes {
appearance_attributes: HashMap<NodeId, Arc<Appearance>>,
},
+ UpdateEffectsReach {
+ effects_reach: HashMap<NodeId, f64>,
+ },
</file context>
| UpdateEffectsReach { | |
| #[serde(skip)] | |
| UpdateEffectsReach { |
No description provided.