Classic 3D videogame shadow techniques

(30fps.net)

219 points | by ibobev 9 hours ago ago

39 comments

  • 01HNNWZ0MV43FF 2 hours ago

    My favorite shadow fact is that outdoor shadows are blue.

    It's not an optical illusion or artistic vibe or anything. The sky is blue, shadows on a clear day are illuminated by bounced light from the sky, therefore shadows are blue.

    If you look underneath cars you can see it - A sharp blue shadow where the sky is visible, that fades to true black where the car's body occludes light from the sky.

    If you combine this sharp blue sun shadow with a soft and black "AO" sky shadow you can get very pretty shadows for cheap.

    • Sohcahtoa82 an hour ago

      It's true, and so subtle that a lot of people don't even notice it.

      But a good graphics rendering engine will do it. Shadows should carry a slight tint from the color of the sky.

      Which is why some old screenshots of No Man's Sky bothered me. Pretty sure I saw scenes where shadows were purple despite a green sky.

  • jsheard 6 hours ago

    I like the variant used in modern Nintendo platformers - they use shadow maps like basically everything else nowadays, but the player characters shadow is rigged to always be cast straight down regardless of where the actual light sources are. That helps the player gauge where they're going to land after a jump like a classic blob shadow, but with the visual fidelity of a proper shadow.

    IIRC in dark environments they also rig the shadow to be brighter than the ground to make sure it remains visible.

  • throwawayk7h 11 minutes ago

    > Shadows do become darker when they overlap in Metal Gear Solid.

    They should indeed get darker when there are multiple significant light sources, as in the Metal Gear Solid screenshot. This is because the addition of another obstruction (i.e. Solid Snake) causes more sources of light to be blocked.

    • ajuc 6 minutes ago

      I recently realized this when there was a heat-wave and I walked through a small patch of trees in the middle of the city.

      The shadows of buildings were pretty light color and walking through them wasn't changing the temperature noticeably. But between the trees almost all of the sky was blocked - so the diffused light wasn't getting there - and the shadow there was much darker and it was significantly colder than every other part of the city.

      So - shadows can get darker or lighter, even if there's just one light source and it's very far :).

  • aarongeisler 4 hours ago

    Great post. There are lots of nostalgic game references here. I still remember being blown away by the shadows in the N64 Zelda many years ago.

    I expect area lights and soft shadows to become the norm as ray-traced techniques are adopted. If you have the hardware, it's worth checking out Quake 2 RTX to see what the future might look like.

    Lastly, I've added your blog to my growing list of graphics resources: https://github.com/aaron9000/c-game-resources

    • lawlessone 2 hours ago

      Honestly if they can get good enough shadows with smoke and mirror trickery i'd prefer they stick to smoke and mirrors for performance reasons.

      • aarongeisler 18 minutes ago

        Agreed. Even with a top-end GPU I almost always turn off RT features. I expect we will continue to see hybrid RT approaches for the foreseeable future.

  • mordae 3 hours ago

    Thanks, it was an interesting read. Could have been more technical, though.

    I am toying with lighting little voxel grid scene these days, targeting RP2040 and a measly 160x120 px screen and it's crazy how computationally and memory expensive this stuff is.

  • msephton 4 hours ago

    One of my favourites are the shadows in PS1 game Power Shovel (aka Power Diggerz) which were interesting as they had to be projected over uneven terrain. I guess planar shadows is the closest technique in the article. https://www.youtube.com/watch?v=j_c4ZgcLTuE

    • edflsafoiewq 3 hours ago

      Interesting. It looks like each vertex in the "shadow model" is projected onto the ground individually, which means the shadows can "peel away" from the ground.

                  :   :
                  :   :____  ground
                  :  /|
                  : / | wall
        ground  __:/__|
  • otikik 8 hours ago

    Shadows do get "darker" when they overlap and there's more than a single light source.

    3 people illuminated by 2 lamps will project 6 shadows. Where the 6 shadows all overlap, that will be "black" (or only picking ambient light). In other places where less shadows overlap, you will get a gradient of illumination.

    • fregus 6 hours ago

      that's not true, it will be black (or ambient light) when any two shadows, one from each light, intersect. that's because if it is in shadow from light A and in shadow from light B, where would it get any illumination from? only from the ambient light, or if there is none, it would be black.

      • terminalbraid 5 hours ago

        No. Consider two objects, two light sources, and an ant.

        An ant outside any shadow can see both light sources.

        An ant in a non-overlapping shadow cast from one object will have one light source blocked out but the other light source will be visible to the ant.

        An ant in overlapping shadows from two objects will have both light sources blocked out. (Geometrically in this case it is necessary the overlapping shadows be cast from two separated points each from distinct light sources)

        When one light source is visible to the ant that area must be lighter than when no sources are visible. This is the scenario presented by the OP.

        edit: Since people seem to not believe this you can find a representation in part E in this diagram

        https://i.imgur.com/r6x6QPQ.jpeg

        and a photograph of this nicely done with colored lights here

        https://i.imgur.com/NUlywpb.jpeg

        • twodave 5 hours ago

          We aren’t questioning your logic, just your reading comprehension in this case :) OP was correctly describing the case where both lights are blocked from view.

          • terminalbraid 4 hours ago

            Just to summarize, because someone is missing something:

            otikik pointed out a case of multiple light sources where overlapping shadows will be darker (otikik is correct)

            fregus says "that's not correct" and argues a true case (shadows from one light source will not be darker) which is a bad argument because it tries to overgeneralize. The case from fregus is for the same light source and they cannot use this to argue otikik is incorrect because otikik's argument explicitly requires multiple light sources.

            I point out, responding to fregus, how otikik is correct and how you need to consider multiple sources as well as including examples and physical evidence.

            You question my reading comprehension for some reason

            • freestyle24147 2 hours ago

              > ... when any two shadows, one from each light, intersect. that's because if it is in shadow from light A and in shadow from light B ...

              They actually reference two light sources TWICE in their comment: ("any two shadows, one from each light", "from light A and in shadow from light B"). Hence the question of reading comprehension.

            • danparsonson 3 hours ago

              > when any two shadows, one from each light

              @fregus explicitly described a scene with two light sources. Thus the question about your reading comprehension.

            • Fraterkes 4 hours ago

              Fregus point is that otikik seems to suggest that the darkest shadow will be the combination of all 6 shadows; thats obviously wrong, any shadow blocked from both lights will be as dark as any other shadow blocked from both lights, no matter the amount of "overlapping" shadows. You then respond to Fregus by unnecesarily just explaining shadows again, hence the reading comprehension comment.

              • binary132 4 hours ago

                Let’s all write long explanations of one another’s long explanations, then the people who couldn’t comprehend the simple point in the first place will definitely understand

                • Fraterkes 2 hours ago

                  I'm not talking to "people", I'm writing a specific response to a specific person. Do try to keep up

      • binary132 4 hours ago

        That would be true if lights were simple point sources with simple straight ray behavior and no diffusion and no reflection but they’re not.

    • lukan 7 hours ago

      Good observation, but the article is not wrong (and quite interesting)

      "There’s just one light source, and relatively far away, so the shadow is simply an absence of light."

  • samsartor 2 hours ago

    SketchUp uses stencil shadows! Although we have more modern options, it is part of the look.

  • chungus 7 hours ago

    Clicked this because it sounded interesting and was surprised to see one of my favorite movies in the introduction!

    edit: really nice and nostalgic read, I played almost all of the games mentioned.

  • tanepiper 2 hours ago

    A great article but I can't believe they missed Third: The Dark Project from their list.

  • MattRix 5 hours ago

    For an example of the state of the art in videogame lighting, check of Epic’s recent UE 5.5 MegaLights demo: https://youtu.be/p9XgF3ijVRQ?si=GcU0kP33iKQh_5Ge

  • nuancebydefault 7 hours ago

    So many shadowing techniques! Interesting how using ray tracing inherently makes rendering shadows a non issue.

    • samsartor 2 hours ago

      Sorta, in classical single-bounce ray tracing you still need to cast explicit shadow rays from diffuse surfaces. Path tracing gives shadows for free, because it is simulating global illumination rit large: ambient occlusion, shadows, bounce light are all special cases.

    • Cthulhu_ 6 hours ago

      I mean ray tracing is (probably? I'm no expert) the most physically accurate rendering method available, mapping closely to how light works in real life ('rays' of light bouncing around until they hit your retina, but then in reverse so you only simulate the rays that actually hit the camera instead of wasting every one that doesn't). But it's also the most expensive one.

      • hnuser123456 6 hours ago

        We're at the point where we need new systems to represent material surfaces better, like leaves glowing from beneath when sun hits them from above, since they're thin enough for light get through. Or imagine putting a flashlight on your skin and seeing your skin glow from the inside around it. Unfortunately a much more complicated scenario than large open rooms and solid flat walls.

        • jsheard 6 hours ago

          Games do simulate subsurface scattering, it's been a staple since the PS4 generation. They currently fake it rather than brute forcing the light paths traveling inside the surface like offline renderers do, but it still works fairly well.

          https://old.reddit.com/r/gaming/comments/4jc38z/til_in_uncha...

          In offline rendering the sky is the limit when it comes to SSS quality, if you have enough compute to throw at it. It's essential for getting skin to look right.

          https://x.com/HadiKarimi_Art/status/1730627284141216181

        • Keyframe 3 hours ago

          BRDF, BSSRDF.. all can simulate that and are part of the rendering equation (Kajiya) if you plug it in.

        • bathtub365 4 hours ago

          Why are the existing systems inadequate?

      • teamonkey 5 hours ago

        Ray tracing algorithms are quite simple - it’s essentially just checking line intersections with geometry and doing bounce calculations - but a VAST number of rays are needed and a GPU that can do ray tracing needs to keep much more information about the scene geometry in memory. In older generations you wouldn’t store detailed collision information in GPU memory.

        A GPU that can handle ray tracing, however, can do a lot of the techniques mentioned in the article (and others) more efficiently without doing what you’d consider full scene ray tracing, because the fundamental path tracing algorithms are very versatile.

    • lukan 6 hours ago

      "Interesting how using ray tracing inherently makes rendering shadows a non issue."

      Raytracing simulates real lighting. Shadows are, where no light is.

      • magicalhippo 5 hours ago

        In traditional Whitted-style ray tracing, the expensive part is indeed figuring out where there is no light. You know where you are, you know where the light is, but is there something inbetween?

  • moralestapia 3 hours ago

    Great article, fun to read.

    The shadow overlap in MGS is not completely incorrect as there's ambient light, scattering and other similar global illumination phenomena.

    >Mirror’s Edge (2008, PC) is basically Lightmaps: The Game.

    Lol, true. Impressive game at the time, and even nowadays.

  • justsomehnguy 5 hours ago

    >> Some early flight simulators draw a top-down flat shadow when on a runway. During my research I expected to see examples where the shadow is also seen when in flight but couldn’t find any.

    F-29 RETAL aka F29 Retaliator aka F29

    That shadow was another small tidbit what gave this game the enormous feel of speed.

    https://imgur.com/a/hOgxr7a

    https://www.mobygames.com/game/6233/f29-retaliator/