Jump to content
  • Advertisement
Sign in to follow this  
Hermes

Shadow Projection

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,i'm intereasted in making a hard shadow(using a projection matrix) .I tryed a formula but i didn't get the result i've expected so i wouldn't mind if you gave me an explanation. A*x+B*y+C*z+D=0; And the projection matrix would be the one below:
|1      0    0     0|
|0      1    0     0|
|0      0    1     0|    
|-A/D  -B/D  -C/D  0|

My problem is that i have a floor at y=-1.0f on which i want to project my object.I said that the equation of the plane is in this case "y+1=0" i hope i'm right.
The algorithm given is:
========================
float P[16]={1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,0}; glMatrixMode(GL_MODELVIEW); glPushMatrix(); glPushAttrib(GL_LIGHTING_BIT); glTranslatef(lx,ly,lz);/* why translating into the light position?*/ D=D+A*lx+B*ly+C*lz;/* what is this for?*/ P[3]=-A/0.999*D;/*what is this for*/ P[7]=-B/0.999*D; P[11]=-C/0.999*D; glMultMatrixf(P); glTranslatef(-lx,-ly-lz);[looksaround]
...............DrawObject..............
glPopAttrib(); glPopMatrix(); Since i don't understand it i can't find the error i'm making so please explain to me what is going on in this algorithm or if you have a better way to do it and know well the algorithm please give it to me,some explanation won't hurt.Also i can't understand where the matrix comes from Thanks for your help.

Share this post


Link to post
Share on other sites
Advertisement
Well, I don't know that I can explain each part of that, but I can give you a general idea of what is being done. You basically have similar triangles. You are projecting onto a plane. There is a plane parallel to that plane that contains the point being projected. Call L the position of the light, P the point projected, P' the projection, D the nearest point on the plane containing P to L and D' the nearest point on the plane containing P' to L. So |D'-L|/|D-L|=|P'-L|/|P-L| where |x| is the magnitude of vector x. So P'-L=|D'-L|/|D-L|*(P-L).

Share this post


Link to post
Share on other sites
ThankX for your answer for a while i was thinking about P' as the projection of P not as beeing cast from the light source
 
|P
|
|P' then

/P
/
/
P'

You've been of great help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!