Log In  


Cart #28633 | 2016-09-17 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
21

OVERVIEW
This cart is a bit of a demo of a few shadow methods I've given some thought to. The first two techniques work best at 60fps, but the final technique I think is suitable at any speed.

UPDATE
The original cart had an issue where the "peek/poke merge" technique could not draw starting at odd numbered X coordinates. This has been fixed (but made things a bit more complicated)

METHODS

1 ON/OFF SPRITE:
This method uses a solid shadow sprite that cycles between on/off every frame

2 ALTERNATE PATTERNED SPRITE:
This method uses two sprites with an alternating pattern that is cycled every frame

3 PEEK/POKE MERGE:
This is what I really wanted to get to :) This method uses a defined palette of darker colours. Each PICO-8 colour is given a darker alternative. For some, that is full black, but for 8 (red), it is given dark purple (2).

  • The shadow sprite is read in from PICO-8's memory and every pixel that is not black is considered shadow, and black is ignored.
  • The draw coordinates for the shadow are read from memory in the graphic area, the existing colour values are determined and are replaced with their darker version wherever there is shadow pixel in the sprite
  • The new darker pixels are poked back into memory

CONTROLS

O: Cycle shadow method
X: Cycle background

Down: Toggle background scrolling

21


That's pretty cool. The first technique was pretty popular for retro game consoles like the SNES. The second one that uses two checkerboard patterns is very smooth on my end, and hard to notice the trick unless you look really close.


I found the first technique flickers quite a bit at a stand still at least on PICO-8 on my monitor. I've added the ability to toggle the background scrolling with the Down arrow. This will make the effect a bit more obvious, and it's also affected by which colours are being used.


1

The Peek/Poke/Merge is awesome. No flicker at all, nicely done !


I too, like the peek/poke/merge. Very good technique here.


aaaaand..... pico8 got transparent shadows in less time that the PC took for same feat :P



[Please log in to post a comment]