• Runtimes
  • [Unity] Custom Shaders build problem

Hey!

We're using Spine in our project to animate some elements (characters, trees, etc). It's working great I've always found solutions in this forum or elsewhere before, but this one I can't seem to wrap my head around.

Problem:
We are using some custom shaders (created with Shader Forge) on Spine objects in our game.
They work perfect in the editor but as soon as we make a full .EXE build, all the spin objects using that shader show up as Purple-ish objects.

All "non-spine" objects using the same shader work perfectly. Only Objects animated using Spine don't work, so I know it's not that the shader is not compiled with the build. I tried placing my custom shaders in the "Resources" folder, to no avail.

I'm guessing maybe it as something to do with initialization or something but I figured I'd ask around here as I'm guessing I'm not the only one who had this problem (even though I didn't find anything in the forums).

I'd really apprciate if someone could point me in the right direction !

Thanks a lot!

Related Discussions
...
  • Изменено

Its possible that the scene you're loading doesn't have a reference to the material itself as the materials list is generated at runtime for the spine object.

try attaching the spine material to a cube and loading that scene at runtime - if that works we just gotta make sure the material is included in the build.

Hey Mitch ! Thanks for answering so fast !

I tried the following:

  • Placing a Unity Cube in the scene with the same material > When I run the build, the faulty Spine objects are still broken, but the cube is ok. (I attached a picture)
  • Placing all my shaders with the spine shaders. > No change.
  • Spine objects with Spine basic shaders are OK too. (Spine> Skeleton | Spine > SkeletonLit) work fine.
  • I wrtoe a very simple Lambert / Forward / with diffuse map shader manually (without using shaderForge) and it works, so I'm guessing the problem is between Spine objects and ShaderForge generated shader code.

I'll try isolating "problematic" shader code lines to see if I can fix the problem. 😐

Thanks a lot for your time!

Mmm ... Can you send me a package with the shader and spine data?

<removed>


_MainTex ("Diffuse", 2D) = "white" {}

Fixed. See email for details/rage.

TL;DR
Unity is broken. All shaders must have something that resolves with Material.mainTexture (ie: _MainTex instead of _Diffuse)

5 дней спустя

For anyone with the same issue:

The problem was indeed what Mitch pointed out.

For anyone using shader forge, make sure you name the texture going to the Diffuse node as "MainTex".
Or you can edit your shader afterwards as Mitch suggested.