Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

An average between addictive and multiply in particles?

Discussion in 'General Graphics' started by dworm, Sep 5, 2015.

  1. dworm

    dworm

    Joined:
    Jun 17, 2015
    Posts:
    74
    Im trying to make a classic explosion and my problem is while i love more the multiply option into shader it doesnt "cover" very well the background.
    Addictive has the problem of not working well with blackish tints, like the final smoke or similar effects.
    Multiply has the problem of not covering the blacks (im no expert i guess you cant multiply a zero but i cant avoid having blacks in the BG...)

    So i need a particle system that just makes particle adds each other like the aboves BUT also dont mix that much with background, i want to pretty much cover the background WHATEVER that is...

    It seems pretty standard tbh but i cant figure a way to do it...
     
  2. Catinightmare

    Catinightmare

    Joined:
    Sep 18, 2013
    Posts:
    11
    Do you mean having a particle shader which has both additive and multiply effects on it?

    Code (CSharp):
    1. Shader "Particle/Additive and Alphablend"
    2. {
    3. Properties
    4. {
    5.     _MainTex ("_MainTex RGBA", 2D) = "white" {}
    6. }
    7.  
    8. Category
    9. {
    10.     Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
    11.      Cull Off Lighting Off ZWrite Off Lighting Off
    12.    
    13.     SubShader
    14.     {
    15.         Pass
    16.         {
    17.             //Render Alpha Blend First
    18.             Blend SrcAlpha OneMinusSrcAlpha
    19.            
    20.             CGPROGRAM
    21.             #pragma vertex vert
    22.             #pragma fragment frag
    23.  
    24.             #include "UnityCG.cginc"
    25.  
    26.             sampler2D _MainTex;
    27.            
    28.             struct appdata_t {
    29.                 fixed4 vertex : POSITION;
    30.                 fixed2 texcoord : TEXCOORD0;
    31.                 fixed4 color : COLOR;
    32.             };
    33.  
    34.             struct v2f {
    35.                 fixed4 vertex : SV_POSITION;
    36.                 fixed2 texcoord : TEXCOORD0;
    37.                 fixed4 color : COLOR;
    38.             };
    39.            
    40.             fixed4 _MainTex_ST;
    41.  
    42.             v2f vert (appdata_t v)
    43.             {
    44.                 v2f o;
    45.                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
    46.                 o.texcoord =  TRANSFORM_TEX(v.texcoord, _MainTex);
    47.                 o.color = v.color;
    48.  
    49.                 return o;
    50.             }
    51.            
    52.             fixed4 frag (v2f i) : Color
    53.             {
    54.                 fixed4 tex = tex2D(_MainTex, i.texcoord);
    55.                
    56.                 return tex*i.color;
    57.             }
    58.             ENDCG
    59.         }
    60.        
    61.         Pass
    62.         {
    63.             //Then Additive
    64.             Blend SrcAlpha One
    65.            
    66.             CGPROGRAM
    67.             #pragma vertex vert
    68.             #pragma fragment frag
    69.  
    70.             #include "UnityCG.cginc"
    71.  
    72.             sampler2D _MainTex;
    73.            
    74.             struct appdata_t {
    75.                 fixed4 vertex : POSITION;
    76.                 fixed2 texcoord : TEXCOORD0;
    77.                 fixed4 color : COLOR;
    78.             };
    79.  
    80.             struct v2f {
    81.                 fixed4 vertex : SV_POSITION;
    82.                 fixed2 texcoord : TEXCOORD0;
    83.                 fixed4 color : COLOR;
    84.             };
    85.            
    86.             fixed4 _MainTex_ST;
    87.  
    88.             v2f vert (appdata_t v)
    89.             {
    90.                 v2f o;
    91.                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
    92.                 o.texcoord =  TRANSFORM_TEX(v.texcoord, _MainTex);
    93.                 o.color = v.color;
    94.  
    95.                 return o;
    96.             }
    97.            
    98.             fixed4 frag (v2f i) : Color
    99.             {
    100.                 fixed4 tex = tex2D(_MainTex, i.texcoord);
    101.                
    102.                 return tex*i.color;
    103.             }
    104.             ENDCG
    105.         }
    106.     }  
    107. }
    108. }
    109.  
     
  3. dworm

    dworm

    Joined:
    Jun 17, 2015
    Posts:
    74
    Well more like something with the effect described, i dont know if adding both makes that effect i want.

    Anyway ill try your idea and see if works, ty.