Jump to content
  • Advertisement
Sign in to follow this  

Shadow in C# & managed DirectX

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



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




// the vertex M is not in shadow.



the scene without shadow is : see the 8.PNG file;

Edited by abdellah

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!