# Implementing Shadows

**URL:** https://discourse.vtk.org/t/implementing-shadows/4756
**Category:** Support
**Created:** [November 30, 2020, 6:19pm UTC](https://discourse.vtk.org/t/implementing-shadows/4756 "2020-11-30T18:19:41Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Darshan\_K](https://discourse.vtk.org/user_avatar/discourse.vtk.org/darshan_k/32/2664_2.png) [@Darshan\_K](https://discourse.vtk.org/u/Darshan_K)
#### Post date: [November 30, 2020, 6:19pm UTC](https://discourse.vtk.org/t/implementing-shadows/4756/1 "2020-11-30T18:19:41Z")

</div>

Hello,  
I’m currently working on a project, and I’m facing some issues with lighting. I have started with this minimalist program and work on it:

```python
import vtk

sphere_1 = vtk.vtkSphereSource()
sphere_1.SetCenter(25, 0, 0)
sphere_1.SetRadius(10)
sphere_1.SetThetaResolution(120)
sphere_1.SetPhiResolution(120)
mapper_1 = vtk.vtkPolyDataMapper()
mapper_1.SetInputConnection(sphere_1.GetOutputPort())
actor_1 = vtk.vtkActor()
actor_1.SetMapper(mapper_1)

sphere_2 = vtk.vtkSphereSource()
sphere_2.SetCenter(0, 0, 0)
sphere_2.SetRadius(10)
sphere_2.SetThetaResolution(120)
sphere_2.SetPhiResolution(120)
mapper_2 = vtk.vtkPolyDataMapper()
mapper_2.SetInputConnection(sphere_2.GetOutputPort())
actor_2 = vtk.vtkActor()
actor_2.SetMapper(mapper_2)

sphere_3 = vtk.vtkSphereSource()
sphere_3.SetCenter(-25, 0, 0)
sphere_3.SetRadius(10)
sphere_3.SetThetaResolution(120)
sphere_3.SetPhiResolution(120)
mapper_3 = vtk.vtkPolyDataMapper()
mapper_3.SetInputConnection(sphere_3.GetOutputPort())
actor_3 = vtk.vtkActor()
actor_3.SetMapper(mapper_3)
actor_3.GetProperty().SetOpacity(0)

light = vtk.vtkLight()
light.SetPosition(-25, 0, 0)
light.SetConeAngle(180)

renderer = vtk.vtkRenderer()
renderer.AddActor(actor_1)
renderer.AddActor(actor_2)
renderer.AddActor(actor_3)
renderer.AddLight(light)

render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)

shadows = vtk.vtkShadowMapPass()
seq = vtk.vtkSequencePass()

passes = vtk.vtkRenderPassCollection()
passes.AddItem(shadows.GetShadowMapBakerPass())
passes.AddItem(shadows)

seq.SetPasses(passes)

cameraP = vtk.vtkCameraPass()
cameraP.SetDelegatePass(seq)

glrenderer = renderer
glrenderer.SetPass(cameraP)

iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(render_window)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
iren.Initialize()
iren.Start()

```

My intention is to have three spheres, with a light at the center of `sphere_1`, so that `sphere_1` acts analogous to the sun, the half of `sphere_2` facing `sphere_1` lit, while the other half is dark, and `sphere_3` completely dark, being eclipsed by `sphere_2`.  
`sphere_2` and `sphere_1` render the way I want, but I expected `sphere_1` to be lit as well.  
From what I understand, the problem is because of making it transparent, using `actor_3.GetProperty().SetOpacity(0)`. Is there a workaround?

---

<div class="post-metadata">

### Author: ![unhumano](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/u/3be4f8/32.png) [@unhumano](https://discourse.vtk.org/u/unhumano)
#### Post date: [March 23, 2023, 10:24am UTC](https://discourse.vtk.org/t/implementing-shadows/4756/2 "2023-03-23T10:24:40Z")

</div>

did you found a workaround?
