using D3DXMatrixShadow?

Started by
3 comments, last by jollyjeffers 18 years, 6 months ago
I have a couple of questions regarding the function D3DXMatrixShadow? a) Can I use this for rendering shadow? b) Can it SUpport rendering shadow on edges or corner of the scene?
Advertisement
The D3DXMatrixShadow function is only really useful for producing cheap shadows on the ground plane of your application. That said, it is the most robust and usually cheapest of all shadow techniques, though its usage is very restrictive.

To render shadows using this transform, fill in the light position and a D3DXPLANE structure describing your ground plane (you can build this with e.g. D3DXPlaneFromPointNormal) then render all of your shadow-casting geometry.

This technique is usually most useful when used in conjunction with stencil buffering.

What exactly are you referring to when you say the "edges or corner" of your scene?
The Problem
Using D3DXMatrixShadow for rendering shadows

The Solution
a) Sure you can, it takes a given light position and a plane and flattens it thus creating a shadow. it's up to you to set the specified details such as how you want the shadow rendered, normally I just render the box again with the shadow matrix and set alpha blending on and turn of the Z tests to reduce z fighting.

b) I haven't tried this but i'm sure if you specified 2 planes... let's say you want to render the shadow on the wall and the floor you will render the first shadow on the wall and the next shadow on the floor. Since it takes a single plane I would imagine it's limited in the sense that you cannot do arb shadows.

I hope this helps.
Take care.
Given that graphics programmers like shadows, and that shadows are still a "cool" thing to be implementing you'll find no shortage of algorithms on the net. Some of them are pretty complex, but then there are quite a few that are reasonably straight forward.

Unless you REALLY can't be using a stencil buffer (+extruding shadow volumes) and REALLY don't want to be doing any texture-space/render-to-texture effects for shadow maps you don't really want to bother with the D3DXMatrixShadow() version.

As already posted, it's a fairly simple/"old" technique.

Quote:Original post by Armadon
b) I haven't tried this but i'm sure if you specified 2 planes... let's say you want to render the shadow on the wall and the floor you will render the first shadow on the wall and the next shadow on the floor. Since it takes a single plane I would imagine it's limited in the sense that you cannot do arb shadows.

you could use this - probably abstract it further out so that you "flattened" onto every different face of your geometry. But you'd have to be VERY careful of clipping. Whilst in the wall/floor analogy it might not be a problem, in others you might end up with somewhat odd looking "floating" shadows [grin]

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

There is a category of articles on shadows here at GDNet. A couple of ones you might want to check out:

Soft-Edged Shadows. Whilst it's technique for soft shadowing might not be entirely correct (it's screen-space based) the results look very good given the complexity of the implementation.

And just for good measure, I wrote a Z-Pass stencil shadowing example/article for this side a couple of years back. It's a little dated now, but if you're interested: An Example of Shadow Rendering in Direct3D 9

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

This topic is closed to new replies.

Advertisement