Hello Guest

Author Topic: Sprite blendmode  (Read 15001 times)

camelot10

  • Newbie
  • *
  • Posts: 24
    • View Profile
Sprite blendmode
« on: July 25, 2012, 12:56:40 pm »
Can someone point me.
How i can change sprite blend mode like "additive", "multiply" or "color dodge" ?
thanks.

p.s. im new to unity and 2D toolkit. former flash developer. search this forum and google for "2d toolkit blendmode" and didnt find anything useful.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite blendmode
« Reply #1 on: July 25, 2012, 06:17:09 pm »
Those blend modes are "Photoshop blend modes". You can simulate a few of them using shaders, but not all of them are possible when dealing with accelerated hardware. The thing is, every time you need to switch this, you'll need to switch materials - this will massively increase drawcalls depending on sort order and various other things.

Using premulitplied alpha, you can do additive and alpha blended in the same sprite collection and as a result not incur any extra draw calls.

camelot10

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Sprite blendmode
« Reply #2 on: July 26, 2012, 10:23:35 am »
found how to use additive blending. changed atlas meterial shader to "particle/additive".
and its change blending of all sprites from this atals.

i realy don't know how to use normal and additive sprites in one atlas.
if you point me "how"
or maybe official 2D Toolkit tutorial would help alot to me and others in future.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite blendmode
« Reply #3 on: July 26, 2012, 10:50:41 am »
I take it you've seen the tutorials here? (There isn't one about the additive blending there, its just mentioned in there)
http://unikronsoftware.com/2dtoolkit/doc/

To mix additive & non-additive sprites in the same collection is a slightly advanced feature (and I'm not sure if anyone else has actually used it apart from us). It used to be much more obvious how to do it in the past, but when the interface got revamped it got made a bit more obscure as it wasn't widely used.

Here are the steps to do it -

1. Create a sprite collection as usual and fill it
2. Go to the sprite collection settings overlay, then tick "Premultiplied Alpha"
3. Double click on the Material listed at the bottom of "Settings" and switch the shader to "tk2d/PremulVertexColor" (the default is tk2d/BlendVertexColor)
4. Go back to the sprite collection editor, find the sprite you want to make additive, and tick "Additive" (This is only visible when premultiplied alpha is on).
5. Commit.

That should be it. When you create that sprite, it'll be additive.


camelot10

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: Sprite blendmode
« Reply #4 on: July 26, 2012, 11:24:09 am »
thanks alot.