Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Is Graphics.Blit an 'Add' or 'Replace'?

Discussion in 'General Graphics' started by CSEliot, Sep 2, 2023.

  1. CSEliot

    CSEliot

    Joined:
    May 9, 2014
    Posts:
    30
    Hello!

    I'm working on a PNG importer for cards and want to auto-apply a black border onto the imported card. Much like how real life cards do for "Bleed".

    I was thinking of having a .png of ONLY the border and the rest transparent. if I Graphics.Blit the imported card art, THEN the edge frame ... will the transparencies overwrite underneath? Would like to find out before spending a day trying it. If anyone has a better suggestion I'm all ears!

    Thanks in advance! (See image below for 'bleed')

    https://egoidmedia.com/wp-content/uploads/2021/03/postcard_template_4X6_bleed.jpg
     
  2. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,834
    You'll always learn more by setting up the test and trying it.

    That said, the docs for Graphics.Blit implies that what is written depends on the Material used. That makes sense, it's up to the shader and parameters for the shader. A default Material is used if you don't give one, which probably means a straight opaque copy. From that I would look at using a Material that included alpha blending or alpha clip as appropriate.
     
    CSEliot likes this.
  3. CSEliot

    CSEliot

    Joined:
    May 9, 2014
    Posts:
    30
    Interesting, my knowledge of shaders is very limited so this is clearly a blindspot of mine that you're leading me to!

    So while I'll likely have to do some 'testing' anyway, I have a super tight deadline and a million things on my todo-list. So I'm hoping to get a 'this is a good idea!' or 'this won't work!' while working on other tasks if I can save myself a day. Either way, your response is appreciated! When I get a chance I'll read more on shaders.