Real-Time Shadows

Hey everyone,

I noticed a recent game out for iPhone that displays realtime shadows.
Very nice!

Blades of Fury by Gameloft

Does anyone know how the shadows are produced? Is it the 3D engine they’re using that makes it possible or clever coding?

Just curious.

It’s funny, how such an old technic is now “new” again :smile:

Looks to me like the oldest shadow-technik after the ugly blob-shadows. Take your 3D model, make it flat, tint it and make it transparent…bam! Nice shadow but ONLY useful on flat grounds!

those guys at gameloft know how to make good money… and visuals!
I guess Ubi Soft get as much money from gameloft as from Assassins Creed (investing much less).

I implemented faked real-time shadowing in our game recently. They work great and play nice with the fence at the back of the level, appearing to stretch from the ground to the fence. That was more luck with our multi-camera setup than a planned thing :slight_smile:

We’re using a mixture of 3d for the background and static objects, and sprites for anything animated. Since characters and weapons fly through the air we couldn’t bake them onto the sprites, I ended up having to create a new camera for the shadows due to our mixture of ortho and non-ortho cameras, luckily the performance dip was barely noticeable. Our artist actually convinced me to look into more detailed shadows, so kudos to him for pushing me, they really help to ground everything more than simple blob shadows! It was fairly trivial to get running, our ground is mostly flat and so they rarely look out of place.

We’ll release a new video of our game soon to show off the effect, I may be biased but I think it looks night and day better :roll: For those interested in what the current game looks like, and to see a before video, here’s an old build with buggy blob shadows: http://www.youtube.com/watch?v=sjk1yZyQ2NA

Actually it looks like stencil shadows :slight_smile:

There’s no access to stencil buffers on the iPhone. Note that these particular shadows in Blades of Fury are solid-shaded gray shapes, rather than being transparent, and the ground is indeed just a flat plane, so they are almost certainly using the “flattened characters” technique seen in Quake 2 et al. One problem with this technique is that if you use transparent shadows, like Quake 2 does, overlapping shadows are darker where they overlap, which looks kinda silly. Using a solid gray shape prevents this, but has its own problem; namely, looking rather drab.

More interesting shadows are in 2XL Supercross among others, where they aren’t a solid color and are projected on arbitrary geometry. Not really sure how they were done; would be interesting to know… (Aside from shadows for non-player geometry, which are obviously lightmaps.)

–Eric

Such shadows aren’t that much more complex

primarily a question of edge calculation and edge projection instead of full mesh projection.
You are basically doing the same as with other shadow calculation technics, just in pure math on the cpu

Don’t know, if anyone here owns Blitz3D (DX7, no stencil and render texture support) + Sswifts shadow system, but if anyone does: that does exactly that for example, offering even transparent texture projection shadows for stuff like stained glass and alike.
Its all pure math, with an engine opted to do that, you can get away pretty good.

The shadows in 2XL Supercross actually look distinctly texture-based, like the shadows in Unity Pro. I think they also fade out in the distance in the same way, but it’s hard to tell.

–Eric

that can all be achieved through mesh based shadows casted from the edge.

fading is nothing but vertex alpha.

even smooth shadow borders are doable through texture alpha.

Unity’s shadow system is not much different from that unless I’m wrong.
Just that it uses a texture and shaders to project it straight through the gpu.

The next “higher” shadow casting approach is PSSM which I’m not sure if it is beeing used as it is commonly used with “modern” rendering backends with forward or deferred rendering or hybrids where it can be implemented much more efficientely. Unity as far as I see seems to be more like the traditional renderers where FFP was the core and shaders for visual extension, just that unity is capable to use shaders instead of FFP too. Basically like TGEA works.

At least thats my understanding from different postings (no floating point render target pretty clearly rules out any forward and deferred rendering as the depth precision would be horrible)

Quite a variety of responses on the real time shadows.
Still wondering what technique was used.

@Eric5h5
I think your theory sounds the most likely so far. But how is that acheived?
They are solid gray shapes as opposed to being transparent. I took a hard look at the 2XL Supercross game and I do like their shadows but if you watch closely, they’re not as accurate as the Blades of Fury shadows. Seems like the Supercross shadows are textured shadows (individual PNG files?) that are scripted to display based on the rotation of the rider. Not even sure if that’s possible. Maybe too much of a memory hog.

When you study the Blades of Fury shadows, they are more accurate as far as shadows being cast as related to player movement. I did notice that one of the shadows cast from one of the weapons ( a large sword) the shadow wasn’t shaped like the weapon. It was a rectangle. So there was some simplifying going on.

@JTBentley
I’m curious about the stencil shadows and if they are possible on the iphone or not.

I’m working on a game that would benefit greatly from a similar shadow system and I really need to find a way to pull it off.

Thanks for your input guys!
It’s much appreciated.

@dreamora
I’m also curious about the mesh-based shadows. Sounds like that would be too memory-intensive. Not really sure though.

@Samb88
It’s funny, how such an old technic is now “new” again
Looks to me like the oldest shadow-technik after the ugly blob-shadows. Take your 3D model, make it flat, tint it and make it transparent…bam! Nice shadow but ONLY useful on flat grounds!

That sounds like memory intensive also.
When you say take your model and make it flat, tint it, etc. . . . how does that shape follow the movement of the character?

Can you elaborate?

Thanks a lot!

Nope, they are clearly generated from the bike/rider models in real time. If your guy goes flying off the bike, the shadows are still accurate.

Shadows in Unity are basically done by rendering the scene to a texture, and it looks a lot like the Supercross shadows are done more or less the same way, except I thought the iPhone didn’t have any way to do render-to-texture.

The shadows are flattened models with no texturing (aside from plain gray), so that means the weapon is actually a rectangle with a sword texture on it rather than being modeled out of polygons.

Not possible, at least not on older devices; not sure about the new iPhone/iPods.

Not at all; you use a flattened projection of the models you want to have shadows…using some math…not sure about that part exactly. :wink: But I am pretty sure there must be articles about it floating around on the net.

–Eric

The iphone has pbuffers, unity just does not support/expose them in Unity iPhone Advanced yet.

I wouldn’t worry about the possibility but more about the 3FPS you can expect with stencil shadow on a device like the iphone with its low bandwidth and 0 fillrate.

Just did a little research on the 2XL Supercross game for the iPhone.

It’s a game engine written by another company and they are projection shadows.
The company is a console game maker that ported the game to the iPhone.

Here’s a line from an article I found:

You won’t believe what you’re playing in the palm of your hand! “2XL Supercross” features liquid-color graphics, fully interactive 3D physics, surround sound, authentic engine recordings, particle effects, projected shadows and lighting.

My guess is it won’t be too long before Unity iPhone Advance has this ability.
Hopefully not too long.

wouldn’t bet on that. projected shadows are very costly and need to be used in a specifically optimized environment or they will totally kill the performance due to the projection calculation.
I doubt you will see them in the forseable future in Unity iPHone Advanced.

Dremora - Could you imagine if there was a single click shadow solution? Every day there’d be a new forum thread ‘Help! My game runs like crap!’

… Only to find out they’ve got 60 realtime shadows on everything…

There’d need to be a pinned thread at the top “DON’T USE THE DAMN SHADOWS!”

Nah, they’d have it be Advanced-only, so there wouldn’t be as many people using it. In any case, I wasn’t aware that UT didn’t do features just because they might conceivably be abused by a few people who don’t necessarily know what they’re doing at first; doesn’t sound like their philosophy…

–Eric

Really? We have real time Global Illumination working on the iPhone at 30 fps, but we’re afraid to release it because it only works if your scene is rendering under 50k vertices at any one time :wink:

Yeah, our philosophy is definitely to give you as much rope as you need to hang yourself (and then some)… we’ll never hold back features just because they’d be abused by a minority of users.

Aarrghhh, my current game uses 49,996 vertices!! It would totally work!!! Release this feature dammit!!!

:wink:

–Eric

I had trouble with the Realtime globals on my remake of the Lord of the Rings battle sequence on the device (I’m on the beta version that has the realtime globals)

I listed it as a bug but nobody from unity seems to be helping me…