Search Unity

Question How to draw input texture on top of the destination texture

Discussion in 'Shaders' started by UserNobody, Aug 31, 2021.

  1. UserNobody

    UserNobody

    Joined:
    Oct 3, 2019
    Posts:
    144
    Hello,
    I am still learning to write shaders and currently, I am trying to create a composition shader of sorts.
    I have a main texture which is e.g. 800x640 and I want to draw multiple various size images on top of that main texture.

    So for example, I have this 800x640 texture and I want to draw two 95x150 size zombies on that texture at a certain position and in the correct size.

    Background.png

    I use Graphics.Blit(), where I specify the source, destination textures, and material. I also send x and y source position coordinates and source size values. X and Y coordinates represent a position within the output texture so for example, x 400 and y 320 would be the middle of the output texture.

    Also, some images might be outside the output texture or can be way larger than the output texture itself.

    How can I achieve such a result?