So for some reason, when I have any shaders in a project on my computer and I try to make a build, the Shader Compiler crashes (multiple instances of them for some reason) and eventually will BSOD my computer. I tried testing this on another computer, but it compiles just fine.
I have tried this with Unity 2017.1.0p4 and 2017.1.1f1. The computers both have GTX 1080s. They’re both running off SSDs. The computer crashing has Unity on an NVMe and the project on an SSD, while the computer that works fine just has one large SSD for everything. They are both Intel processors, but this computer is running an i7-6700k, while the other is running an i7-7820x.
I even made a simple project with just one of the assets and its textures. Then I imported Lux Free (Lux – Physically Based Shader Framework | VFX Shaders | Unity Asset Store). And it will crash on this computer when trying to make a build. I’ve had this happen with other shaders as well. I never had this issue with versions of Unity before 2017.
Does anybody know what could be going wrong? I would put in a bug report through Unity, but considering it works fine on my other computer, I doubt it would help.
Thanks
Like I said, I don’t think a bug report will help. It seems to work fine on other computers. I also recently clean installed Windows on this computer too. The problem occurred before and after.
I wonder if it’s a hardware thing with 2017? There was another thread where a guy also had an i7-6700 and 32GB of RAM. His issue was what mine used to do. And would eventually crash. Now mine just crashes sooner than it used to.
Are the shaders capable of instancing? I know that using more instanced variables than will fit in the buffer will cause shader compiler crashes. Fixing the instance count inside the shader stopped the compiler crashes for me.
It says it in the docs for the old versions of Unity, but this useful info was removed from later versions’ docs:
In short, try changing the UNITY_MAX_INSTANCE_COUNT to something smaller, if it’s an instanced shader issue. That stopped the shader compiler crashes for me.
You can also just create a new empty project. Import each shader one by one, and do a build, with a material for that shader, exactly the way you’re going to use it in your real project, and apply it onto a simple mesh. Look at the console logs. See if the shader compiler crashes for that shader. If not, then import the next shader and continue the process until you find the shader(s) that are causing the crash. Fix the shaders that cause the crash.
Oh nevermind my previous answer - I see that your issue is more of a “works on one computer but not the other” issue. What about starting a new project and creating a new surface shader?
Project tab > Create > Shader > Standard Surface Shader. (Just the default one that it creates for you).
Put it on a material and drop it onto a sphere.
Try the same thing on both machines. Is there a shader compiler crash?
Also, something to keep in mind is that Assets on the Asset Store might have different files used for different versions of Unity, even for the same version number of the asset on the Asset Store.
So I tried this, and it didn’t crash using a standard surface shader. Nor with one of the shaders I made. So I’m guessing it’s a shader in one of my projects? I tested in an empty project using the Lux Shader on the asset store for free, and that one crashed. My other projects are a bit too large for me to test one by one. But it’s still strange that it compiles fine on a different computer
Is there a way to check what my Editor was doing the last time the shader compiler crashed? (I have to force quit Unity via task manager as soon as it happens, or my computer will BSOD)
This helped me. I had misread the docs and was trying to increase the count to fit more vars in instead of reducing. Also, it appears as though space is used up in 16 byte chunks. So a float4 will use up one chunk of 16 bytes but two floats will use up two chunks of 16 bytes.
Interesting. Did you ever resolve this? I’m getting the same issue during shader compilation, and I’m also on an i7-6700k with 32GB. And like you, it BSODs my machine, rather than just crashing Unity.
By chance, I’m taking delivery of a new i7-8700k machine tomorrow, so it’ll be interesting to see if the issue still occurs there.
Well, I’ve built our project several times on the new machine now without any issues.
First time I’ve seen a Unity issue fixed by a hardware upgrade. It’s really interesting because in benchmarks, the 6700K and 8700K are pretty much identical (unless you’re actually taking advantage of the two extra cores).
The fix is more likely related to the reinstallation of Windows 10 on the new machine. Anyway, good news.