# How to derive 4x4 shadow matrix

This topic is 3352 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

the directx docs state:
P = normalize(Plane);
L = Light;
d = dot(P, L)

P.a * L.x + d  P.a * L.y      P.a * L.z      P.a * L.w
P.b * L.x      P.b * L.y + d  P.b * L.z      P.b * L.w
P.c * L.x      P.c * L.y      P.c * L.z + d  P.c * L.w
P.d * L.x      P.d * L.y      P.d * L.z      P.d * L.w + d

I have tried to derive the matrix myself and the closest I got was this:
{
{ld - lpx * pna - pnd,   -lpy * pna,             -lpz * pna,             -pna}
,{-lpx * pnb,             ld - lpy * pnb - pnd,   -lpz * pnb,             -pnb}
,{-lpx * pnc,             -lpy * pnc,             ld - lpz * pnc - pnd,   -pnc}
,{lpx * pnd,              lpy * pnd,              lpz * pnd,              ld}
}

from this equation:
ld = lp . pn

(vp - lp) * ld
vp' = -------------- + lp
ld - (vp . pn)

I derived the reflection matrix in about 2 minutes - I have been working on this shadow matrix for 4 days now :-( in my test program my matrix works, the dx matrix does not does anybody know how to derive this matrix - are the directx docs correct? I keep expecting to have a forehead-slapping moment but its not coming ...

1. 1
2. 2
Rutin
20
3. 3
khawk
17
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633759
• Total Posts
3013720
×