- Home /
Create a shader using mask for sprite
Is it possible to create a shader using mask technic? I want to manage my transparency with this. I attached a picture for show what I mean. The first picture is a character, and a second one the mask (the white part it's what will appear, and the black what will be tansparency. Is it possible to do this and how? Thanks.
Answer by Owen-Reynolds · Aug 03, 2011 at 08:19 PM
Your second picture is a standard alpha/transparency channel and should be part of the first picture. Any shader from the Transparent dropDown will automatically recognize that and have the "black" parts be transparent.
A format like jpg or gif only has an RGB componenent, so can't do this. PNG's have a 4th "alpha" channel (Photoshop calls it transparency, I think.) Depending on the program, you more-or-less use a tool to outline the model, set alpha from that, maybe feather it, and export as PNG. You could maybe even just copy your 2nd picture onto the 4th channel.
If you actually want to mix and match pictures and masks, you will need a shader, and it is very easy to do (if you know how to write shader code, that is.)
Your answer
Follow this Question
Related Questions
Sprite masking 3 Answers
Implement texture masking into simple existing shader 1 Answer
Shader for 2D Sprite "Always Rendered on Top" Problem 0 Answers
Shadercode for alphatesting and transparency at the same time 0 Answers
Multiple sprite mask 0 Answers