Any Shadow Solutions for animated meshes

Blitz3D Forums/Blitz3D Programming/Any Shadow Solutions for animated meshes

eye(Posted 2005) [#1]
Just wondering if anyone has come up with/are working on or have any ideas about casting shadows for animated meshes ?

This seems to be a standard feature in all pro games, yet I/we have trouble implementing this in blitz.

Thanks for any input


puki(Posted 2005) [#2]
Here is one:
http://www.blitzbasic.com/codearcs/codearcs.php?code=434

Someone rewrote this recently - it's on the forums somewhere in the last 6 months.

There is at least one other shadow routine for animated characters - might be this: http://utenti.lycos.it/mnzsoftware/.


eye(Posted 2005) [#3]
Thanks puki,
I will have a look at those.


Beaker(Posted 2005) [#4]
The best known solution is sswifts shadow system.

It is good, but there isn't a perfect solution for Blitz3D mainly cos it uses old technology (DirectX 7). Regardless, Blitz3D is still great.


Pongo(Posted 2005) [#5]
I second sswift's shadow system.

it is well worth it IMO, and really easy to use.


Matty(Posted 2005) [#6]
I've been working on some features for another game I want to make (after my gauntlet remake) which has animated models casting shadows. I'll release the code when I've done a little more, although it has a few drawbacks that I am going to use as features.

The way I do them is by taking a render (or multiple renders) from the light's position and orientation (for a spot or point light(multiple renders)) and copying the render to a texture and applying this texture over the level/mesh in such a way that shadows are shown on the mesh. There are a few ways of doing them and a few tricks you may need to use when designing your levels but I'll hopefully have something to post in a few days.


Matty(Posted 2005) [#7]
To cast shadows from animated meshes the way I do it is by placing a camera at the light source, take a render with scene in white, shadow casters in black, apply it as a texture to a copied mesh, do this for each light, use additive blend and take another render of the sum of all the meshes from the world camera's view and then apply this as a texture to the 2nd uv coords of your level using multiply texture blending (level mesh full bright).

Will post a demonstration in a few days hopefully as I've got something that does this I am working on..although it has a few features/drawbacks that limit its usefulness


IPete2(Posted 2005) [#8]
Swifts Shadows - although cpu intensive produce very professional results. I have it working with animated meshes too - lovely!

IPete2.


Dock(Posted 2005) [#9]
I recommend Swift's Shadow System. It's really cheap, and fully featured.


jfk EO-11110(Posted 2005) [#10]
Matty I'd really lik to see your method, sounds good.


Matty(Posted 2005) [#11]
Here is a link to an example I put together today demonstrating real time lighting/shadows with animated meshes.

http://home.swiftdsl.com.au/~gezeder/lloyd/Shadows.zip

A few points to note:

1. I just realised - you will probably need to change the screen resolution as I set it to 1280x800 which is my laptop's resolution, easy enough it's in the first few lines.

2. There are glitches - I have not tweaked this fully but hopefully you will be able to see how it works.

To run it:

open the file Sci Fi Engine.bb (remembering to change the graphics resolution) and simply run it. Cursor keys to move/turn the player around. There are about 20 little green men running around who will cast shadows as well as a set of doors which also cast shadows and the walls of the level which while themselves not seen do cast shadows as well.

The core stuff that does the shadows:

ShadowMap.bb - contains a few functions, one which basically initialises the system, another which sets up spot lights, another to remove lights when necessary and the main one which updates the level shadows every frame.

Don't worry about all the rubbish that is in the Sci Fi Engine.bb code - I basically spent the last little while modifying my gauntlet code to run this and so it is not in the best of shape however it should not give you any errors.


t3K|Mac(Posted 2005) [#12]
looks pretty cool - but so much source, i am sure i will not get into this :( nevertheless, very very nice.


Alienforce(Posted 2005) [#13]
Matty! Really cool. thanks for sharing


Matty(Posted 2005) [#14]
t3K|Mac - don't worry about the source in sci fi engine.bb, it is the source in shadowmap.bb that deals with the shadows/lighting.

Edit - alternate thread here:
http://www.blitzbasic.com/Community/posts.php?topic=54167


jhocking(Posted 2005) [#15]
sswift shadow system ftw!


Barliesque(Posted 2005) [#16]
There is another new shadow system that's well worth considering. It supports stencil shadows, soft self-shadowing and refractions. Have a look:

http://www.codersworkshop.com/viewshowcase.php?id=395&read=no

I'd like to hear from experienced users of Sswift's sytem, how the quality of shadows compares.


sswift(Posted 2005) [#17]
Looks interesting, but I have my doubts it can handle B3D's with bones, and that's a really important feature to many people.


Barliesque(Posted 2005) [#18]
Yes, it is... The animated robot in the demo is an X file with bones. I don't imagine B3D or X file format makes much difference here.

The shadows created by this system are sharp--I don't think soft ground shadows are possible with this technique. Also, I haven't seen a color-tinted shadow, as seen in your system. Nor, multiple light sources. Your demo warns that two-light sources will "kill your frame rate" but I don't find that to be the case on my system. It's still pretty fast.

I'm not quite sold on the hot air effect in Andreyman's system, although, it could probably be fine-tuned on the Blitz-side better than it is in the demo. Generally, the refraction system is *very* nice.

It would be interesting to see a head-to-head comparison of performance between these two systems.

All in all, it's looking like stiff competition for you Sswift. (Sorry, to be the bringer of bad news.) ...but probably, the two systems will turn out to have different strengths.


sswift(Posted 2005) [#19]
Barli:
Which robot? The one from Aliens? Why would a robot have bones? I guess in theory you could DO it, and it might save you on surfaces, but it would cost you a whole lot more for tansforming all those vertices.

Also, I was no aware anyone had developed a library to load X files with bones. I'm prety sure that isn't possible. To load anyhting with bones, it has to be loaded as a B3D unless you somehow find a way to get into the internal polygons structures of Blitz.

Which is exactly why I dubted he could handle bones. That's really the only easy way to accomplish that for animated meshes because blitz doesn't report the transformed vertex locations.

Now in theory, one could wite an X with bones loader, and then transform the vertices themselves, or predict where Blitz will transformt hem for a given animation frame, but in reality that would be such a huge headache and require wiritng so many new commands, and would probably be so slow, and require so much extra ram, that frankly, I doubt he's done that.

So the only option really would be that he is loading X files, and he found a way to access and write to the bone strucutres in Blitz, which would in itself be a major feat above and beyoond mere stencil shadows. :-)


"Nor, multiple light sources. Your demo warns that two-light sources will "kill your frame rate" but I don't find that to be the case on my system. It's still pretty fast."

Well I say that because when you add a second light source, you double the number of shadows you cast. A third would triple the number. So effectively you cut in half the number of objects you can have cast shadows, and it is already low.

Of course there are special cases for everything. That's why I included the option to have more than one.


"All in all, it's looking like stiff competition for you Sswift. (Sorry, to be the bringer of bad news.)"

It's not that big a deal, I don't sell very many copies of my shadow system anymore. :-)


Barliesque(Posted 2005) [#20]
If you look through the media files for demo3, you'll find that the robot model is an X file. I loaded that file into Unwrap3D and found that it contained a skeletal hierarchy. ...come to think of it, I've confused that skeleton for DX8-style bones. Ahhhh, so no. This is NOT an example of a boned mesh!

I stand corrected.


Ferret(Posted 2005) [#21]
I'm creating libs to reuse in future projects, i got one for vertex lighting and i'm working on animated shadows for characters.
It will not be as fancy as Swifts shadow system but i'm uploading it when it works.


Ricky Smith(Posted 2005) [#22]

Also, I was no aware anyone had developed a library to load X files with bones. I'm prety sure that isn't possible. To load anyhting with bones, it has to be loaded as a B3D unless you somehow find a way to get into the internal polygons structures of Blitz.


You simply parse the .x file and do a real-time conversion to .b3d. It's something I'm currently adding to PaceMaker.
I already export to boned .x but want the ability to import as well.