Mising shader UnityStandardAssets.ImageEffects.DepthOfField

I started my project up today to find that suddenly my Depth of Field is broken!
I’ve tried reimporting assets as well as removing and reimporting the ImageEffects assets with no luck.

I’ve started working on multiplayer using UNet which means I haven’t touched anything related to shaders for a while now so I’m not sure what change could have broken this.

Here’s the console output: (I’ve renamed the Main Camera to Camera)

Missing shader in Camera (UnityStandardAssets.ImageEffects.DepthOfField) UnityEngine.Debug:Log(Object) UnityStandardAssets.ImageEffects.PostEffectsBase:CheckShaderAndCreateMaterial(Shader, Material) (at Assets/Standard Assets/Effects/ImageEffects/Scripts/PostEffectsBase.cs:18) UnityStandardAssets.ImageEffects.DepthOfField:CheckResources() (at Assets/Standard Assets/Effects/ImageEffects/Scripts/DepthOfField.cs:58) UnityStandardAssets.ImageEffects.PostEffectsBase:Start() (at Assets/Standard Assets/Effects/ImageEffects/Scripts/PostEffectsBase.cs:88)

I may have fixed it after apply my ‘fix’ below. Renaming DepthOfFieldScatter to DepthOfFieldHdr seemed to fix it. Maybe renaming the file triggered some kind of refresh that has fixed it.

=====================================

I’m still having a problem with this but I’ve found a solution though it’s ‘a bit of a hack’.

In DepthOfField.cs I added a new variable:

	public Shader dofShaderReplace;

I then appended this to the start of CheckResources():

		this.dofHdrShader = this.dofShaderReplace;

I then had to do a quick edit to DepthOfFieldEditor.cs in order to get the new field to show in the editor, I added this var:

	SerializedProperty dofShaderReplace;

And then added this to OnEnable() just before InitializedAnimBools():

		dofShaderReplace = serObj.FindProperty("dofShaderReplace");

And finally I added this to OnInspectorGUI() at the bottom just before serObj.ApplyModifiedProperties():

		EditorGUILayout.PropertyField(dofShaderReplace, new GUIContent(" DOF Shader Replace"));

In the inspector I then drag over DepthOfFieldScatter.shader into the new variable.

Had a similar issue with the Color Correction Curves effect. Every time I tried to enable the component I got the “Missing shader” error message. After reading this, I tried to remove the effect component and add it again, and that did the trick.