Sign in to follow this  
henksgu

The shadows of NWN? (Animating shadows)

Recommended Posts

To begin with, I wonder if there is a better method, when implementing shadow volumes on a skinned mesh (currently ruiing with vertex shader), than calculating the whole animation on the CPU and let the vertex shader do only the shadowing? I am really interested in the fabulous shadows in Never Winter Nights, they are the kind of shadows I'm trying to implement, but don't really know how to do it. I know the concepts of shadow volumes and everything, but I don't know how to put it all together in a nive little game with a reasonable FPS. Thanx for all the help!

Share this post


Link to post
Share on other sites
I worked only with shadow mapping, so I may be totally wrong...
But, isn`t it possible to create degenerated quads (on CPU, once) (or whatever it is called), use bones for character animation/skinning, and after that do extrusion for shadow volumes (all in VS)?

Share this post


Link to post
Share on other sites
While were on the topic, with shadow volumes on the vertex shader do you keep a seperate mesh of the mesh with degenerative quads for the shadow volume AND your model or combine them into one? This is confusing me somewhat!

Thanks,

Matt

Share this post


Link to post
Share on other sites
ok, now i'm lost, you can't create new vertices in a shader right? so how then could you get a correct shadow volume then?

do you have any good articles about the degenerative quads? What are they all about?

thanx

Share this post


Link to post
Share on other sites
You don't need a separate mesh, just a separate index buffer. instead of having a triangle indexed like so,
0 1 2

you have 2 degenerate tris for each edge so

0 1 1
2 1 1

1 2 2
0 2 2

2 0 0
1 0 0

I may have mixed up the facing, but you get the idea.

Share this post


Link to post
Share on other sites
I need to partially correct what I wrote above. You DO need a separate set of geometry, or at least a face normal.

If you have two faces, A and B

A
/
/
p.
|
|
B






You will need two copies of point p, one with the face normal of face A, and the other with the face normal of face B.

Additionally, you use indices similar to what I wrote above.

Share this post


Link to post
Share on other sites
What i don't get then is how do skeletal animations (i.e. ones that invlove more that the application of a WorldTransofrmMatrix) get applied to a vertex shader based shadow volume. For example:

I have a terrain.

I create a vertex-shader ready mesh based on the terrain, so now i have a terrain mesh and a shadow mesh.

I create a hill on the terrain in real time by raising some vertices. So now my terrain mesh has a hill but my shadow mesh knows nothing of tis.

How would i bring the shadow mesh in line; do i have to loop through and apply the same changes to this and then recalc the degenerative quads for the ones that have changed, or is there something vital i have missed here?

Thank you very much for any help, this is reallly confusing me!

Matt

Share this post


Link to post
Share on other sites
Ok I have now found ATI's paper "Extruding Shadow Volumes with vertex shaders" and I think I have got the idea.

As the degenerative quads should be able to be implemented in every point of view / light source / shadow-reciever, I don't think there would be any problem with animations except:

As presented above, it is the shadow-caster that is being animated (if I'm correct) I think that you could just animate the quads with the same bone-weights, in a vertex shader and then, in the same shader of course, extrude them. But that's just only me, speculating.

Please, someone correct me, if I'm entirely wrong (or even a little) ;)
I have probably just misunderstood your question, and if that's the case ... sorry!


Share this post


Link to post
Share on other sites
From that article it would seem that you use the same geometry (with the degenerative quads inserted) for both the shadow casting mesh and your actual model mesh; is this you impression as well or have i misread that? I always thought you maintained two seperate meshes, one for the object (normal) and another for the shadow generating mesh (with quads in it).

Matt

Share this post


Link to post
Share on other sites
Yes, exactly, 2 seperate meshes (it would take a lot of time to draw these extra quads when not extruding them to a shadow volume)

But the really sad thing is that you would either have to calculate the animation in software, CPU and then pass it to the shadow volume shader OR you could send your mesh to a skinning shader and then send the shadow-mesh to a combined skinning-shadowing shader.

Both methods are time-eaters but that's the only way I know of.
I read, though, a rather interesting article in the sweet snippets section here in GD and the introduced the concept of using a shader to skin the mesh and then paint the animated vertices on a texture (set render target, with pixel shaders)
And you could later use these points in the drawing (lighting) and shadowing passes.

But to me this seems very ackward, as you would have (after storing the points in a texture) to lock the texture and vertex buffers and copy the whole set of data, every frame!

If you have any different approach to the problem, please enlighten me.

Share this post


Link to post
Share on other sites
No, i think you are right. It seems to me that, for characters that require such animation, extruding the volume on the CPU would actually be more beneficial as there is no reliance on this second geometry. However, this seems alot slower, although admitidly i have not done much in the way of optimising the extruded geometry method for this case yet so i should see substantial improvement.

That or move to shadow maps, which would be a shame after this work into shadwo volumes.

Share this post


Link to post
Share on other sites
If you have a skinned character, or a smooth shape like a sphere, there are no sharp edges, where two faces can have different vertex normals, then you can use only one mesh.

Basically, if all of your vertex normals are shared across your mesh, then you can just use an index list.

For something like a cube or the corner of a room, or a chunky-looking robot, you would need two mesh copies to handle the case of non-shared vertex normals.

Share this post


Link to post
Share on other sites
But (ah, the big but ;) if i have created a mesh with those degenerative quads (2 extra vertices for every 2 vertices) i.e. twice the vertex buffer size. Wouldn't be foolish to draw a lit model with this shadow mesh? I mean, you don't need the the extra vertices when just doing phong lighting, right? You would actually only need it when "drawing"/burning the shadow volume into the stencil buffer, or I am i completely mistaken?

Share this post


Link to post
Share on other sites
No you are right. However, if you maintain just the one mesh it means you only have to do the manipulation on it once for animation, not once on each mesh. I guess it is pros and cons; i actually found that the DirectX sdk gave good example and touched on the pros and cons of the 1/2 mesh idea.

Matt

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