Hello Guest

Author Topic: Self illuminated, transparent shader  (Read 3769 times)

kreso22

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Self illuminated, transparent shader
« on: November 30, 2014, 04:51:35 am »
Hi,

First to say I spent 2 days trying to create my own solution with no success. What I gained from these 2 days is some knowledge of shaders, and a huge appreciation for what 2Dtk can do and does (as I was browsing source code for reference).

For my 2D, unlit game I would like to change shade of color for the sprite. I can change sprite's color with 2Dtk editor utility and still stay at 1 draw call, which is great. But the sprite will look too dark.

Is there any way to achieve effect like Self-iluminated/Diffuse shader? The effect that I get by just applying Main Color parameter is marvelous. Unfortunately shader doesn't work with transparency. And ideally keep at 1 draw call (edit material tint via script).

I am thinking only change current shader (tk2d/Blend Vertex Color) and somehow multiply values or something, but I don't understand shader rules.

Any help is appreciated.



Thank you in advance,
Kreso

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Self illuminated, transparent shader
« Reply #1 on: November 30, 2014, 12:46:02 pm »
Change blend mode to additive.
Eg. Blend SrcAlpha OneMinusSrcAlpha to Blend SrcAlpha One
That will probably do something similar.

kreso22

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Self illuminated, transparent shader
« Reply #2 on: December 01, 2014, 04:52:08 am »
Thanks a lot for the suggestion. I tried combining all the blend modes and didn't succeed in achieving the effect.
Then I took a step back .. basically I have a greyscale sprite that I want to tint with color. So I tried making it brighter in grayscale - and it worked.
I know this sounds obvious and I should have done that right away... but I did it now.

Thanks a for your help!

Kreso