0
\$\begingroup\$

I want to take an (animated) 2-d sprite and apply a texture to it. Basically, I want every non-transparent pixel to be covered by the texture (color is disregarded). I understand I can probably accomplish this using masks but I am worried that may not be the most performant solution. I know you can put textures onto 3-d models, so I was wondering if there was a similar process for 2d sprites. Below I have a graphic demonstrating what I want.

Demonstration

What I have tried so far

I see there is an option to add a material to a sprite, so I tried creating various materials.

1. Default material

enter image description here

When I tried applying this material to my sprite, the sprite disappeared entirely. I suspect because this default material type only works on 3D objects

2. Sprite Material

enter image description here

I figured sprites probably expect sprite materials, so I tried creating one. However, there does not appear to be anywhere to upload an image to use as a texture. This appears to only be useful for adding tints to sprites.

\$\endgroup\$

This question has an open bounty worth +50 reputation from C_Z_ ending in 5 days.

This question has not received enough attention.

  • 1
    \$\begingroup\$ What would make this impossible, based on your research? What have you tried so far? \$\endgroup\$ – DMGregory Feb 9 at 12:30
1
\$\begingroup\$

You need to create a custom shader. The following example is made in Unity's Shader graph. You need to multiply your assets. This site is for undestading these type of operations, which can be applied to Unity too. Quick example of the shader you are aiming for, made with ShaderGraph.

However, there does not appear to be anywhere to upload an image to use as a texture. This appears to only be useful for adding tints to sprites.

You can have properties in the shader and exposed to the inspector and edit the via script(s). In ShaderGraph you can convert variables to properties and even create one editable in the "blackboard".

\$\endgroup\$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.