Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

where is Additive Blend mode for sprites?

Discussion in '2D' started by Deeeds, May 25, 2018.

  1. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    I can't find a way to turn on Additive blend mode for sprites.

    Where am I failing to look, and how is it done?
     
  2. 1Piotrek1

    1Piotrek1

    Joined:
    Mar 14, 2014
    Posts:
    129
    After quick googling I found this: link
    But if you need any shader to work as it were a sprite shader just create a 3d quad and disable it's lighting. Then add material with your sprite image as a texture and correct shader to it (in your case Particles/Additive).
     
  3. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    So there's no switch to create an additive sprite?

    I have to learn use a shader, and a quad and something else... and whatever else... and ... learn to jump through hoops?
     
  4. 1Piotrek1

    1Piotrek1

    Joined:
    Mar 14, 2014
    Posts:
    129
    Yes, Unity doesn't have blend modes built in SpriteRenderer.
    But making materials is pretty straightforward in Unity and when it comes to shader you just create new shader in Assets window and paste the code from the link.
     
  5. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    So it's

    Sprite Texture > Material > Shader

    ?

    Where is the Shader associated or connected to the Material?
     
  6. 1Piotrek1

    1Piotrek1

    Joined:
    Mar 14, 2014
    Posts:
    129
    You select it in material inspector. This video should be helpful for you: link.
    I don't know what else I can tell you. Post your results (as screenshots) after trying the methods that I posted before if you want any more help.
     
  7. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    The easiest mental solution to this is understanding the problem:

    That Unity hasn't considered how 2D could best be done, nor how Sprites are considered by anyone outside 3D, and have used a 3D workflow to present textures in a 3D space, pretending they're Sprites when they're really still quads with a material.

    And... that they've not made anything simpler than the ability to write shaders. Which isn't simple.

    Having spent a few days trying to figure out how their animation systems work, relate, conflate and compete for user attention, I can see this sort of design failure exists throughout.
     
  8. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    23,598
    Perhaps the shader graph included with SRP Lightweight pipeline will suit you? so you can click together shaders. You can find information about that on the blog, across the website etc.
    It is all in the documentation and Learn sections, with hundreds of videos. It is easier to do than all competing engines bar game maker as far as I can tell.

    Sounds like you would prefer to use the Lightweight pipeline and shader graph, as you can better tailor how Unity works for you.
     
  9. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    With hundreds of videos and tutorials... yet you can't point to one.

    You do this all the time. I've seen your posts... over and over... you can't be specific about these great videos and tutorials.

    And there's no process of filtering them, to find the good ones, done by curators and ambassadors of the company, such as yourself.

    Which is also incredible failure to consider new users.

    but beside the point.

    The point is simple... there is no simple way to change a sprite blend mode. Got it. Gotta learn :

    Sprite is not a sprite, it's a quad with a material, pretending to be a Sprite.

    There has been no further abstraction done, despite the huge push of Unity for 2D.

    Materials are 3D materials, with textures and shaders.

    Shaders are a nightmare.... no way for someone to find the ideal, or know if they are using the best or most optimal one for a simple Sprite blend... because there's no organisation of the millions and billions of tutorials.
     
  10. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    23,598
    Well, all sprites in the last 20 years haven't been sprites but meshes, in all engines. Because There is no longer any dedicated 2D hardware left.

    In the Unity case, a sprite isn't guaranteed to be a quad. It can be tight fitting geometry to save on fill rate, so calling it a sprite in the modern sense is absolutely correct!

    Materials are merely a Unity concept of gathering up a package of a shader plus the relevant inputs for that shader to render. These details are processed by the engine and become gpu instructions with data to draw the mesh (be it a sprite or quad). This is also correct and typical for most engines.
    Yes they are. But if you want to try out the shader graph and learn more you can do so here: https://blogs.unity3d.com/2018/02/2...raph-build-your-shaders-with-a-visual-editor/

    For over a decade, Unity has tried to find a sweet spot between abstraction and obfuscation - it's an age-old battle but I think having a couple of easy to understand steps and less mystery is much more beneficial for something like Unity as it gives you more options and power as a developer.

    Unity isn't suitable for complete beginners IMHO, unlike something like Game Maker which will completely hide how things work and what is actually going on. So you will have to do some learning and accept some compromises in how things work.

    Nobody's perfect, least of all me or Unity.
     
    rakkarage likes this.
  11. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    still missing the point.

    Imagine an Enum in the Sprite Renderer, right beneath Material (when set to a standard Sprite Material):

    upload_2018-6-4_1-38-9.png


    Just the four basic types:

    Normal
    Additive
    Multiply
    Screen

    Probably should be there, after those decades you're talking about.

    I'm not sure which is most odd, that it's not there, or your attempts at justification and rationalisation of it not being there.
     
    rakkarage likes this.
  12. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    660
    https://unity3d.com/get-unity/download/archive
    can get official built in shaders here


    2018-04-06.png

    copy sprite shader and replace blend mode with whatever u need here is my 'additive' shader using
    Blend SrcAlpha One

    there may (should) be an easier way?

    Code (CSharp):
    1. Shader "Custom/Additive"
    2. {
    3.     Properties
    4.     {
    5.         [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
    6.         _Color ("Tint", Color) = (1,1,1,1)
    7.         [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
    8.     }
    9.  
    10.     SubShader
    11.     {
    12.         Tags
    13.         {
    14.             "Queue"="Transparent"
    15.             "IgnoreProjector"="True"
    16.             "RenderType"="Transparent"
    17.             "PreviewType"="Plane"
    18.             "CanUseSpriteAtlas"="True"
    19.         }
    20.  
    21.         Cull Off
    22.         Lighting Off
    23.         ZWrite Off
    24.         Fog { Mode Off }
    25.         Blend SrcAlpha One
    26.  
    27.         Pass
    28.         {
    29.         CGPROGRAM
    30.             #pragma vertex vert
    31.             #pragma fragment frag
    32.             #pragma multi_compile DUMMY PIXELSNAP_ON
    33.             #include "UnityCG.cginc"
    34.        
    35.             struct appdata_t
    36.             {
    37.                 float4 vertex   : POSITION;
    38.                 float4 color    : COLOR;
    39.                 float2 texcoord : TEXCOORD0;
    40.             };
    41.  
    42.             struct v2f
    43.             {
    44.                 float4 vertex   : SV_POSITION;
    45.                 fixed4 color    : COLOR;
    46.                 half2 texcoord  : TEXCOORD0;
    47.             };
    48.        
    49.             fixed4 _Color;
    50.  
    51.             v2f vert(appdata_t IN)
    52.             {
    53.                 v2f OUT;
    54.                 OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
    55.                 OUT.texcoord = IN.texcoord;
    56.                 OUT.color = IN.color * _Color;
    57.                 #ifdef PIXELSNAP_ON
    58.                 OUT.vertex = UnityPixelSnap (OUT.vertex);
    59.                 #endif
    60.  
    61.                 return OUT;
    62.             }
    63.  
    64.             sampler2D _MainTex;
    65.  
    66.             fixed4 frag(v2f IN) : SV_Target
    67.             {
    68.                 fixed4 c = tex2D(_MainTex, IN.texcoord) * IN.color;
    69.                 c.rgb *= c.a;
    70.                 return c;
    71.             }
    72.         ENDCG
    73.         }
    74.     }
    75. }
    76.  
     
    Deeeds likes this.
  13. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    23,598
    Personally I am just proud of my patience in the face of hostility and rudeness :) It appears you are successful in getting people to code things for you though so good luck with the future.
     
  14. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    Mirror, Mirror.
     
  15. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739

    THANK YOU!!!

    I'll try out figuring out all the inanities of the steps, and let you know how I go.

    And, yes, agreed. There should be a better, easier, funner, more dynamic and responsive manner to do this, instantly.
     
  16. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    Sorry if this is a super stupid question.

    These are "Standard Shaders"... to download.

    If they're standard, why aren't they in the install package, already?

    Why do I have to download them separately, and install them myself?

    And, this is probably super uber stupid, where/how do I install them, and why has Unity been working before this, without me having ever installed these before?
     
  17. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    660
    They are included and usable but compiled and not editable or human readable afaik
     
    Deeeds likes this.
  18. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    thank you!!!!


    this explains all!!!!


    cheers!
     
    rakkarage likes this.
  19. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739

    I've created a sprite.

    Then added this code to it, as a shader. And the sprite has disappeared.

    What could I be doing wrong?
     
  20. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    660
    You need to modify the sprites shader for your version not the one I posted... How u know it from your version?
     
  21. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    I don't get this stuff, at all.

    Don't know what version, of what, you're talking about.

    And I came across some weird material bug that was further making my experience sucky.

    https://issuetracker.unity3d.com/is...rom-particles-slash-standard-surface-or-unlit

    This was completely throwing me for a curve. Didn't know what was going on. Presumed it was me making mistakes... turns out...no... Unity. Again.

    There should be popups happening in the Editor UI: "You've hit a known bug... here's the link, we're planning to fix it... don't know when."

    I'm using an additive Particle Shader, now, which required jumping through hoops, too, to get working. And has no alpha handling. Need black background on textures instead of using alpha.

    Just boggled that it's all this primitive and requires so much effort and consideration to switch to an additive blend mode.
     
  22. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    660
     
  23. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    That doesn't make it simpler. Elegant. Or remotely user friendly.
     
  24. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    I download these, then what? I install them, Unity then takes forever to compile them... then what? Where does one begin within this?
     
  25. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    660
    not saying it is friendly or simple... just trying to explain how i did it. don't need to install them or compile them just copy an edit one (change blend and name) text file from it and copy that to your project...

    now you have a new shader you can use standard sprite shader or the modified blend mode shader you copied

    you just have to get the right shader for the version you are using because it changes a lot....

    yes it sucks that you cannot just change blend mode without performing this crazy quest but

     
  26. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739

    Slowly, in baby steps, because I'm stupid, and cannot get this to work:

    1. Import a texture.
    2. Convert it to a 2D/Sprite // now a sprite, material, with a default shader.
    3. Now what, EXACTLY do I do to not lose the image

    Everything I do, from this point on, makes the texture representation disappear.

    Just like this: https://issuetracker.unity3d.com/is...rom-particles-slash-standard-surface-or-unlit
     
  27. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    660
    2018-06-15 (1).png

    it works in latest 2018.2

    create shader
    1. download right version of built in shaders
    2. locate the Sprites-Default.shader file within this downloaded archive
    3. copy and rename the file to Sprites-Additive.shader into your project
    4 edit the shader using a text editor like vscode
    - change name (first or second line) to something like Sprites/Additive
    - change the blend to Blend SrcAlpha One if you want additive or whatever

    use shader
    1. create a mat
    2. drag shader to mat
    3. drag mat to sprite
     
    Last edited: Jun 16, 2018
  28. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    660
    ya maybe that is just a bug with that version idk worked in 4.4 and 4.6 and 2018
     
    Last edited: Jun 16, 2018
  29. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    I'm using the latest 2018.1, will try with the newer beta... THANK YOU!!!

    @rakkarage