• Unity
  • Sprite Shaders for Unity

Related Discussions
...

The inspector looks broken too. Are you importing ToddRivers' unitypackage?
If you're using the latest spine-unity unitypackage, the shader should already be included under Modules.
The shader path looks like `Spine\Sprite\


`

I think if you have both, the cginc files might have code collision problems which may turn the shaders pink.
Is the console empty?

We imported both Spine unitypackage and Todd's unitypackage. Reading the other answers I deleted both, Todd River's and Spine spine-csharp folder and spine-unity, then I closed unity to have a clean console report, and then re-imported only Spine official unity package. The problem persists and this message appeared on console:

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même


28 Nov 2016, 11:44


@MattouBattou solution is working for us, but I don't know why the Spine unitypackage and todd's shader unitypackage doesn't work alone.

Hi, I'm just trying to use the awesome shader package and ran into an issue where nothing would work.

I had an error showing up in the inspector panel for all shaders in Game>Shaders>Sprites saying "undeclared identifier 'unity_ObjectToWorld' d3d11 ShaderShared.cginc:15".

I'm stuck on Unity 5.3.4p6 for target platform reasons. I basically changed the line in ShaderShared.cginc from:

/* line:15 */  return mul(unity_ObjectToWorld, vertex);

to

return mul(_Object2World, vertex);

And everything now works.

Just thought it was worth mentioning for anyone else stuck on this!mentioning for anyone else stuck on this!


28 Nov 2016, 11:48


In our ShaderShared.cginc file we had to edit line 12 though.

Same here, using Todd's latest version:

Unity v5.4.2f2 (building for Android), Win7 Ultimate 64bit

Previous ones didn't trigger any error.

Amazing!!, it's always so nice to have great support. Definitely loving everything related Spine!
Thanks again!

Hey sorry for the late response, yeah I've been on the 5.5 beta so stuck some 5.5 only shader stuff in there by mistake.
5.5 is now out properly so I guess I'll leave it in so the shaders are correct for the latest version of Unity.

I guess most people will be grabbing the shaders via the spine runtimes now anyhow though, don't know what version of Unity they're targeting but might need to change some of the Unity variables to match it 🙂

Hi @ToddRivers,

Great progress as always! And also very much appreciated for all your hard work and continued support on this tool! I hope the Spine guys are compensating your excellent addition, to an already awesome animation tool.... maybe some free licenses or something if you aren't accepting cash ? :party:

I also have a question about normal intensity, maybe I'm doing something wrong? I can't seem to get the same level of "normal" map bump using your tool compared to Unity's normal "Standard" shader. Any idea on what I'm doing wrong? (The left mario is using the Standard Shader, right is your sprite shader)

Thanks again!

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

Pls find the settings below.

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

AlaNintendo a écrit

Hi @ToddRivers,

Great progress as always! And also very much appreciated for all your hard work and continued support on this tool! I hope the Spine guys are compensating your excellent addition, to an already awesome animation tool.... maybe some free licenses or something if you aren't accepting cash ? :party:

I also have a question about normal intensity, maybe I'm doing something wrong? I can't seem to get the same level of "normal" map bump using your tool compared to Unity's normal "Standard" shader. Any idea on what I'm doing wrong? (The left mario is using the Standard Shader, right is your sprite shader)

Thanks again!

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

+1 for normal intensity float multiplier in the shader 😛

@[supprimé]
Does your mesh have tangents?

On top of that, it looks like the Standard shader is adding speculars which ToddRivers' shaders current doesn't do.

Is it possible that the shader (Pixel Lit) not running on mobile? If I use a Spine object its works. When I use a normale sprite it does not render on mobile. This worked weeks ago without any problem. Maybe this shader will not work without Spine object now?

Edit: Maybe something to do with this warning?

Hi!, I wanted to post a bug I think.

Why whenever my Spine character gets near a point light with Pixel Lit shader it looks like this?

Image supprimée en raison de l'absence de support de HTTPS. | Afficher quand même

The normals are set to X= 0, Y = 0, Z = 1 (If I use normals -1 it's not lit), the same with use mesh normals by the way.
If I use Vertex Lit the problem fades away but is not accurate in terms of lighting so I want to use Pixel Lit.
The light is behind the character, if it's in front it doesn't get lit.

Also another question. Why in Vertex Lit mode everything needs to be lit from the front, and in Pixel Lit everything has to be lit from back? I have to manually change normals in the shader to not have to change every light Z position.

1) This is just how pixel lighting in Unity works.
The same thing will happen with any pixel lit shader in Unity that doesn't write to depth and sprites on the same batched pass.

To fix it, write to depth, and add z-spacing.
This will cause other artifacts related to alpha-blended things that write to depth. This is an extensive topic in graphics programming and in any engine.

Again, here, this is just how pixel lighting in Unity works.

2) Normals should be (0, 0, -1). If the light direction acts incorrectly despite using that normals value, that's where the bug is.

@AlaNintendo, yeah like Pharan says what you're seeing is just the specular from the standard shader. The shader doen't support specular (yet!) so a better comparison would be to compare it with the 'Legacy Shaders/Bumped Diffuse' shader which doesn't have specular.
Its something I'll prob add at somepoint, along with a specular map as don't think it makes sense for the whole sprite to be shiny but bits like armour etc would look cool 🙂

@Pharan so NeatWolf pointed out a bug with vertex lighting a while ago which meant he had to set the normal to (0,0,1). I fixed it in my github a while ago but not sure if you guys have kept up to date with the shaders in your runtimes?

@alcyongames As Pharan says pixel lighting will always cause overdraw unless you write to depth. Pixel lighting is split into multiple passes for each light. The only way a pass wont draw on top of a previous one is using a depth test. For that to work you need to write to depth (which means a hard alpha edge).

If you're art style has hard edges anyways that's not a problem, use pixel lighting just turn on write to depth.
If it doesn't (ie you've got faded edges) then use vertex lighting and increase the number of verts used in your spine animation (ie use mesh attachments instead of just quads) to make it more accurate.
With a decent number of verts you'll struggle to notice the difference between vertex and pixel lighting most of the time, and vertex lighting is faster (though increased number of verts is slightly more CPU intensive, vertex lighting is less GPU intensive).

, yeah like Pharan says what you're seeing is just the specular from the standard shader. The shader doen't support specular (yet!) so a better comparison would be to compare it with the 'Legacy Shaders/Bumped Diffuse' shader which doesn't have specular.
Its something I'll prob add at somepoint, along with a specular map as don't think it makes sense for the whole sprite to be shiny but bits like armour etc would look cool 🙂

@ToddRivers @Pharan Ahh that would explain the difference in appearance. 8)

Ok crossing fingers , you or the Spine team can get around adding a specular map option :happy: :happy:

@ToddRivers should be up to date until Nov 24. I think that includes the normals fix.

ToddRivers a écrit

@Pharan so NeatWolf pointed out a bug with vertex lighting a while ago which meant he had to set the normal to (0,0,1). I fixed it in my github a while ago but not sure if you guys have kept up to date with the shaders in your runtimes?

I updated them yesterday as well, but I still have to set them to (0,0,1) for Vertex Lit to work. If I switch to Pixel lit, -1 is ok.
Unity v5.4.2f2

@NeatWolf Yeah me too! "Use Mesh Normals" doesn't work, I have to manually set the normals for Pixel Lit to Z = -1. It works in other things though (I use Todd's Rivers shader in other assets like Ferr2D) and if I use pixel lit with "Use Mesh Normals" It works haha. Well it's not a problem though, I just have to set it up manually that's all.

Hey sorry for the delay. OK had another look at the vertex lighting macro's and think I found a bug! (I was using the view matrix instead of the inverse view matrix). I've checked in a fix to github so might be worth grabbing latest and seeing if it helps.
I also made the material editor work with multiple materials at the same time (i.e. multi-edit).

Another think to look out for is it might be worth trying to 'reset' the material (by clicking on the cog in the top right corner of the material editor) and then reapplying any settings.
Unity materials tend to accumilate loads of flags/defines/values whilst your editing them and switching shaders, which can potentially cause things to break.
I've hopely cleaned up the sprite material editor so it always sets and resets things properly but worth trying too if the fix doesn't help!

was my post ignored? 🙁 or it isn't a problem?

dothem a écrit

Is it possible that the shader (Pixel Lit) not running on mobile? If I use a Spine object its works. When I use a normale sprite it does not render on mobile. This worked weeks ago without any problem. Maybe this shader will not work without Spine object now?

Edit: Maybe something to do with this warning?

ToddRivers a écrit

Hey sorry for the delay. OK had another look at the vertex lighting macro's and think I found a bug! (I was using the view matrix instead of the inverse view matrix). I've checked in a fix to github so might be worth grabbing latest and seeing if it helps.
I also made the material editor work with multiple materials at the same time (i.e. multi-edit).

Another think to look out for is it might be worth trying to 'reset' the material (by clicking on the cog in the top right corner of the material editor) and then reapplying any settings.
Unity materials tend to accumilate loads of flags/defines/values whilst your editing them and switching shaders, which can potentially cause things to break.
I've hopely cleaned up the sprite material editor so it always sets and resets things properly but worth trying too if the fix doesn't help!

I tried to import these latest shaders but I got a compiler error (targeting Android, Unity v5.4.2f2):

Shader error in 'Hidden/Internal-SpriteDepthNormalsTexture': unrecognized identifier 'UNITY_VERTEX_INPUT_INSTANCE_ID' at line 213 (on d3d11)

Compiling Vertex program
Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING

in UnitySpriteShaders-master\SpriteShaders\SpriteDepthNormalsTexture.shader

😢