# problem with the shadow effect

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

## Recommended Posts

I have oppened another thread where i asked for help on how to find the plane equation wich is : AX+BY+CZ+d = 0. fist thanks for the help , second i found that the equation is very simple and can be reduce to : A = y1* ( z2 - z3 ) + y2 *( z3 - z1 ) + y3 *( z1 - z2 ); B = z1 *( x2 - x3 ) + z2 *( x3 - x1 ) + z3 *( x1 - x2 ); C= x1 *( y2 - y3 ) + x2 *( y3 - y1 ) + x3 *( y1 - y2 ); D = - x1 *( y2*z3 - y3*z2 ) - x2* ( y3*z1 - y1*z3 ) - x3* ( y1*z2 - y2*z1 ); as it is written in the article in : http://www.gamedev.net/reference/articles/article415.asp No i have a new problem : it doesnt show the shadow , i'm working with the book :"Advanced Graphic Programming " and it's not working . it show the object (that for know is a simple rectangle ) but it doesnt show the shadow projection . thanks in advance .

##### Share on other sites
hi!

I misread your first post, as I didn't understand you were looking for plane equation :\$
First I think you should reply in the same thread for keeping things together.
Without any calculation I can told you that your plane normal is (0, 0, 1) (or (0,0, -1), depending on the order of the point).
Can you give us the piece of code that do the projection? (and other rendering)

##### Share on other sites
Sorry for the late reply , the piece of code is :

{
float p1[3] = {-3,3,0},p2[3] = {3,3,0},p3[3] = {3,-3,0};
float x1,x2,x3,y1,y2,y3,z1,z2,z3;
float A,B,C,D;
float dot;
float ground[4], light[4];

x1 = p1[0];x2 = p2[0];x3 = p3[0];
y1 = p1[1];y2 = p2[1];y3 = p3[1];
z1 = p1[2];z2 = p2[2];z3 = p3[2];
A = y1* ( z2 - z3 ) + y2 *( z3 - z1 ) + y3 *( z1 - z2 );
B = z1 *( x2 - x3 ) + z2 *( x3 - x1 ) + z3 *( x1 - x2 );
C= x1 *( y2 - y3 ) + x2 *( y3 - y1 ) + x3 *( y1 - y2 );
D = - x1 *( y2*z3 - y3*z2 ) - x2* ( y3*z1 - y1*z3 ) - x3* ( y1*z2 - y2*z1 );

ground[0] = A;ground[1] = B;ground[2] = C;ground[3] = D;
light[0] = pos[0];light[1] = pos[1];light[2] = pos[2];light[3] = pos[3];
dot = ground[0] * light[0] + ground[1] * light[1] + ground[2] * light[2] + ground[3] * light[3];

shadowMat[0][0] = dot - light[0] * ground[0];
shadowMat[1][0] = 0.0 - light[0] * ground[1];
shadowMat[2][0] = 0.0 - light[0] * ground[2];
shadowMat[3][0] = 0.0 - light[0] * ground[3];
shadowMat[0][1] = 0.0 - light[1] * ground[0];
shadowMat[1][1] = dot - light[1] * ground[1];
shadowMat[2][1] = 0.0 - light[1] * ground[2];
shadowMat[3][1] = 0.0 - light[1] * ground[3];
shadowMat[0][2] = 0.0 - light[2] * ground[0];
shadowMat[1][2] = 0.0 - light[2] * ground[1];
shadowMat[2][2] = dot - light[2] * ground[2];
shadowMat[3][2] = 0.0 - light[2] * ground[3];
shadowMat[0][3] = 0.0 - light[3] * ground[0];
shadowMat[1][3] = 0.0 - light[3] * ground[1];
shadowMat[2][3] = 0.0 - light[3] * ground[2];
shadowMat[3][3] = dot - light[3] * ground[3];

}

in the glScene function i do :

void glscene()
{
...
...
...
DrawObject(false) ; // Draw Object , False means not for shadow
DrawObject(true) ; // Draw Object , true means for shadows
...
...
}

the DrawObject() function receive as argument true or false and i use it to determine the color of the objects . Yellow when false or black when true.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634090
• Total Posts
3015430
×