AuthorTopic: Pixel Perfect Shadows, does anybody use them?  (Read 2801 times)

Offline Cherno

  • 0010
  • *
  • Posts: 122
  • Karma: +0/-0
    • View Profile

Pixel Perfect Shadows, does anybody use them?

on: April 07, 2016, 12:34:19 am
(I'm aware that the term "Pixel Perfect Shadows" generally has a different meaning than the one I try to convey here, but it it's still the best term to describe what I'm thinking of)

Let's that we create a pixel art-based game (maybe something low resolution like Minecraft). Let's say we have 16 pixels per world unit (a common size), and all texture and sprite resolutions are bound to that pixels/unit scale. The shadow a light creates should only either fill one pixel on a texture completely or not at all. Here is an image I created to better illustrate what I mean:



Now, This doesn't have to be in 3D space of course, it could also be done for classic pixel art for a top-down perspective. In this case, the shadows would either have infinite length, or the length of the shadows (or rather the height of the point light) would have to be specified.

Here is the only video I found via Google:

https://www.youtube.com/watch?v=q8Zguxctojs

The technique would probably become more complex for isometric games, but for a true top-down perspective it wouldn't be too hard.

I just wonder if any game has uses this technique, because I can't think of one and my searches have been fruitless. Then again, maybe I used the wrong search terms.

Offline AlexHW

  • 0100
  • ***
  • Posts: 1037
  • Karma: +0/-0
    • View Profile
    • AlexHW

Re: Pixel Perfect Shadows, does anybody use them?

Reply #1 on: April 07, 2016, 04:42:27 am
Closest thing I can think of that is similar, are rougelikes that use a tile-based line of sight. So they end up with very square looking castings.
I think your suggestion for aliasing the casted shadows is a cool idea.

Offline yrizoud

  • 0010
  • *
  • Posts: 330
  • Karma: +0/-0
    • View Profile

Re: Pixel Perfect Shadows, does anybody use them?

Reply #2 on: April 07, 2016, 07:31:07 am
See videos of the game Cyberdogs or its sequel C-Dogs, they use dynamic line-of-sight at the tile level.

Offline Ai

  • 0100
  • ***
  • Posts: 1057
  • Karma: +2/-0
  • finti
    • http://pixeljoint.com/pixels/profile.asp?id=1996
    • finticemo
    • View Profile

Re: Pixel Perfect Shadows, does anybody use them?

Reply #3 on: April 07, 2016, 08:26:42 am
Closest thing I can think of that is similar, are rougelikes
Like alizarin crimson?

</ /r/roguelikes/ common complaints>
If you insist on being pessimistic about your own abilities, consider also being pessimistic about the accuracy of that pessimistic judgement.

Offline Cherno

  • 0010
  • *
  • Posts: 122
  • Karma: +0/-0
    • View Profile

Re: Pixel Perfect Shadows, does anybody use them?

Reply #4 on: April 07, 2016, 11:45:59 am
Yes, the per-tile shadows are basically the same principle, but in an extremely low resolution, so to speak (1:1 pixels per unit :) ).

I am programming in Unity and have no shader writing experience, so I guess I'll just throw together a C# Mono script and see if it's fast enough to do it dynamically (as opposed to static / baking). The most straightforward way would be to have a texture as a shadowmap over the level, preferably in chunks, and set the pixels to black or transparent depending on each light source's position relative to the nearest collision vertices.