I was looking to add a sprite shadows to my game. I found a few tutorials, for example, this one:
It seems like Unity 6.4 breaks the support of sprite colors in (non-sprite) Lit shader graphs. In prior versions of Unity, I could get the color via Vertex Color in the shader graph. But it does not work in 6.4. I’m specifically on version 6000.4.3f1. Did this get changed to just not work between the Sprite Renderer and non-sprite shader graphs?
Why are you using a non-sprite shader on a sprite renderer? Does it work if you set the shader to Sprite Lit?
I’m unsure as of right now, once I get some time I will try it out. It does fix the color issue, but I don’t know if casting shadows will work. It’s just weird to see something broken and i can’t seem to find any logs indicating this change explicitly.
Sprite Lit does fix the color issue, but prevents shadows from working, so they cannot cast the shadow.
It does look like if you edit the shader, it will temporarily fix the vertex color but then as soon as the shader is saved or the scene runs, the vertex color reverts back to white. So this definitely seems to be broken in 6000.4.3f1.
The issue is probably happening because using a non-sprite shader on a sprite renderer is not intended. For now, you could try adding your own custom color property in the ahader graph and use it instead of vertex color. You’d have to manually set the property’s color, either in the inspector or in code. If set in the inspector you’d need to have a separate material for each different color.
Hi,
you will find more information on using the Sprite Color in Shader Graph in this thread.
You should not have to use a target other than Sprite on Sprite Renderers.
That it worked before was ‘accidental’ and doesn’t now not a ‘regression’ or bug.
With the work done to render 3D as 2D, you should always use Sprite targets on both Sprite and Mesh Renderers when using the 2D Renderer.
Now, I appreciate you’re using the 3D Renderer and want shadows cast from Sprites, and yet get the SpriteColor, so here’s a work around.
Use a Custom Function Node with the following:
#if defined(UNIVERSAL_SHADER_VARIABLES_INCLUDED) && (SHADERPASS != SHADERPASS_SHADOWCASTER)
SpriteColor = unity_SpriteColor;
SpriteProps = unity_SpriteProps;
#else
SpriteColor = float4(1,1,1,1);
SpriteProps = float4(0,0,0,0);
#endif
Hope this helps.