Search Unity

Trouble With Shader

Discussion in 'Shaders' started by Danil0v3s, Jan 20, 2021.

  1. Danil0v3s

    Danil0v3s

    Joined:
    Sep 22, 2014
    Posts:
    45
    Hey, I've been trying to reproduce the effects of an OpenGL shader but I don't know much about neither OpenGL or Shaders. So far I've found that the Additive shader in Unity recreates most of what I want, however it seems like I need the alpha channel to taken into consideration as well.

    My reference code uses

    gl.blendFunc( D3DBLEND_SRCALPHA, D3DBLEND_DESTALPHA );


    I then searched for the source code of the Mobile/Particles/Additive and found this
    Code (CSharp):
    1. Shader "Effects/Custom" {
    2.     Properties{
    3.         _MainTex("Particle Texture", 2D) = "white" {}
    4.     }
    5.  
    6.     Category{
    7.         Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
    8.         Blend SrcAlpha One
    9.         Cull Off Lighting Off ZWrite Off Fog { Color(0,0,0,0) }
    10.  
    11.         BindChannels {
    12.             Bind "Color", color
    13.             Bind "Vertex", vertex
    14.             Bind "TexCoord", texcoord
    15.         }
    16.  
    17.         SubShader {
    18.             Pass {
    19.                 SetTexture[_MainTex] {
    20.                     combine texture * primary
    21.                 }
    22.             }
    23.         }
    24.     }
    25. }
    But I can't seem to get it working with
    Blend SrcAlpha DstAlpha


    This is the result with the shader untouched


    And this is what my reference looks like



    Can anyone help me sort this out?