Small shadow improvements…
As I stated on the previous post, I didn’t have time to work on Grey this weekend, since I was participating in Ludum Dare’s 48-Hour Game Development Competition… Before you ask, it didn’t go that well, since I couldn’t come up with a decent idea; I just ended up doing a Voxel World editor… If you want to read some more about the competition, you can check out my personal blog.
Anyway, I had time to add three things to the shadow systems:
First up, I added the “Shadow Cluster”… This works similarly to the Geo Cluster I described in a previous post, but it’s much more simpler, since I use it to store the necessary geometry to render the shadows for all the static objects in the light’s radius. Since I only need vertex positions to render the shadows, it makes for pretty small buffers, that are lightning fast rendering!
This gave us an improvement of about 100 FPS in our test scene…
Another thing I messed about is “light volume culling”. Before I was drawing all the objects in the scene to the shadowmaps, even if they weren’t in the light’s radius, but now the system does culling and as such only renders things that actually need to cast a shadow.
Finally, I added an option to enable a small trick…
Until now, all lights needed to have a “shadow epsilon” value tweaked on each light, which would do a small bias in the shadowmap so that the object wouldn’t incorrectly self shadow itself… This parameter was quite fickle and depended on the distance of the light to the closest object, angle to the light, etc, etc… Even if the parameter was well tweaked for some circumstances, if the lights were dynamic, all bets were off!
As you can see, the light is incorrectly shadowing the bottom-right column (the one closest to the light).
More technical explanation follows:
Tweaking the epsilon value, I’d get something like:
Which fixes that objects, but offsets the distant shadows a large amount. For example, see where the shadow of the left-most tree’s trunk starts!
By using a trick called “shadow backface”, I manage to avoid most of this:
On the screenshot above, the epsilon value is set to the same value as in the first screenshot. There’s still some errors (on the top of the closest column), but that’s mostly because this column is a terrible example (too thin).
This trick involves rendering the back faces of the geometry, instead of the front faces (as normal). That acts as a “natural” offset, and shouldn’t change the end result that much in “closed” objects, since the shadowed area of any closed object is beyond its back face.
This makes tweaking of the lights a bit easier, we think…
That’s all I managed to do on the weekend, but it really improves the shadows and makes them more efficient (which is one of the main drawbacks of shadowmaps).
Rest of the week, I’ll hopefully finish the tool that allows for project merger (something we’ll need when we start working on different parts of the game).
Comment
You must be logged in to post a comment.