Sign in to follow this  

Shadow Volume Creation

Recommended Posts

Hi. I have been reading up on how to create shadows using shadow volumes and a stencil buffer, but alas, i have tripped up on the first hurdle. I have been lead to believe (from that you must create the shadow volume by finding the contour edges of the occular object. You do this by cycling through every polygon of the object and finding the dot product of the normal of the polygon and the direction of the light at that polygon, and check if it is facing the light or not. So i have a D3D mesh, (a teapot actually), but I am confused as to how to access each polygon individually. =/ Any help would appreciated greatly. Thanks for your time. Trandafira

Share this post

Link to post
Share on other sites
Since it is derived from an ID3DXBaseMesh (I'm guessing!), then you should be able to access it's vertex buffer, lock it, and get all the info you want to construct your data.


IDirect3DVertexBuffer9 * VertBuff;


Vertex * v;
VertBuff->Lock(0,0,(void**)&v, NULL);
for (unsigned int i = 0; i < pMesh->GetNumVertices(); i++)
// every third vert completes a triangle
// add together the normals and divide by 3 to find average normal
// which will be the face/triangle normal


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this