JuiceTin

I have custom 2D shaders built using the Amplify shader editor (Lit 2D), which work perfectly fine in Editor.

However in builds of the game, these materials are Pink on any Spine object, but work find on other objects.

Any reason this may be happening? I can't seem to find info anywhere.
JuiceTin
  • Mesajlar: 13

Luke

Hello,

I'm sorry to hear you're having trouble with Spine objects in Unity; our Unity expert, Harald is on vacation at the moment.
Is there any way that you could post some screenshots of what's happening?
Luke

Luke
  • Mesajlar: 105

JuiceTin

Sure, here's in editor:


And in build:


Note, the Unity ragdoll uses the same shader, which is a 2D lit sprite, and it works just fine in build.
JuiceTin
  • Mesajlar: 13

Mario

Can younshare the shader code?
Kullanıcı avatarı
Mario

Mario
  • Mesajlar: 2965

JuiceTin

Of course!

Here's one of the shaders in the Amplify Editor (Equipped weapon).
Basically gets an RGB image and changes it's R/G/B colors.



And here is the shader code produced by the Amplify Editor:
https://pastebin.com/LWWRJUtt

Thanks!
JuiceTin
  • Mesajlar: 13

Harald

Sorry for the delay.

How do you assign this material at the skeleton? Did you modify the material asset that is generated upon import of your skeleton data?
Are you using any special delayed loading mechanism, or Asset Bundles or the like?
Is everything working as expected when using e.g. the standard Spine/Skeleton shader instead of the Amplify shader?

Could you perhaps create a minimal Unity project that still shows this issue? You can send it as a zip package to contact@esotericsoftware.com (briefly mentioning this forum URL so that we know the context), then we can have a look at it.
Kullanıcı avatarı
Harald

Harri
  • Mesajlar: 3907

JuiceTin

Harald yazdı:How do you assign this material at the skeleton?
The 4 body part materials are added onto the Atlas, which is then added into the SkeletonData. No other materials are used outside of those.
Harald yazdı:Did you modify the material asset that is generated upon import of your skeleton data?
Nope created the new ones using Amplify.
Harald yazdı:Are you using any special delayed loading mechanism, or Asset Bundles or the like?
Nope, and there are none in Graphics>Always Included/Preloaded shaders.
Harald yazdı:Is everything working as expected when using e.g. the standard Spine/Skeleton shader instead of the Amplify shader?
Nope, I just switched the shaders to Spine/Skeleton and they still appear pink.

I will make a stripped down project and send it to that email, thanks!
JuiceTin
  • Mesajlar: 13

Harald

JuiceTin yazdı:Nope, I just switched the shaders to Spine/Skeleton and they still appear pink.
I will make a stripped down project and send it to that email, thanks!
Thanks for the additional info and for sending the reproduction project, we received everything. We will have a look at it and get back to you as soon as we've figured out what's going wrong.

---

The problem seems to be that your Material has no _MainTex property, then a call to material.mainTexture here in MaterialTextureLoader.Load throws an exception.

In general you can see such errors by building your project with settings Development Build and Script Debugging enabled. Then you can see an in-game development console displaying any errors.

To resolve this issue, you could either rename the texture property names in your shaders to the standardized name _MainTex, or perhaps Amplify allows you to declare a texture property as the main texture similar to Shader Lab:
https://docs.unity3d.com/ScriptReference/Material-mainTexture.html
Kullanıcı avatarı
Harald

Harri
  • Mesajlar: 3907

JuiceTin

Hi Herald, unfortunately that can't be the (only) issue, as that shader works everywhere else. It is only pink on spine.
Also, changing the materials to use Spine's default Spine/Skeleton shader still makes them pink.

Basically, any shader on spine always shows up pink, and any shader anywhere always works properly. You can change the materials currently on those spines to use the Spine/Skeleton shader to see what I mean.
JuiceTin
  • Mesajlar: 13

Harald

When I change the shaders of all four materials of the skeletons to Spine/Skeleton no errors apprear and everything is displayed correctly, I don't receive any pink materials. Are you sure you changed all shaders and didn't leave some to your amplify shaders?
Kullanıcı avatarı
Harald

Harri
  • Mesajlar: 3907

JuiceTin

Ah right, I see I need all materials converted for it to work. BUT, Spine/Skeleton does not use 2D lighting.

I can't get any of lighting shaders to work, they all appear pink even after fixing the errors shown in the component.

Can you please show the proper way to get this working with 2D lit sprites? I think that may be the issue.
JuiceTin
  • Mesajlar: 13

Harald

JuiceTin yazdı:Ah right, I see I need all materials converted for it to work. BUT, Spine/Skeleton does not use 2D lighting.
This shader was not intended to be used, it just shows that a shader with the _MainTex property works. It is recommended that you fix your Amplify shader accordingly as described above, if you intended to use it originally.
JuiceTin yazdı:I can't get any of lighting shaders to work, they all appear pink even after fixing the errors shown in the component.
Can you please show the proper way to get this working with 2D lit sprites? I think that may be the issue
Do you mean you don't get your Amplify shader to work after modifying the texture property name to _MainTex? Or do you mean that you don't get any of the lit Spine shaders to work? If you mean the latter, please note that you are using Universal Render Pipeline with a 2D Renderer asset, but I don't see the Spine URP Shaders UPM package installed in the package manager in your project. When using URP, standard pipeline shaders will not work, you need to add the Spine URP shaders package to your project. See here for more info on the Spine URP Shaders.

Before installing this package, please wait for the next soon to be released URP Spine shaders package, as you are using Unity 2021.2 and URP 12.1.2 which causes some known problems with the current Spine URP Shaders package. We will release an updated package later today if everything goes right.

---

Harald yazdı:Before installing this package, please wait for the next soon to be released URP Spine shaders package, as you are using Unity 2021.2 and URP 12.1.2 which causes some known problems with the current Spine URP Shaders package. We will release an updated package later today if everything goes right.
The above bugfix update has just been committed and new Spine URP Shaders UPM 4.0 and 4.1-beta packages are available for download here as usual:
Spine Unity Download: Download
Feel free to download the UPM package now if you want to use Spine URP shaders with Unity 2021.2.
Kullanıcı avatarı
Harald

Harri
  • Mesajlar: 3907

JuiceTin

After a brief break from this, I finally came back and fixed it.

While _MainTex errors are perfectly harmless in game, they were hiding the real errors. Once I added an empty _MainTex texture to each shader, I started seeing errors that the shader requires the original texture to be placed in _MainTex. Fixing that solved the issue completely!

Odd that the _MainTex errors worked in editor, but hid the real errors that broke the build version.

Oh well, all fixed now, thanks Harald!
JuiceTin
  • Mesajlar: 13

Harald

Glad to hear you've figured it out, thanks for letting us know!
Kullanıcı avatarı
Harald

Harri
  • Mesajlar: 3907


Dön Unity