Jump to content
  • Advertisement
Sign in to follow this  
abdellah

Shadow in DirectX

This topic is 1467 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

hello

 

is my technique correct?

 

i use this technique for rendering a shadow using HLSL :

1/ my scene has a sphere located in (0,3,0) & a floor like a plane (y = 0) & a point light located in (0, 7, 0);

2/ the technique is : if we name P the point light position + N is the name of every vertex of the sphere vertices + the point M is for every vertex of the floor vertices, i use two techniques t1 & t2, t1 for gathring the N points & t2 for calculating the vertices M  & then use the math operation :

float4 NP =mul(P, world_matrix) - mul(sphere.Position, world_matrix); // so here we calculate the NP vector.

 

 

float4 NM = mul(floor.Position, world_matrix) - mul(sphere.Position, world_matrix); // so here we calculate the NM vector.

 

// for dot product calculation ;

NP = normalize(NP);

MN = normalize(NM);

 

 

if (floor(dot(NP, NM)) == -1) 

{

// the vertex M is in shadow

}

else

{

// the vertex M is not in shadow.

}

 

the scene without shadow is

Edited by abdellah

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!