How to code a camouflage (camo) shader?

I am trying to code a shader using the Free version of Unity. I would like the shader to make the surface of my object blend with what is behind it, camouflage in other words. I am trying to follow this tutorial which has the exact camo look I am going for:

Shader Tutorial for Unity 3D

Here is my shader code:

Shader "Custom/Camouflage" {
	
	Properties {
		_Texture ("Main Texture", 2D) = "white" {}
	}
	
	SubShader {
		//Draw ourselves after all opaque geometry
		Tags { "Queue" = "Transparent" }
		
		//Grab the screen behind the object into _GrabTexture, using default values
		GrabPass {}
		
		//Render the object with the texture generated above
		Pass {
			SetTexture [_GrabTexture] { combine texture }
			SetTexture [_GrabTexture] { combine previous +- previous }
			SetTexture [_Texture] { combine previous +- texture }
			SetTexture [_GrabTexture] { combine previous + previous }
		}
	} 
}

Unfortunately though it is not working. Ive applied this shader to a simple sphere gameobject but it turns the “error pink” color. Could someone please let me know what I’m doing wrong. I’m not getting any errors but it just simply doesn’t look the same as in the video tutorial. I’m not sure if it’s because the tutorial is outdated.

was long time ago (with unity4), I don't know if I could explain that well. I added the main script to the answer

1 Answer

1

I may be wrong, but I think that that tutorial is for Unity Pro which is why you are getting the pink material error. One simple solution you could do for Unity Free is to play with the transparency of your clothing materials. A transparent surface will blend into its surroundings quite nicely. It isn’t the best solution but with some adjustment it could work ok for what you want. Remember to mask out any model parts underneath the clothing, otherwise your player will be nude rather than camouflaged!

Thanks for the suggestion, I hadn't tried that yet but I suppose it could work. Marking this as accepted since it's the only suggestion so far.

Thankyou!!