Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] All In 1 Sprite Shader

Discussion in 'Assets and Asset Store' started by GeriB, Nov 12, 2019.

  1. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
  2. therewillbebrad

    therewillbebrad

    Joined:
    Mar 2, 2018
    Posts:
    151
    Have you tested this out in VR? Looks really cool!
     
  3. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Sorry for the late response.
    I haven't tested it with VR since I don't own any VR headset. But if you are worried about performance the shader works great on low end mobile devices.
     
  4. Susihiisi

    Susihiisi

    Joined:
    Jan 11, 2018
    Posts:
    32
    Meow, does this asset work with multi-part characters? Like if character and weapon are diffirent sprites? Does outlines and such effects show on the character as whole or separately on every part?
     
  5. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    The assets treats each part as individual parts (since they are individual sprites). Most of the color based effects will look good on multiple sprite setups. And for outlines you can duplicate the sprites and apply the outline to the sprite in the back. There's an example of that in the WebGl Demo
     
  6. FrankyDess

    FrankyDess

    Joined:
    May 14, 2013
    Posts:
    1
    The asset can't allow cast shadow and receive shadow from light sources in Unity ain't it?
    Is there a way to allow that?
     
  7. Justin_Wingfall

    Justin_Wingfall

    Joined:
    May 15, 2014
    Posts:
    125
    as for the Change 1 color option, is there a way I can change at least 2 or 3 more colors? I tried to add multiple components, but it wont let me. thanks
     
  8. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    Quick Question about the outlines and assigning different colors to those outlines via script...Am i correct in assuming i should just setup a different material for each outline colour and change the material of the sprite renderer from the script during runtime when needed

    that sound about right ? or is there a better method ?
     
  9. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Sorry for the super late reply, as you have noticed I don't really check the Unity forums that much... If you have any questions or need support lease write to the support email. I answers those always in less than a day.

    The next update brings URP 2D Lights support, that may help you out with lighting and shadows. But in general no, shadow casting is not supported.
     
  10. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Sorry for the super late reply, as you have noticed I don't really check the Unity forums that much... If you have any questions or need support lease write to the support email. I answers those always in less than a day.

    The Change 1 Color can only change 1 color, if you need to swap more colors you can use the Color Swap effect. It needs a texture to indicate what zone changes to what color. You have an example of the setup un the Demo Scene, first row, Color Swap.
     
  11. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    As long as you are using sprites the best way of doing it is accesing the Sprite Renderer, caching the Material and then modifying it. The material reference of Sprites Materials aren't the shared global material, instead it's an instanced per object copy. So you can change that and everything will work as expected.

    You'll need to setup a new material manually or at runtime by creating a copy if you are doing the same on UI Images. Unity is limited when it comes to UI rendering. When you get the material reference of a UI Image it always refer to the shared global material.
     
  12. JugglingJoe

    JugglingJoe

    Joined:
    Feb 15, 2020
    Posts:
    4
    Hi, I'm managing to get effects using 2d sprites added to the scene. I am not managing to get effects working when I'm adding them to prefabs in the Project window before I've added them to the scene. What am I doing wrong? Has anybody found this issue and how to get around it? I'm using URP in 2 projects with 2D renderer in one and the normal forward renderer in another. Both have the same issue. Thanks in advance!
     
    unity_jYUSnS-ktFeaUA likes this.
  13. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Hi, sorry to not respond in a shorter time. I never open the Unity forums and I don't get any notification either. In the documentation cover you have my contact email which I always answer within 24h: seasidegamestudios@gmail.com

    That being said to use the asset material in a prefab you need to Save Material To Folder. The material needs to be saved as a file within the project.

    You can read more about it in the Documentation included in the asset, Saving Prefabs section.

    And you can see a short videotutorial giving a quick overview of all the main features of the asset here (also linked in the Documentation):


    Best,
    Gerard
     
    unity_jYUSnS-ktFeaUA likes this.
  14. JugglingJoe

    JugglingJoe

    Joined:
    Feb 15, 2020
    Posts:
    4
    Excellent, wish I'd seen the link before. This answers my question simply, thank you!
     
  15. Workaround-Games

    Workaround-Games

    Joined:
    Oct 26, 2015
    Posts:
    4
    Hi,
    I'm using your shader together with spine to add the Outline effect when my character goes into stealth mode. But there is something weird happening with the "Only Render Outline" option. I'm using the following code that was suggested in the spine forums (due to how they handle materials):

    Code (CSharp):
    1. block.SetFloat("_OutlineAlpha", 1f);
    2. block.SetFloat("_OnlyOutline", 1f);
    3. Render.SetPropertyBlock(block);
    It works fine for the outline alpha, but does not work for the "only outline"... except if i select the Renderer's gameobject in the inspector during gameplay, then the effect works exactly how i want (only outlines on my character).

    Do you have any clue about what is happening? Thanks in advance!
     
  16. Bromm

    Bromm

    Joined:
    Nov 18, 2014
    Posts:
    18
    Hello. I have an issue. On Unity 2020.2.5 all effects can't be toggled. But I can toggle DepthWrite, change tiling and offset, change lightning properties. Currently trying to figure it out. Any clue on why that may be happening?
     
  17. Bromm

    Bromm

    Joined:
    Nov 18, 2014
    Posts:
    18
    oldKeyWords that is set form targetMat.shaderKeywords has only 4 elements listed

    upload_2021-3-10_13-47-43.png
     
  18. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    To enable the only outline feature you'll need to do:
    material.EnableKeyword("ONLYOUTLINE_ON");

    The property "_OnlyOutline" is used for editor logic only.

    If you have more questions please contact me through the contact email shown in the documentation (seasidegamestudios@gmail.com), I don't know how you reached this forum post but this is by far the worst way to contact me, I respond all email queries in less than 10h most of the time. It may take weeks before I see a post in here.
     
    Last edited: Mar 24, 2021
  19. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    That list only contains the currently enabled effects. Please take a look at the Documentation How to Enable/Disable Effects at Runtime section. It explains how to enable and disable effects and the problems you may encounter if you aren't careful about it. Here's a quick code snippet:
    mat.EnableKeyword("GRADIENT_ON");
    mat.DisableKeyword("GRADIENT_ON");

    If you have more questions please contact me through the contact email shown in the documentation (seasidegamestudios@gmail.com), I don't know how you reached this forum post but this is by far the worst way to contact me, I respond all email queries in less than 10h most of the time. It may take weeks before I see a post in here.
     
    Last edited: Mar 24, 2021
  20. HuldaGnodima

    HuldaGnodima

    Joined:
    Oct 10, 2016
    Posts:
    110
    Hi!

    First of all, omg what a fantastic asset this is. Thank you for making it.
    I was wondering if it's compatible with Unity's newer 2D lighting (experimental)? And if so, how do I enable being Lit on a shader? I'm making use of the system, which is why I'm asking.

    Thanks in advance! Again, what a wonderful asset. Unity should buy it and offer it to all users I think! :D
    Hulda

    (as a bonus I just want to show that I'm using your asset to make magic-rain : D turning out super beautiful!)


     
    Last edited: Apr 20, 2021
  21. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    What a cute game, love it! Thanks for sharing and for the kind words :D

    As the description says, it does support URP 2D Renderer lights, you can see how to setup the project and how to use it in the Documentation (at the very beginning First Steps (Must Read) section ) or in these 2 video tutorials:

     
    HuldaGnodima likes this.
  22. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    194
    Hi was wondering what is the best way to activate and deactivate particular shader effects. For example, if my player is dashing I want to enable the motion blur and disable it after the dashing is finished. How should I do that?

    Thanks for making this amazing asset. Now I don't have to go in shader graph to try and spend a lot of hours to make it myself.
     
    Last edited: May 6, 2021
  23. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Thanks for reaching out. I'm really happy to hear that you are enjoying the asset :D

    I talk about enabling/disabling effects in the "How to Enable/Disable Effects at Runtime" section of the Documentation PDF.

    The main takeaway is that although you can turn off the effect through code the best way of doing it is to have all effects you will use enabled and then just tweaking the values at runtime either with an animation (see tutorial):


    You can also do it with code, take a look at the "Scripting" section of the Documentation for that. But in your case you could do:
    material.SetFloat("_MotionBlurDistance", newBlurDist);
     
  24. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    194
    Thanks for your answer. I usually do like this for example u have character class.

    private BaseCharacter baseCharacter;
    private void Awake()
    {
    baseCharacter = GetComponent<BaseCharacter>();

    }

    private void Die(){

    baseCharacter.enabled=false
    }

    private void Revive(){

    baseCharacter.enabled=true
    }

    how does it work on animated sprites? Since when something moving it's playing the animation and I want to add that VFX while they are animating. Some of my sprites are frame-based. They are single frames, not sprite sheet.

    I was just thinking to enable the script and disable it.
     
  25. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    194
    Hi,
    Is there a way to change the colour of the cloth only but not the entire sprite? Say I want o use it to show that new equipment is being a worn or something.
     
  26. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    You can place your character inside a hierarchy of objects and have more than 1 Animator, 1 for effects and the other one for VFX. You could also have a Animator with multiple layers, but I recommend splitting them up.
    You could also do all VFX stuff by script if you prefer.

    For color swapping specific parts of a sprite you have many options. The most straight forward ones would be Color Swap and Color Change. There's many examples of those effects and many other color swaps on the Demo scene. Please take a look and ask if you have any further questions :)
     
  27. HuldaGnodima

    HuldaGnodima

    Joined:
    Oct 10, 2016
    Posts:
    110
    I just wanted to say, THANK YOU SO MUCH for your quick and sweet reply!! The tutorials are great :) your asset is the best!
     
    GeriB likes this.
  28. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Hey, thank you for using it and for the kind feedback. It means a lot! <3
     
    HuldaGnodima likes this.
  29. gaterooze

    gaterooze

    Joined:
    Jul 17, 2019
    Posts:
    16
    If you're only using Standard pipeline and really need shadow casting with this shader, there is a hacky way to add it in a pinch. BE WARNED this may mess up something else in the AllIn1SpriteShader so I'm not recommending it (and GeriB I'm happy to delete this comment if you'd rather this wasn't done), but if you edit the shader code and add this pass in near the end, the sprite will cast shadows:

    (courtesy https://stackoverflow.com/questions...noring-shaders-transparency-but-only-in-build)

    Pass{
    Name "ShadowCaster"
    Tags { "LightMode" = "ShadowCaster" }

    Fog {Mode Off}
    ZWrite On ZTest Less Cull Off
    Offset 1, 1

    CGPROGRAM

    #pragma vertex vert
    #pragma fragment frag
    #pragma fragmentoption ARB_precision_hint_fastest
    #pragma multi_compile_shadowcaster
    #include "UnityCG.cginc"

    sampler2D _MainTex;

    struct v2f
    {
    V2F_SHADOW_CASTER;
    float2 uv : TEXCOORD1;
    };


    v2f vert(appdata_full v)
    {
    v2f o;
    o.uv = v.texcoord;
    TRANSFER_SHADOW_CASTER(o)

    return o;
    }

    float4 frag(v2f i) : COLOR
    {
    fixed4 c = tex2D(_MainTex, i.uv);
    clip(c.a - 0.9);
    SHADOW_CASTER_FRAGMENT(i)
    }
    ENDCG
    }
     
  30. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    It will only work in Built-in, but it's a good solution in case someone needs quick shadows :)
     
  31. dikar771

    dikar771

    Joined:
    Oct 30, 2015
    Posts:
    19
    Does it works with URP 12?
     
  32. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Yes it does. It works out of the box in all render pipelines in all versions
    And the 2D Renderer Urp lights works on all Urp versions
     
    dikar771 likes this.
  33. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    194
    Hey is there any shader in this to make 2D water reflections and 2D water? Maybe I did not notice but did not find that option.
     
  34. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    No, there are no effects that grab information from the scene in any way. No way of interacting with color, depth, normals or anything else. All effects are self contained and can only be affected by their Material (except URP 2D Renderer shader that gets affected by 2D lights)
     
  35. harusame-

    harusame-

    Joined:
    Nov 18, 2013
    Posts:
    11
    Hello :)

    I updated my project to 2021.2.0f1 (URP 12 with 2d renderer) , and I have 2 shader error :
    "[Worker30] Shader error in 'AllIn1SpriteShader / AllIn1Urp2dRenderer': 'CombinedShapeLightShared': cannot implicitly convert from 'half4' to 'struct SurfaceData2D' at line 1182 (on d3d11)"

    "Shader error in 'AllIn1SpriteShader/AllIn1Urp2dRenderer': Couldn't open include file 'Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl'. at line 248"

    Is it related to my project or allin1shader ?
     
    Last edited: Oct 30, 2021
  36. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    If URP is properly installed and the URP package of the asset is extracted you shouldn't face any errors.
    In case of doubt the steps are explained in the Documentation and YouTube tutorial playlist. If you are still having problems it may means that Unity have changed the implementation of the 2D Renderer, but chances are that you just need a URP project, export the URP package of the asset and assign a 2D Renderer Asset Pipeline to Project Settings
     
  37. harusame-

    harusame-

    Joined:
    Nov 18, 2013
    Posts:
    11
    I've the same error on a new blank project with just URP and your asset.
    It works with these modification(AllIn1Urp2dRenderer.shader, l1184) :
    Code (CSharp):
    1.                
    2.                 // OLD code
    3.                 //half3 lightResult = CombinedShapeLightShared(col, mask, i.lightingUV).rgb;
    4.  
    5.                 // FIX URP 12
    6.                 SurfaceData2D surfaceData;
    7.                 InputData2D inputData;
    8.                 surfaceData.albedo = col.rgb;
    9.                 surfaceData.alpha = col.a;
    10.                 surfaceData.mask = mask;
    11.                 inputData.uv = i.uv;
    12.                 inputData.lightingUV = i.lightingUV;
    13.                 half3 lightResult = CombinedShapeLightShared(surfaceData, inputData).rgb;
    14.                 // END FIX
    15.  
    Spine plugin has same and fix it with this :
    https://github.com/EsotericSoftware/spine-runtimes/commit/dfa52de90d08564d30d292de4e658c8f056b712c
     
    GeriB likes this.
  38. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Thanks for the heads up and for the solution!
    It's really annoying when Unity changes the implementation of their stuff with no chance for back compatibility
     
  39. nattyboyz

    nattyboyz

    Joined:
    Jan 31, 2015
    Posts:
    4
    Hi
    I've been using your shader with Spine character and it show seam between part like this, how could I prevent this from happening?

    upload_2021-11-3_15-37-44.png
     

    Attached Files:

  40. dikar771

    dikar771

    Joined:
    Oct 30, 2015
    Posts:
    19
    This solution fixes error, but the rendering of normal maps does not works correctly
     
    Last edited: Nov 4, 2021
  41. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    I'll need to take a proper look and create a definitive URP 2021 shader variant.
    But this things take time to do properly. Unity just did this change and of course, there is no documentation available and I'll need to reverse engineer their stuff and then adapt it to the asset.

    Please give me a couple weeks to offer a definitive clean solution and on the meantime if the normal issue is a problem please go back to a previous version before Unity decided to ninja update URP
     
    dikar771 likes this.
  42. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    There's probably a premultiply going on. Please contact me on my email and send me the details of the texture and material you are using so that I can offer you a solution: seasidegamestudios@gmail.com
     
  43. nattyboyz

    nattyboyz

    Joined:
    Jan 31, 2015
    Posts:
    4
    I've sent the email to seasidegamestudios@gmail.com, thanks.
     
  44. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Wait, I don't think I've received your email. Have I replied to you?
    The email address is the correct one
     
  45. Zephni

    Zephni

    Joined:
    Apr 23, 2015
    Posts:
    100
    Hey, I have just bought the asset I just have one small question. Is it possible to add the component and apply effects purely through code? I have a base Enemy class and plan on adding an effect once they get hit, so I have done something like this just to test if it works:

    Code (CSharp):
    1. AllIn1Shader allInOneShader = go.AddComponent<AllIn1Shader>();
    2. Material material = go.GetComponent<SpriteRenderer>().material;
    3. material.SetColor("_HitEffectColor", Color.white);
    4. material.SetFloat("_HitEffectBlend", 0.5f);
    On starting the game, when looking in the inspector the enemies have the component, the material and also the correct effect parameters have changed... but I need to manually click the "Hit Effect" check box to apply the effect. So how do I enable the actual effect through code?

    Thank you
     
    Last edited: Nov 28, 2021
  46. Zephni

    Zephni

    Joined:
    Apr 23, 2015
    Posts:
    100
    Ah! I found it. Just incase anyone else has this question you can switch on a materials "Keyword" like so:

    Code (CSharp):
    1. material.EnableKeyword("HITEFFECT_ON");
    Looking in the main AllIn1Shader.cs file from lines 201 - 255 there is a list of available keywords. it's working fine now purely just through code :)
     
  47. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Still no email from you. In case you are waiting me to reply, I won't. I haven't received anything.
     
  48. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    As I told you via email, in case someone sees this, please stay away from doing this is case you don't know exactly what's happening behind the scenes when doing this.
    Read the How to Enable and Disable Effects section of the Documentation for a detailed explanation about why and what to do instead.
     
  49. Antsurkov

    Antsurkov

    Joined:
    Mar 30, 2013
    Posts:
    6
    Hello. Got any update on this problem?
     
    Grafos likes this.
  50. GeriB

    GeriB

    Joined:
    Apr 26, 2017
    Posts:
    192
    Struggling with a new asset I'm wrapping up. Will jump to All In 1 Shader right after (expect to see this solved in the next update coming soonish)