POV-Ray : Newsgroups : povray.advanced-users : Fake shadows in 32-bit images? : Re: Fake shadows in 32-bit images? Server Time27 Sep 2021 09:38:47 EDT (-0400)
 Re: Fake shadows in 32-bit images?
 From: Kenneth Date: 30 Aug 2021 04:35:00 Message:
```
{
"@context": "https://schema.org",
"@type": "DiscussionForumPosting",
"dateCreated": "2021-08-30T08:35:00+00:00",
"datePublished": "2021-08-30T08:35:00+00:00",
"author": {
"@type": "Person",
"name": "Kenneth"
}
}
"Bald Eagle" <cre### [at] netscapenet> wrote:
>
> ...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.
> [snip]  ...so we need to scale it very small in y to get the flattened shadow
> version that we want.
>

The ground plane? As in, horizontal?

Oh!!!  [*** slaps forehead, and kicks self in butt**]

So the matrix-oriented object is horizontal! Or more precisely (using a y-scale
of plain old 1.0 for starters) that object is now aligned along the light's
direction vector,  but 'flipped' through the origin and sheared a bit, thanks to
the -vnormalize vector and the matrix itself...and because y is your 'basis
vector' for the matrix.  It's all suddenly clear to me-- one of those 'eureka'
moments. Thanks!

We Southern Walkers can be a bit slow-witted at times :-P

I originally thought the matrix object was still vertical(!) but simply sheared
left and down-- which is why I couldn't understand why it should be scaled in y.
The camera view and angle fooled me. But now the tiny y-scaling makes perfect
sense-- not only to 'flatten' the object, but to bring that flatness into very
close parallelism with the x/z plane, to look like a correctly-placed shadow.

I added a few different cameras/positions to see what was going on, and did some
simple animations while changing the scale. Very interesting! There is actually
a small *range* of y-scalings that gets rid of the intersecting-surface
artifacts, before the object completely disappears (which itself must be a
precision issue.) I'm thinking that if the object was made 100-1000 times
larger, rather than just 1-unit tall, the y-scale would probably not need to
be so exacting.

BTW, I eliminated the  ground-plane object; it doesn't seem to serve a purpose,
and kind of gets in the way.

The one thing that still puzzles me is *why* the smaller and smaller y-scale
eliminates those intersecting-surface artifacts; seems that they should still be
there no matter how tiny the scaling is. Perhaps the happy result of a precision
issue again?

I also tried an 'object pattern' for the shadow (no matrix needed,
just the negative vnormalize trick): I  pasted its created pigment on the front
of a vertical box, then aligned/rotated the box using
Point_At_Trans(<LS2.x,0,LS2.z>  It works, sort of...but the object-pattern
operation is a bit odd (or rather, unexpected)-- the pattern seems to be derived
from an infinitely thin slice of its object in the x/y (?) plane-- which leaves
out any parts that do not overlap that plane:

#declare OBJ_PATTERN =
pigment{
object{Object
//  translate (-.35 + .65*clock)*z // experiment
color rgb .2
color rgb .5*<.3,1,.3>
}
}

#include "transforms.inc"
box{<-.7,-.4,0>,<.7,1.6,.01> // vertical box centered on x-axis
texture{pigment{OBJ_PATTERN} finish{ambient 1 emission 0 diffuse 0}}
Point_At_Trans(<LS2.x,0,LS2.z>)