A nice complex shadow prob :)

Blitz3D Forums/Blitz3D Programming/A nice complex shadow prob :)

D4NM4N(Posted 2005) [#1]
I got one hell of a terrain, lots of faces, and want to put a simple blob shadow under certain entities.

so far ive tried:

Geometric shads, (too slow because of complexity of terrain)

dark light shadows with spotlights, looks bad as only the verts are un-lit (although is there a way of making spots light in a nice smooth circle, independent of vertices??!? if so please tell)

shooting sprites at the landscape and aligning to vectors(really bad idea)

jfks linepick idea, (closest so far) but still not fast enough because of the big mesh


The only thing i havent tried is texture shads. I can shoot a pivot out of my 'dude' and have it return the entity hit, but how do i plot the texture coords to this point??

unless anyone has any better ideas, but i cannot reduce the complexity of the mesh unless i can do hw lighting that doesnt light only when near a vertex.


DJWoodgate(Posted 2005) [#2]
If it is a regular grid like terrain mesh you may be able to calculate the texture coords for a tformed point. You may also be able to calculate the tri and surrounding tris to overlay a shadow mesh.


Matty(Posted 2005) [#3]
The textured spotlight demo that Fredborg has posted in the code archives can (and has been - there is another entry using similar code by him) can achieve this. Projected shadows is a simple way. What it involves is this:

Hiding scene objects apart from shadow caster (ie character).
Coloring character black/grey some dark uniform color
Rendering the scene from the light's view and copying it to a texture buffer.
Using the second set of UV coords for your terrain multiply blend the shadow texture with the terrain's textures. You need to also set the U,V values for the second texture coordinate set. The details of how to do all this are in the following code archive entries.

Issues with it are as follows:
Very hard to have multiple light sources (need to make a copy of the terrain surface for each light source beyond the first)
Requires changing vertex uv coords each frame which can be slow if terrain has a lot of vertices, which I'm sure it does.

Anyway the code archives needed are here:

http://www.blitzbasic.com/codearcs/codearcs.php?code=1000

and

http://www.blitzbasic.com/codearcs/codearcs.php?code=1010

Note that Fredborg copies the original mesh - if you only have a single light and no lightmap for the mesh you can simply use the second UV coord set. (Wouldn't it be nice if you could have unlimited UV coord sets..)


D4NM4N(Posted 2005) [#4]
works great, thx 4 pointing it out!!!