Lighting things is pretty well covered in Crystal Space* right now; multiple lights can be rendered in one pass, and materials can have the usual assortment of properties such as normal maps, specularity maps etc. giving shiny visuals. However, for a truly convincing environment you also need shadows.

Crystal Space actually supported stencil shadows for a while, but they’re not with out issues: the algorithm inherently can’t support any transparent textures, and extra care must be taken by the artists to produce “closed” models, otherwise the shadows will mess up. Also, the Crystal Space implementation has some issues: they need some effort to set up and animated meshes are not supported.

Thus I implemented shadow map support. Without going into too much technical details, they can support binary transparency (aka alpha test), don’t need special care for the models (just throw anything at them and it’ll look as it should), and due simpler implementation, they work on animated meshes in Crystal Space. Within the render manager framework they can easily be utilized by either using a stock render manager with shadow support or some lines of code in custom render managers.

Now some screenshots on how they look in that well-known small test level:

Shadows test, distant
Shadows test, from a distance

Shadows test, close-upย Shadows test, close-upย Shadows test, close-up
Some close-ups

Shadows also work on somewhat larger levels:

Shadows on large WIP level
(Ignore the missing textures etc. Focus on the shadows ๐Ÿ˜‰

Some implementation details: Parallel-Split Shadow Maps on top of a plain normal shadow mapping. (You can see the shadow maps displayed for debugging purposes in the lower left corner of the shots.) The”soft” shadows you see are actually provided by the NVidia hardware – so real soft shadows is still something left to be done.

* Well, render manager branch.

30 Responses to “Where there’s light there ought to be shadows”
  1. wow that looks great! Can that be animated? Can’t wait to see soft shadows!

  2. Felix Kรผtt says:

    looking good, fellows, looking good. ๐Ÿ™‚

    now id love to see if and/or how much progress has been on crystalblend(or w/e) and etc. xD

    would love a little screen recorded video even, if its not too much to ask. :3

  3. Damn, that looks great!

    Keep up the great work guys!

  4. Sweet. (h)
    I own a NVIDIA video card but some soft shadow samples would be nice.

  5. Nice. That’s actually how it’s been done in Far Cry…

    And shadows for moving objects will be done how? Using the regular CS shadows?

  6. BTW: A limitation of this is of course that the movement of scenery (plants, trees) won’t be reflected in the shadows, which is a bit disappointing, because more recent games (Crysis comes to mind) can do this…

  7. youaresomean says:

    Alex: Why should moving meshs not show up in the shadow map?

    Maybe you are mixing up shadow mapping with lightmaps?

    Provided by the Nvidia HW means Percentage-Closer Filtering?

    Stencil shadows are a dead end. I am not aware of any recent titles using it (the last was doom3).

  8. youaresomean: I always thought that shadow maps were pre-generated, so I am probably confused. So, they’re generated on the fly by using a light as a camera and then projecting its view onto the surfaces as shadows?

  9. youaresomean says:

    Alex: Yes, the scene is rendered from the lights point-of-view storing the scene-depth values in some kind of buffer (“render target”/”fbo”…). This buffer is then projected onto the scene in the camera’s POV and the depth values are compared to determine shadowed/non-shadowed pixels.

  10. youaresomean: Thanks. I always thought that exactly that was what DOOM 3 was doing. I’m not sure what’s the difference between stencil shadows and shadow maps then, because stencil shadows essentially have the same RESULT. I should do some reading ๐Ÿ™‚

  11. It looks really good.
    I’m just curious what my (not so new) ATI-Card will say….

  12. These look great but they bring to mind a question I have had. Does CS support AA? If it does, could you show some pictures with it enabled. If it doesn’t, that would the one really important feature to make the game look professional, but I assume it would be a big deal to implement. So eh, it still looks good without.

  13. lohborn: I could be wrong *again* ;), but afaik, getting FSAA is merely a question of setting a certain flag in the graphics card. (It is like that, at least, with NVidia based cards.)

  14. looking good.. is it possible to filter the shadows with some gaussion blur?

  15. Wow, that looks awesome! I hope moving shadows also gets into the game.

  16. Yall should use the texturing style of Team Fortress 2.

  17. will you additionally use some kind of static (global illumination) light mapping?

    when will there be a post about brecht’s shader node system? ๐Ÿ™‚

  18. horace: CS’ static lighter currently doesn’t do GI. So at least from that perspective static lighting would be pointless.

    Kirado: not easily.

  19. how are u doing multiple lights in single pass?.

    You should integrate it with ambient occlusion from blender,at least for the terrain.

    also what are minimum requirements.i hope all this runs on my crappy 7300 :>.

  20. i just asked because i hope that blender’s light baking features get improved. ๐Ÿ™‚

  21. Francisco Ortiz says:

    Very interesting… Alexander and youaresomean talked about a subject confuse to me: the difference between stencil shadows and shadowmaps. I also need to do some reading! ๐Ÿ˜‰

  22. stencil shadows are geometry based. the silhouette edges of models as seen from the light get extruded to form a shadow volume and the faces of this extrusion get rendered (taking the z-buffer of the scene into account) into the stencil buffer.

    shadow maps are image based. a depth map seen from the light gets rendered and then projected onto the geometry where the distance to the light can be compared.

  23. Francisco Ortiz says:

    Hey Horace, thankx for the type!

  24. I think that the shadows look really impressive, and I only hope that the game runs well on the average hardware available on the market these days.

    NathanKP – Inkweaver Review

  25. NathanKP: I don’t think “impressive” is quite the right word, they’re slightly worse than in Far Cry (which is 4 years old). But they’re work in progress… In turn, the shadows in CRYSIS *DO* look impressive ๐Ÿ™‚ Of course, that game doesn’t run on average hardware, but hey.. ๐Ÿ™‚

  26. Anonymous, because I fully expect to be flamed. says:

    This is still work in progress ehhhh right? IMHO, this looks like graphics from an average studio in 2003. Is open source game dev really this primitive at the moment? before you flame me, which I expect someone to do, This is an honest question, I don’t mean insult by it. I think the blender team is great, I just don’t think Crystal Space is the right way to go, I think we should concentrate on building more powerful game engines from scratch, like Unreal3 cryengine2, ect, it’d take longer yes, but it’d fruit far better results. I hope I see something like that in the next blender game project, if there is one.

  27. Anonymous: Exactly my opinion. Of course, this is work in progress, so one should be careful about premature comments and expect things to get better (and try to motivate the team instead of complaining all the time ๐Ÿ™‚

    However, saying that everything is spectacular when it clearly isn’t *yet* is also the wrong way to go.

  28. (Just to give an impression of what I mean: this is roughly “state of the art” currently:

    I don’t expect a small half-dozen-people team to produce a title like this, but then, don’t say you are going to produce a ‘state of the art’ game, because frankly, I think this is impossible given this budget and manpower.

  29. the budget of GTA IV was 100 million dollars and they had a staff of 1000 people. ๐Ÿ™‚
    crysis had a budget of about 30 million dollars.

    how are open source projects supposed to compete with that manpower? a free and open sourced unreal3 engine wouldn’t give much advantage over crystal space either.

    some people seem to have way too high expectations.

  30. Indeed. That’s why I said I don’t expect a “state of the art” game from this project at all. I just wanted to convey that it’s dangerous to propose “state of the art” as the plan (as Ton did in the initial Apricot announcement), because that’s simply not possible. It’s easier with a movie (like Peach), because with a movie, the lack of budget and people can simply and fully be compensated for with an arbitrarily shorter length.