Sign in to follow this  
Kurt-olsson

SDK Shadow mapping sample

Recommended Posts

Hi

i am trying to learn how to use shadow mapping in directx9.
i have downloaded the sample from the DX9 SDK and i am now trying to get rid of all code that has nothing to do with shadow mapping.

i HATE the DXUtil classes, it messes me up and i don´t understand the whole idea of having a pointer to the d3d device etc.

What does this mean?

DXUTSetCallbackD3D9FrameRender( OnFrameRender );

OnFrameRender is a function declared but how can this function be drawn at the end of every frame?
Does DXUtil listen to some callback and trigger this function?

I am trying to run the function after EndScene() but then the code no longer works...

If anyone know a good sample of shadow-mapping without dxutil judder/jidder, let me know. =)

Share this post


Link to post
Share on other sites
If I had to guess they have a function that will call the sample's Render function at a specified point, and that's the function that's used to register the function. So I would guess if you want to use that code you either need your own Render function and then copy that code into it, or put a breakpoint in the function and see where it's getting called from.

Share this post


Link to post
Share on other sites
Hi,

Here is [url="http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324%28v=vs.85%29.aspx"]some info[/url] on shadow mapping and also [url="http://www.microsoft.com/en-us/download/details.aspx?id=14052"]some slides[/url] with audio from GameFest 2010, both by David Tuft.
Maybe it’s easier for you to get the intentions in the sample code, if you have read/heard this.

DxUtil is just some helper stuff, which manages the message loop, the events of loading and unloading scene data (e.g. on resize) and the invocation of the update (OnFrameMove) and render (OnFrameRender) pass. What's important is:
What are the resources involved for shadow mapping? How are they created? How is the shadow map rendered? How is the shadow map used later to get the shadows? Once you have refreshed your knowledge on the basic concept (see the slides), it will be easier to spot the important lines in the code.

Cheers!

Share this post


Link to post
Share on other sites
Thanks.
I am continuing to strip the code for better understanding.

You are right fellas, i need to read up more on the shadow-mapping itself.

DxUtil i think is good when you have good understanding of the direct3d API and Win32 API, but right now it just makes things harder.
But i have soreted out that there is pretty much only this:

1, init texture shadowmap and other stuff to make shadow work
2 run a function that renders the scene (like the render_frame()) i have now, only i have to have a boolean so i can render with different techniques seperate time
If the shadowmap-buffer and texture exists, render it, otherwise render the scnene as "usual".

I think i have to use the effect every time i render a mesh/triangle/spehere etc, i thought before that you could set this global, but now i think i have to run the Effect for each time i render a Primitive.

thanks again for your help.

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