lorensen/VTKExamples

Shadows example looks weird

Opened this issue · 7 comments

Hi there!

I'm trying to run the Python Rendering/Shadows example with vtk8.1.0, on windows 10 (through anaconda3).

The result seems a bit odd to me. I can't understand where the rectangular shaded area comes from. What is casting that long straight shadow on the floor? It can't be from the sphere as a sphere would only cast oblong shadows.

the code is just as in master, the lights are at [0, 1, 0.2], and [1.0, 1.0, 1.0]

image

Hi Andrew, and thanks for replying to my issue.

I've place some spheres where the lights would be, and as you can see they are all above. I can't understand how the plane can cast a shadow on itself like that?

image

if i use the cow as you suggested (and I move both lights up by 1 unit, +[0, 1., 0.] i get this which also looks weird - and different from the image in https://lorensen.github.io/VTKExamples/site/Python/Rendering/Shadows/:

image

Finally, if i switch to vtk 8.2.0, the result is the following:
image
image

which is similar to the image in https://lorensen.github.io/VTKExamples/site/Python/Rendering/Shadows/
But why is the light not reaching all the way until the end of the plane?
And why is the behaviour so much different between v8.1.0 and 8.2.0? is there a hidden light somewhere?

thanks, Michele

Look at ShadowsLightsDemo and you will see that the light is actually a frustum, hence the rectangular cross-section on the plane. I'll do a Python version of this soon. It will appear in the master but not on the web pages at this point in time.

If you use this as a plane source, you can see the illuminated rectangular areas quite clearly:

    plane = vtk.vtkPlaneSource()
    expand = 1
    x = bounds[1] - bounds[0] + (rnge[0] * expand)
    y = -0.5
    z = bounds[5] - bounds[4] + (rnge[2] * expand)

    plane.SetOrigin(-x, y, -z)
    plane.SetPoint1(x, y, -z)
    plane.SetPoint2(-x, y, z)
    plane.SetXResolution(100)
    plane.SetYResolution(100)

As to the differences between the versions of VTK this is to be expected since there is a process of continuous improvement going on. As you can see the VTK 8.2 rendering is much better than VTK 8.1. The VTK 9.0 rendering is even better.

Regards
Andrew

Here is a Python version of ShadowsLightsDemo : ShadowsLightsDemo.zip

Regards
Andrew

Hi Andrew, thanks for the explanation. Thanks also for the ShadowLightsDemo.

Yes i see the rectangular areas clearly. But why does the light frustum cover a smaller volume than the light cone?

In a similar way I notice in the ShadowLightsDemo that while the pyramid shown as frustum for white light embraces the whole expected cone volume, and does indeed reach large part of the plane, yet the plane is not illuminated entirely. Again the question is why the frustum doesn't embrace the whole cone, and why does it not match what the prop seem to show?

image

Thanks

I cam answer that, it is probably best if you ask on the VTK Discourse forum.