Author Topic: Clipping with Additive Shader  (Read 4766 times)

BLDGBLOCK

  • Guest
Clipping with Additive Shader
« on: July 29, 2013, 10:29:05 PM »
Hello.

I started using NGUI recently, and this is my first post.

I'm looking for a special way to clipping with additive colored shader,
because it is just good looking rather than transparent colored shader
to create transparent interface.

Does anybody know about this ?

xenonii

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Clipping with Additive Shader
« Reply #1 on: May 01, 2014, 03:42:15 AM »
Having an unlit additive shader which works with clipping would be nice.
I tried doing a modified shader but was still getting pink result when inside a clipping panel. But i'm not really into shaders.
Michael Lyashenko, can you provide a working additive shader which is supported inside a clipping panel?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Clipping with Additive Shader
« Reply #2 on: May 02, 2014, 07:38:08 AM »
NGUI's clipping is done by choosing a different shader with a similar name. Look at the existing shaders, for exmaple:

Unlit - Transparent Colored < -- used if no clipping is needed
Unlit - Transparent Colored 1 <-- used if there is 1 panel clipping the content
Unlit - Transparent Colored 2 <-- used if there are 2 panels clipping the content
Unlit - Transparent Colored 3 <-- used if there are 3 panels clipping the content

When making custom shaders, you would need to follow the same naming convention. The easiest thing to do is to just make a copy of at least two shaders (the first two) and modify them to suit your needs. In case of additive blending, all you would do is change the blend line from:
  1. Blend SrcAlpha OneMinusSrcAlpha
to:
  1. Blend One One
Source: https://docs.unity3d.com/Documentation/Components/SL-Blend.html

beermoney

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 80
    • View Profile
Re: Clipping with Additive Shader
« Reply #3 on: June 01, 2015, 07:53:40 AM »
for ref, the blend mode for transparent additive is:

  1. Blend SrcAlpha One
  2.