POV-Ray : Newsgroups : povray.advanced-users : Fake shadows in 32-bit images? : Re: Fake shadows in 32-bit images? Server Time
1 May 2024 15:34:47 EDT (-0400)
  Re: Fake shadows in 32-bit images?  
From: Bald Eagle
Date: 28 Aug 2021 09:25:00
Message: <web.612a391b7599ad521f9dae3025979125@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

Hi Kenneth,

Hope you're enjoying that sweet Virginia heat...  ;)




> But I'm mostly curious as to just what the additional y-SCALING is for, and why
> it solves the problem-- and why it is SO sensitive to the particular tiny scale
> that is used (the number of zeros). I'm obviously not grasping why y needs any
> scaling at all.

> From experimenting, a y-scale of simply 1.0 shifts the matrix-object to a
> completely different orientation(!), which I don't understand. And a y-scale of
> 0.000001 makes the object disappear, as mentioned. I would have assumed that the
> matrix transform *by itself* would have been enough to shear the 'shadow object'
> correctly, in concert with the -vnormalize(...) trick-- no additional scaling
> required.

So, my example was just a quick and dirty proof of concept, so there are no
bells, whistles, sanity checks, or other things to flesh out the code for
robustness - meaning that it probably only works correctly if you understand why
it works in the first place.

If you are trying this with an object not at/on the origin, you'll probably get
some very strange results.

Let's suppose you have a cube.  You shine a light on it from somewhere high up
and in front of the cube.  The shadowed region created would look like a slanted
version of the cube - a parallelpiped.  The angle of that is dependent upon a
vector between the object and the light source (playing fast and loose here).

The top & front of the cube is lit, and the back and bottom is in shadow.  Since
the idea here is to use the object itself to create the fake shadow object, we
need to deform it, to sort of fold it down flat to meet the ground plane.
Let's say the cube is a cardboard box, and you cut off the sides to make a
square cardboard tube.  You can now push the box back and down with a "racking
force" to rotate the tube into an increasingly oblique/eccentric parallelogram
until you flatten it out on the ground.  Actual location of the light being
ignored for the sake of simplicity, that would be your shadow.

So how do we get that with something complicated and virtual?
Let's say the cube's back side is at z=0, and the light source is at some -z, +y
location.  The direction / location of the thing we need to make the shadow of
is in the +z, -y location.  (think: object {Cube rotate x*180} )
But now that's just a copy of the object that is underneath where the shadow
would be, so we need to scale it very small in y to get the flattened shadow
version that we want.

I have some things to do today, and the coffee needs to percolate in, but in
describing this all, I see where a problem or two might lie, and how to fix
them.

I think the shadow image should probably be scaled in -y in order to flip it
onto the same side of the ground plane, then it won't disappear.


Perhaps a completely different shear transform would allow an object pigment
pattern to be used as the top of a layered texture to shadow a complex 3D shadow
region instead of just the simple plane version I came up with off-the-cuff.

Hope that helps (?)

- The Northern Walker


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.