[RELEASED] All In 1 Sprite Shader

What a cute game, love it! Thanks for sharing and for the kind words :smile:

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:

https://www.youtube.com/watch?v=e7jyq-MXLEo

https://www.youtube.com/watch?v=uo-oD4NIVO8

1 Like

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.

Thanks for reaching out. I’m really happy to hear that you are enjoying the asset :smile:

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):

https://www.youtube.com/watch?v=aNastuqGBik

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);

Thanks for your answer. I usually do like this for example u have character class.

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

}

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.

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.

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 :slight_smile:

I just wanted to say, THANK YOU SO MUCH for your quick and sweet reply!! The tutorials are great :slight_smile: your asset is the best!

1 Like

Hey, thank you for using it and for the kind feedback. It means a lot! <3

1 Like

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/52751343/unity-shadows-ignoring-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
}

It will only work in Built-in, but it’s a good solution in case someone needs quick shadows :slight_smile:

Does it works with URP 12?

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

1 Like

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.

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)

Hello :slight_smile:

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 ?

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

I’ve the same error on a new blank project with just URP and your asset.
It works with these modification(AllIn1Urp2dRenderer.shader, l1184) :

                // OLD code
                //half3 lightResult = CombinedShapeLightShared(col, mask, i.lightingUV).rgb;

                // FIX URP 12
                SurfaceData2D surfaceData;
                InputData2D inputData;
                surfaceData.albedo = col.rgb;
                surfaceData.alpha = col.a;
                surfaceData.mask = mask;
                inputData.uv = i.uv;
                inputData.lightingUV = i.lightingUV;
                half3 lightResult = CombinedShapeLightShared(surfaceData, inputData).rgb;
                // END FIX

Spine plugin has same and fix it with this :

2 Likes

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

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?

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

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

This solution fixes error, but the rendering of normal maps does not works correctly