- Home /
Shader not working in Stand-Alone build, but works in Editor.
Stats: Unity 2.6 Windows Editor/Building
So, I've done some sniffing around, and I don't think anyone else seems to have this issue;
A shader I'm using (REPostProcessor/DreamBlurEffect) to blur the screen works perfectly fine in the Editor, I see it, I have access to it, etc.
But, when I make a full build and play it externally, the blur effect doesn't work. Is it possible for a shader only to work JUST in the Editor, and not work at all in a fully compiled game? The shader is there, I still have access to everything, so it's still tangible. It's effects are just not seen, is all.
I had a similar problem for materials I was creating in code -- since I didn't have a reference to the shader in my scene, the shader had to be in the Resources folder or else it's not included in the build.
This is also a great idea to check. A common mistake is to forget to put required files into the Resources folder. ($$anonymous$$y shader was attached to a Camera, so it was ok.), Regardless, I moved my shader to my Resources folder and re-compiled again. Still, the shader wasn't working. $$anonymous$$ind of a shame...
Answer by CinnaMint · Feb 18, 2011 at 11:11 PM
Ok, so I decided to give up on this.
I ended up upgrading my project to Unity3, and the Shader I was using ended up not being compatible in Unity 3, so I just abandoned that Shader altogether, and created a new one (With a Node based shader editor).
Never did figure it out, but when you can't figure things out, sometimes its best to move ahead with something else.
I've had an error similar to yours, where a shader works in the editor but crashes when attempting to create a new material with it in the web or desktop player. I've also had issues with post effects (i.e. blur+bloom) working in the editor and not in the players.
I believe at least the shader issue could be due to an error I saw once when compiling and haven't been able to duplicate. Unity gave an error saying something like 'Unity has run out of shader keywords. Ignoring [name]'. If there are issues with the keyword namespace, that would explain why some shaders simply crash (silently).
Answer by AndySum · Jan 12, 2014 at 04:28 AM
I had a lot of problems with some screenshaders not working, but I managed to fix it after a combination of problems. My shaders would work in the editor but when I built the standalone game they didn't appear at first, and then once I'd "fixed" that problem my screen was black.
Firstly, if your shader doesn't appear at all when you build the game, it might be because Unity can't find it. This will happen if you use Shader.Find() to locate your shaders. Put your shaders in the Assets/Resources folder to force them to be included. Alternatively modify your script with a reference to the shader itself instead of getting it with Shader.Find().
Next, if your screen is coming up black or otherwise not working, it may be because you're trying to blit a material directly which for some reason simply doesn't work. The solution I found in this thread: http://answers.unity3d.com/questions/275630/graphicsblit-with-custom-shader-gives-black-screen.html
As a workaround, you simply need to render your effect to an intermediate buffer and then Blit to the destination without a material. It only takes a couple of extra lines.
I hope this helps anyone looking at this problem in the future!
(Using Unity 4.3.1f1)
I had a similar problem with my screen shader using Unity 5.5.0f3. I was using Shader.Find, and putting the shader in Assets/Resources as suggested fixed my problem. Thank you.
Answer by DaveA · Feb 01, 2011 at 11:44 PM
Check your quality settings. Is the default worse than what the Editor has set? What if you change your quality settings on stand-alone-startup?
That was a very good suggestion actually! I did check all the settings, they were all set at "Good". So, for the sake of chance, I beefed up the Standalone quality to "Fantastic", still no-go. Thought maybe it was something to do with the fact I build my StandAlone through an Editor Code, but that wasn't it either. I'm going to check out Yoyo's comment. But thank you for the suggestion! It might help future people.
Thank you so much! It fixed my problem, I was already about to get insane because of that problem thanks!
Answer by Mark-Davis · Oct 12, 2011 at 07:03 PM
Just found an answer to this! I had the same problem where an unreleased Voxelform shader would work in the editor, but not when running from the player.
Source of the problem:
Properties {
_WallDiffuse ("Wall Diffuse", 2D) = "white" {}
_WallNormal ("Wall Normal", 2D) = "white" {}
_WallSpecular ("Wall Specular", 2D) = "white" {}
_FloorDiffuse ("Floor Diffuse", 2D) = "white" {}
_FloorNormal ("Floor Normal", 2D) = "white" {}
_FloorSpecular ("Floor Specular", 2D) = "white" {}
_NormalPower ("Normal Power", Float) = 1
_SpecularPower ("Specular Power", Float) = 1
_TriplanarFrequency ("Triplanar Frequency", Float) = .2
_NoiseScale ("Noise Scale", Float) = 1.0
_NoiseVal1 ("Noise Value 1", Float) = 1257787.0
_NoiseVal2 ("Noise Value 2", Float) = 233.0
}
The offending line is: _NoiseVal1 ("Noise Value 1", Float) = 1257787.0
Strangely, changing 1257787.0
to a smaller value such as 125778.0
fixes the problem. It also doesn't matter whether this property is even being used. So the cause wasn't somewhere else in the code. Wonder what's going on here? I'm guessing this won't fix everyone's problem, but at least we know there are some quirky differences between the editor and player.
Had the same issue. Apparently very low values also cause issues (i.e. 0.0001).
I had a property with range(0.00001... that caused this problem. $$anonymous$$y editor is 64bit but build was 32bit. I wonder if that matters?
Answer by Exsanguinatus · Sep 07, 2011 at 04:43 PM
Actually, I'd try turning of the Anti-Aliasing. Someone where I work discovered that the shader I was having troubles with works if you lower the quality settings on the build, so I went through the settings, one by one, changing them from their defaults on 'Beautiful' quality to those on 'Good' quality, and the one that made the shader work was turning off AA. There's still issues, as I'm getting tearing on the edges of the polygons that are using the shader, but it's something to start with, at least.
Original Message: I'm also having this problem with Unity 3. Shader works fine in the editor, but not on build. No crashes... it just doesn't render. Render settings on build are identical to the editor, etc., and I can't find any reason for it breaking. I wish someone had a real answer.
Your answer
Follow this Question
Related Questions
Angry Bots 4.0 ground reflection/shader error (Unity 4.1.2f1) 0 Answers
Is it possible to change the shader of collision bodies in editor? 1 Answer
Outline shader being shown only in the material editor 1 Answer
Differences in Depth Buffer inside the editor and outside the editor 1 Answer
Shader Intellisense / Code completion 2 Answers