# Invalid shadow shape affected by the aspect ratio of the window

**URL:** https://discourse.vtk.org/t/invalid-shadow-shape-affected-by-the-aspect-ratio-of-the-window/12000
**Category:** Development
**Created:** [July 22, 2023, 9:46am UTC](https://discourse.vtk.org/t/invalid-shadow-shape-affected-by-the-aspect-ratio-of-the-window/12000 "2023-07-22T09:46:16Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sohnishi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sohnishi/32/6507_2.png) [@sohnishi](https://discourse.vtk.org/u/sohnishi)
#### Post date: [July 22, 2023, 9:46am UTC](https://discourse.vtk.org/t/invalid-shadow-shape-affected-by-the-aspect-ratio-of-the-window/12000/1 "2023-07-22T09:46:16Z")

</div>

I’ve compiled and executed the Shadow example([https://examples.vtk.org/site/Cxx/Rendering/Shadows/](https://examples.vtk.org/site/Cxx/Rendering/Shadows/)).

However, Shadows were correct only when the window aspect ratio is 1.  
The window size can be adjusted at Shadows.cxx:58 `renderWindow->SetSize(640, 480);`.

I set the window size to 400x400 and got correct shadows.  
 ![400x400](https://discourse.vtk.org/uploads/default/original/2X/e/eab9e8452535c3352a04048bd658ac6e30742b17.png)

However, to 1600x400, the shadows became elliptical and invalid black regions were created.

 ![1600x400](https://discourse.vtk.org/uploads/default/original/2X/9/9dcc34a15166236c69bd82bd9909a66c985267aa.png)

Both images are created from the same source code except for the window size settings (Shadows.cxx:58).

How can I avoid this problem?

---

<div class="post-metadata">

### Author: ![Sean\_Curtis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sean_curtis/32/718_2.png) [@Sean\_Curtis](https://discourse.vtk.org/u/Sean_Curtis)
#### Post date: [October 25, 2023, 9:41pm UTC](https://discourse.vtk.org/t/invalid-shadow-shape-affected-by-the-aspect-ratio-of-the-window/12000/2 "2023-10-25T21:41:11Z")

</div>

See also [#5057](https://discourse.vtk.org/t/vtk-incorrect-shadows/5057).

I’d love to see what can be done about this as well.

---

<div class="post-metadata">

### Author: ![sohnishi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sohnishi/32/6507_2.png) [@sohnishi](https://discourse.vtk.org/u/sohnishi)
#### Post date: [November 24, 2023, 11:24am UTC](https://discourse.vtk.org/t/invalid-shadow-shape-affected-by-the-aspect-ratio-of-the-window/12000/3 "2023-11-24T11:24:24Z")

</div>

I found a workaround.

Just set the window size to square first, call vtkRenderWindow::Render(), and then resize vtkRenderWindow to the desired size.

It’s not clean, but it works.

 ![shadows](https://discourse.vtk.org/uploads/default/original/2X/0/02616814cfe28c919ade0c9ff7cbdc16505f3f89.png)
