# Clipped DropShadow render issue using J8 Direct2D

**URL:** <https://forum.juce.com/t/clipped-dropshadow-render-issue-using-j8-direct2d/65110>\
**Category:** Windows\
**Created:** [February 5, 2025, 8:01am UTC](https://forum.juce.com/t/clipped-dropshadow-render-issue-using-j8-direct2d/65110 "2025-02-05T08:01:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pflugshaupt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/pflugshaupt/32/13206_2.png) [@pflugshaupt](https://forum.juce.com/u/pflugshaupt)\
**Post date:** [February 5, 2025, 8:01am UTC](https://forum.juce.com/t/clipped-dropshadow-render-issue-using-j8-direct2d/65110/1 "2025-02-05T08:01:45Z")

</div>

While comparing the ‘DropShadow for Paths’ rendering on macOS and Windows I found an edge case in the D2D Renderer that leads to a visible line where Shadows should fade out. I guess this is another one for @matt . Feels like it’s an edge case related to non-int coordinates from scaling for images and clipping.

Using this code I see a faint line where the top shadow should fade out.  
This only happens for specific offsets (this -11) and scaling factors and doesn’t happen if the shadow isn’t clipped:

```auto
void MainComponent::paint (juce::Graphics& g)
{
    g.fillAll (juce::Colours::grey);

	juce::DropShadow ds(juce::Colours::black.withAlpha(0.7f), 10, {1, 2});

    // Top (clipped)
	juce::Path p3;
	p3.addRectangle(juce::Rectangle<int>{0, -11, getWidth(), 10});
	ds.drawForPath(g, p3);

    // Left
	ds.drawForRectangle(g, {80, 80, 40, 40});

    // Middle
	juce::Path p;
	p.addRectangle(juce::Rectangle<int>(160, 80, 40, 40));
	ds.drawForPath(g, p);

    // Right
	juce::Path p2;
	p2.addEllipse(juce::Rectangle<float>(240, 80, 40, 40));
	ds.drawForPath(g, p2);
}

```

This happens on the latest 8.0.6 develop. This is with Windows Scaling 150%

 ![shadowissues_150](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/8/0/80297057fb7b0f583407e16b5fea68efcb21dad1.png)

And 200%

 ![shadowissues_200](https://us1.discourse-cdn.com/flex026/uploads/juce/original/3X/b/6/b604346fd008c3bfa207cef1af982db2581c8b59.png)

The same code renders correctly with Windows scaling set to 125% or 100%.

---

<div class="post-metadata">

**Author:** ![matt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/matt/32/18340_2.png) [@matt](https://forum.juce.com/u/matt)\
**Post date:** [February 5, 2025, 7:12pm UTC](https://forum.juce.com/t/clipped-dropshadow-render-issue-using-j8-direct2d/65110/2 "2025-02-05T19:12:10Z")

</div>

OK. I’m going to be traveling for bit; I’ll check it out when I can.

Matt

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [February 5, 2025, 8:00pm UTC](https://forum.juce.com/t/clipped-dropshadow-render-issue-using-j8-direct2d/65110/3 "2025-02-05T20:00:25Z")

</div>

I think the problem is that the blur/shadow image is rendered at the logical pixel size, and then scaled up. Rendering the blur directly at the final screen scale seems to fix the problem. I’ve got a fix on the way.

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [February 6, 2025, 9:23pm UTC](https://forum.juce.com/t/clipped-dropshadow-render-issue-using-j8-direct2d/65110/4 "2025-02-06T21:23:26Z")

</div>

There’s a fix for this issue available on the develop branch:

> <https://github.com/juce-framework/JUCE/commit/95d416ab77cc132a7d663ca438574b2d9a820e75>
