Tuesday 24 June 2008

Shadows!


Yay! It took quite a bit of wrestling with formats, but it seems to work now. At least on one PC.

I greatly reduced the ambient lighting and removed all other light sources for testing, so the shadows are rather stark and flat. Also there are a metric fuckload of subtle problems - light bleeding where the depth complexity is even moderately high (the downside of using VSM), speckles due to depth precision problems, streaks and blobs caused by the low resolution shadow map... I'm sure there are plenty more, too.

But the important thing is it's a start, and it's quite essential for that claustrophobic RL feeling.

Next big problem will be making sure this is consistent with logical line-of-sight. LoS calculations need to be somewhat permissive to account for the character moving around within its cell, and only take into account the logical properties of grid cells (i.e. blocks vision or... not) rather than the exact nature of any occluding geometry. Shadow maps, by contrast, are far more precise. Hmm. Giving information to the player based on what their character could see may make the shadows seem wrong or incomplete (e.g. knowing that there's a goblin fishmonger a few squares to your right, despite it being entirely in shadow), whilst denying them information about, say, a monster which is clearly illuminated by the character's light source (but 'shadowed' according to logical LoS) is also broken.

6 comments:

Mikolaj said...

Wow, what a nice project! I've just found it thanks to a link in Andrew Doull's blog.

I detest tiles UI for rogulikes, and isometric tiles the most. However true 3D view with, especially 3rd person, with free camera is almost as readable as ASCII and much better suited for 3d dungeons.

About LOS, perhaps the true physical LOS, as seen from the normal eye level of the character, could be taken do decide if a monster, and its shadow, is visible. Then, it looks real when you view the dungeon in 1st person, but the character squirming, squatting, jumping, etc. withing his cells does not change the visibility. Then, if the player moves the camera, he just has to remember the image is just an exprapolation of what the character sees and not a physical camera mounted on a spy drone flying though the dungeon.

Mikolaj said...

BTW, I may post nonsense, because my experiences are based on UFO:AI, which is turn and cell-based, but done with q2 engine. I've not yet discovered what your engine is...

Snut said...

Thanks for the feedback! I am increasingly leaning towards something based on the true physical LOS, but not sure how performant it will be. More experiments need to be done.

As to the engine, it's basically home-grown from scratch. And nowhere nearly complete enough to be called an engine, at least not with a straight face. As far as I'm aware, there are no game engines yet written in Scala, and I'm trying to minimise my dependency on Java libraries. Plus writing basic engine code is kind of fun, if somewhat akin to reinventing the square wheel...

Mikolaj said...

Scala! Functional programming with static typing! Wonderful! Of course, life would be too beautiful if this project was free software with publicly available SVN, wouldn't it?

Snut said...

Scala is a beautiful, wonderful language so far, but I have to confess that coming from a C++ background I appreciate the fact that it lets me switch to imperative programming when I want to. It makes it so much easier to learn and appreciate the functional side too!

If the engine proves useful (and isn't too embarrassingly badly written, bearing in mind I'm learning the language as I write and making plenty of mistakes) I'll release it as open source. The game will be free, but I'm not sure how open just yet...

Mikolaj said...

No pressure, really. ;)