Issue with shaders and WebGL

Hello,

I am having some issues with getting shaders to work in WebGL. I have the following shader code in Unity:

LineRenderer lineRend = point.AddComponent<LineRenderer> ();
lineRend.material = new Material(Shader.Find("Particles/Additive"));

This works fine in the Unity player (editor) with no errors. However, after building the project to WebGL and trying to use it in the webpage, I get the following error:

NullReferenceException
UnityEngine.Material.Internal_CreateWithShader (UnityEngine.Material mono, UnityEngine.Shader shader)
UnityEngine.Material..ctor (UnityEngine.Shader shader)
SceneShape.createTranslationGizmo ()
SceneShape.Start ()

_JS_Log_Dump @ currentbuild.js:9865
_JS_Log_Dump__wrapper @ currentbuild.js:4606287
dynCall_vii @ currentbuild.js:4605440
invoke_vii @ currentbuild.js:14530
__Z40DebugStringToFilePostprocessedStacktracePKcS0_S0_iS0_iiiiPFvRK11CppLogEntryE @ currentbuild.js:1698717
dynCall_viiiiiiiiii @ currentbuild.js:4605328
invoke_viiiiiiiiii @ currentbuild.js:14386
__ZN9Scripting12LogExceptionEP18ScriptingExceptioniRKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE @ currentbuild.js:1597599
dynCall_viii @ currentbuild.js:4605699
invoke_viii @ currentbuild.js:14863
__ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedE21ScriptingMethodIl2CppP15ScriptingObject @ currentbuild.js:157423
7__ZN13MonoBehaviour16DelayedStartCallEP6ObjectPv @ currentbuild.js:157215
6__ZN18DelayedCallManager6UpdateEi @ currentbuild.js:1219937
dynCall_vii @ currentbuild.js:4605440invoke_vii @ currentbuild.js:14530
__Z10PlayerLoopbbP10IHookEvent @ currentbuild.js:1448792
__ZL8mainloopv @ currentbuild.js:2591252dynCall_v @ currentbuild.js:4605713
Runtime.dynCall @ currentbuild.js:277(anonymous function) @ currentbuild.js:10011
Browser.mainLoop.runIter @ currentbuild.js:6046
Browser_mainLoop_runner

I have taken out the shader code and the error dissappears. Does Unity WebGL support shaders?

This is not a WebGL problem. Your standalone app will write the same error in log file because Particles/Additive shader was not compiled in the build.

It happened because the shader was never referenced from anything in a scene. And to fix that you need to manually include this shader by going to Edit > Project Settings > Graphics and adding it into Always Include Shaders list.