I'm working through the Flag Rush tutorial series. I'm working on adding real time shadows to the bike model. On my higher end PC the performance is fine for the most part, and looks fine (Although the shadow isn't very dark and looks white even.). However, I do most of my work on my laptop and it really isn't a graphics powerhouse. This causes significant slow down when trying to implement real time shadows. I was wondering if anyone knew of a way to implement blob shadows instead since they are much less power hungry and also give the model depth.
hehe, i just asked because i didn't hear the term 'blob shadows' before, i was hoping some else can give some info about it :).
But i also thought about projecting the shadow texture. (there is a jmetest.effects.TestProjectedTexture as a reference)
Maybe its also possible with a shader? I don't know whats easier / more performant.
Well guess there is some work to do, as far as i remember, the projected texture will project on everything untill infinity. So in a two floor house you an see the shadows from the floor above you
how are blob shadows usually implemented ?
Thank you for not just giving me an answer…I'm completely serious. You actually made me think about how blob shadows work.
They work by projecting a "shadow" texture onto the terrain underneath the model, correct? So I would need to use the ProjectedTextureUtil class in jme. I don't know why I even asked if I would have actually put more thought into it and actually looked more at the engine code I wouldn't have needed to ask…that is assuming I'm right about using the ProjectedTextureUtil class. Well, I might as well try it and see if that works.
Again, thanks for actually making me think about the problem. I don't know why I didn't see it before. I'll let you know if I am successful! I'm pretty sure that there is more to it than just using that class but I should be able to figure it out.
With that method you'll have a limited number of blob shadows. Each shadow will take another texture unit, you'll quickly run out of texture units as most cards have 2-4 units. You'll need to instead replicate the part of terrain where the shadow is, this technique is rather complicated but I could explain if you need more than 1 shadow blob.
Well I really just needed one blob shadow for the Flag Rush tutorial and I was able to get it to work last night. I'll post code once I get a chance. I was up pretty late. It still needs some tweaking but it is working for now.
However, this was something that I was wanting to have for another game project that I am working on to help make the game less graphic intensive yet still have "depth." I'd love to hear your explanation for more than one shadow blob Momoko_Fan! Also, any ideas on how to solve the projecting to infinity problem with a two story level? The shadows from top level being projected onto the bottom level would definitely ruin the illusion.
Would it be possible to play around with the near and far planes of the projection? As I understand it, the near plane dictates how close to the projector the texture can be to get projected and the far plane is how far away from the projector the texture can be to get projected.
Thanks for all the input!
Wouldn’t it be possible somehow to use a culled, simpler shape to cast the shadow?
Using a culled sphere attached to the player object gives a better performance, but there is some self shadowing and an internal shadowplane of sorts…
How do I get rid of those?
EDIT: I do realize I can use a smaller shape within the player object, but what if I want a bigger shadow for whatever reason?
The simplest way to have many blob shadows, is to make a quad with a "black glow" texture, and just put it under the model, making sure it always appears in front of the terrain. It won't follow the terrain but I think for most cases it should be good enough.
The more advanced solution is quite difficult to implement so I wouldn't recommend it, it would take even for me a few hours to get it to work right.
Actually depending on what type of pc you plan to use it you can sue far more than 2-4 texture units a radeon 4780 for example has 32 Textur-Mapping-Units. I assume that geforce cards are similar. What you may do is to check prior to activate the shadows a test if there are enough units to succesfull use it.
Also it might be worth to use a small moveable terrain isntead a quad, then if you adjust the y values to the ones of the underground under it it might look a bit better than a plain quad.
Another idea, what about generationg a lightmap in realtime for the objects near the player? It might be a bit harder to implement but features far better shadows, while only using one texture unit, and noa dditional memory cost if you already use lightmaps. -> In fact most of dynamic lighting does not need to be processed then. (I will look into this soon, and see if i can get a usefull shadow/lighting implementation working.)