The Sprites/Default shader multiplies the color with the provided tint, while I need to add it instead. I fixed this copying the shader (taken from here) and simply changing the line

return tex2D(_MainTex, IN.texcoord) * IN.color;


return tex2D(_MainTex, IN.texcoord) + IN.color;

Is this the right approach, or there was a better one? (which uses something like inheritance, as opposite to copy-pasting)

Also, is this legal? I assume they allow you to use it at will, but technically there's no licence attached to the shader, so I'm not sure. Maybe that's covered somewhere in the Unity license?

  • \$\begingroup\$ What do you mean if you want to "add" the color? The first return statement indeed, like you mentioned, tints the texture with a certain color but what is it exactly that you want to create? Do you have a reference or something? \$\endgroup\$ – Dries Jan 4 '14 at 13:44
  • 1
    \$\begingroup\$ What you're doing is completely fine. I can't think of any simpler way to achieve what you're trying to do. IANAL, but Unity provides the included shaders & scripts as a base with the express purpose of developers building upon them. Something as simple as a textured sprite shader isn't worth getting proprietary over. ;) \$\endgroup\$ – DMGregory Jan 4 '14 at 21:34
  • \$\begingroup\$ @DMGregory you may put it into an answer, then ;) \$\endgroup\$ – o0'. Jan 4 '14 at 23:34
  • 1
    \$\begingroup\$ I figured I'd leave answering for someone with some evidence to back up the point, since all I've really got is opinion (which I may think is sound, but still). \$\endgroup\$ – DMGregory Jan 5 '14 at 16:05
  • \$\begingroup\$ not to sure on this one, but isnt this the update that unity released in 3.0? basically shouldn't really matter which one you choose i dont think, if this is the case just go with the more recent version. Might look into this. \$\endgroup\$ – lemunk Jan 6 '14 at 14:45

According to this answer, you can either include common files, but this isn't the case, or use the UsePass command, but is not helpful here either.

Since apparently there isn't really inheritance like with normal object-oriented languages, I'd say there's no other way to do that.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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