PurpleKingdomGames / indigo

An FP game engine for Scala.
https://indigoengine.io/
MIT License
650 stars 60 forks source link

Layer Masking #752

Open davesmith00000 opened 4 months ago

davesmith00000 commented 4 months ago

There might be an issue open for this but just wanted to capture quickly.

I've been putting off masking on the excuse that we need render targets first, and that's sort of true, but I think there's probably a work around:

  1. Add another field to Layer.Content that is identical to nodes, called mask.
  2. Render the layer twice:
    1. First you render the mask, and at the last moment, render it to a new mask buffer
    2. Render the layer as normal.
  3. Update the blending process to accept the new mask buffer as a fixed input.
  4. Use the mask during the blend process to decide how much of each pixel to draw. (Alpha values are ok)
  5. Clean the mask before the next layer is rendered.