Shaders Cut hole in layer with shader

Discussion in 'Programming' started by JeffJ, Dec 6, 2018.

  1. JeffJ

    JeffJ Member

    Joined:
    Jun 20, 2016
    Posts:
    228
    I have two layers - layer A on top of layer B. I want to cut a hole through layer A on certain areas to see through to layer B.

    I have already done this by placing a distinctly colored sprite/object where I want the cutout(s), draw the layer to a surface, and then apply a shader that removes all pixels with that distinct color.

    [​IMG]

    However, I would like to achieve the same effect without using a surface. What I'm thinking is a shader that works sort of like a magic wand, that will select my distinct area(s) and then remove everything within that area but only on that layer.

    But I'm not even completely sure if this can be done with shaders? And if so, any idea where to start?
     
  2. The Reverend

    The Reverend Member

    Joined:
    Sep 8, 2016
    Posts:
    484
    JeffJ likes this.
  3. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,003
  4. The Reverend

    The Reverend Member

    Joined:
    Sep 8, 2016
    Posts:
    484
    Great post. Read it a while ago but totally forgot it covered shaders as well :)
     
    JeffJ likes this.
  5. JeffJ

    JeffJ Member

    Joined:
    Jun 20, 2016
    Posts:
    228
    Thank you so much! This is great!

    Two things though -

    1: How would I adapt the area to be based on a sprite rather than a mathematically defined shape?

    2: Preferably I would be able to position spritebased objects where I wanted specific holes to be, but with the current architecture, it seems I'd need a unique start and end instance for every hole?

    I actually do remember seeing that post before. I will have a closer look at it. Thanks!
     
  6. The Reverend

    The Reverend Member

    Joined:
    Sep 8, 2016
    Posts:
    484
    Then you'd just use YellowAftrLife's post. He has both approaches there and I'm nowhere near his genious to find anything easier or better :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice