Shadow Expansion

BlitzMax Forums/MiniB3D Module/Shadow Expansion

Banshee(Posted 2013) [#1]
I'm considering a return to MinB3D because I'm having some difficulty with issues in my current 3D engine (Xors) and I want something a bit more stable.

When I last used this engine the real drawback for me was that it didn't have any kind of shadow support. After some forum and google searching I see that people have worked on shadow solutions but I havn't found anything finished.

Is there are shadow system for BlitzMax + MiniB3D that works?

I don't mind paying.


ima747(Posted 2013) [#2]
Nothing I would call production ready, but there are several approaches that have been implemented at various points. Your best bet would be to take a look at the existing implementations and try to update them for your specific usage. Something I've been meaning to do for about forever and a half...


Banshee(Posted 2013) [#3]
I lack the time and almost certainly the required knowledge for it myself - but I think it is a very important feature.

If someone was to do this for the benefit of the community I would certainly be willing to contribute a few hundred pounds to incentivise it.


Yasha(Posted 2013) [#4]
The thought that's always struck me about this topic is that the Blitz3D/miniB3D command set (I'm'a just call it B3D from here on out) is really too low-level and/or primitive for something like a generic shadow system to really fit very well. B3D isn't a full-fledged game engine that defines what is and isn't whatever kind of art asset: it's a game-engine-builder that you use to define a game engine that itself has a built-in shadow system that's aware of the assets it's handling.

That's not to say that it can't be done - you can obviously have shadows - but that "generic solutions" aren't really generic, they'll always embody somebody's assumptions about how to make a game, how to divide your content into actors and stages, how to define the difference between logical objects and mesh data etc. These are the kinds of forced decisions that B3D doesn't otherwise apply to the user: they belong on a higher level of engine design (in fact the entire concepts necessary to determine what ought to be a shadow caster can't really be expressed easily in pure-B3D terms).


Anyway, stupid waffling out of the way, I think there are a few promising leads that are worth investigating, inherited from Blitz3D, by dividing up into shadow rendering techniques:

-- Projective shadows: the technique is the one most commonly used in previous-generation games. Render an image of the casting entity in black to a texture, apply this to the receiving objects as a perspective texture. This is dead easy to do with the standard command set once you understand the trick, and could be optimised further in miniB3D than in Blitz3D by writing a specialised render function in OpenGL. Examples:
---> FastExtension comes with a version of this that applies to whole scenes, which is about as efficient a way to cast shadows in the fixed-function pipeline as you can get. Unfortunately that's locked to DirectX, but the source (possibly using extensions) comes with the package. The FastExt version is the only one I know that ever got self-shading working.
---> The famous "Swift's shadow system" used this method. I have no idea if it's still available.
---> I made a clean-room knockoff of SSS which can handle individual objects (it's not likely to be efficient for many objects though). I'd be happy to rewrite it for Max, and probably do a lot better this time around.

-- Stencil/volume shadowing: this is incredibly simple... in theory. The part where you render the shadows from the shadow volumes is really easy and plenty of static demos were made to work in B3D. Unfortunately there isn't a generic, CPU-friendly way to actually create the shadow volumes for any old dynamic mesh. You need to either design your models with the system in mind, or perhaps use vertex shaders to do the work which are conveniently not available in B3D as it stands. This technique is the least friendly to being generically plugged into an existing content system.

-- Shadow mapping: this is the simplest way to get shadows and probably the closest thing to a "generic" system that doesn't prescribe the nature and arrangement of your media files, which is very friendly to the B3D command set's style. Unfortunately it cannot be done at all without access to shaders. There's a heroic effort at making it work in the code archives which at least demonstrates the concept, but realistically this simply can't be done on the CPU.
If it could be made to work, this technique would be effectively quite similar to simply creating and positioning the hardware lights, which both nice and generic and content-agnostic.


Conveniently for those last two, somebody's apparently just recently found out how to integrate shaders with vanilla miniB3D, which is certainly something I will be looking into (needed to learn about shaders anyway): http://www.blitzbasic.com/Community/posts.php?topic=99496


TL;DR: there are crap systems that work; there are theoretically very attractive systems that don't work; and there's potentially a system that does everything you want waiting to be built if it turns out to be easy to integrate shaders with the rest of the miniB3D pipeline.


Kryzon(Posted 2013) [#5]
I'm afraid there's no easy-to-plug solution for MiniB3D.
There is no extraordinary public interest in making one.

Since you have tried Xors3D and are open to commercial products, you should take a look at Nuclear Basic which any Blitz3D'er should pick up quickly, and is built to a modern standard.
If I'm not mistaken Leadwerks 3 also seems to carry a bit of the Blitz3D flavor, and has graphic fallbacks for older systems.

- - - - -
The closest there was to shadow-mapping in MiniB3D was with Klepto2's work on it. He did a shadow-mapping shader but did not release it (check his worklogs). You might try contacting him.

http://code.google.com/p/minib3dextended/


angros47(Posted 2013) [#6]
OpenB3D has shadow support, if it can help.