lorensen / VTKExamples

The VTK examples, formerly hosted on media wiki
Apache License 2.0
342 stars 157 forks source link

Shadows example looks weird #655

Open cosw0t opened 4 years ago

cosw0t commented 4 years ago

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

ajpmaclean commented 4 years ago

If you use cow.g you get the image as on the Web site. If no image is supplied it defaults to a sphere on a plane. In the case of the sphere and plane some of the shadowing may be from the plane. Try moving the lights.

On Wed, 20 May 2020, 20:04 michele-arrival, notifications@github.com wrote:

Hi there!

I'm trying to run the Shadows Example with vtk8.2.0, on windows (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 shadow on the floor?

[image: image] https://user-images.githubusercontent.com/54891577/82433420-5118d380-9a89-11ea-8838-f9038670c656.png

Am I wrong at seeing the same thing in the image in this page? https://lorensen.github.io/VTKExamples/site/Python/Rendering/Shadows/

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lorensen/VTKExamples/issues/655, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBHQO4YPOGJ4DAJPCSZSATRSOTLJANCNFSM4NFZGBJA .

Andrew Maclean

cosw0t commented 4 years ago

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

ajpmaclean commented 4 years ago

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

ajpmaclean commented 4 years ago

Here is a Python version of ShadowsLightsDemo : ShadowsLightsDemo.zip

Regards Andrew

cosw0t commented 4 years ago

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

ajpmaclean commented 4 years ago

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

cosw0t commented 4 years ago

Thank you very much.

For reference: https://discourse.vtk.org/t/shadowlightsdemo-extents-of-shadows-light-frustum-darkened-areas/3410