GLSL shaders pink in release

Hi all,

I have a GLSL shader (for the terrain) that works fine in Unity Editor (3.5.7f6) but not when I build to standalone windows - I get the pink output telling me it failed.

In the runtime log it says:

Unsupported: Hidden/TerrainEngine/Splatmap/Lightmap-FirstPass
Unsupported: GLSL Test

So I guess that’s why it’s pink…
I stripped down the shader to a bare minimum to rule out precision problems etc., and still get the same problem.
Also tried a separate test shader that doesn’t override the terrain one - same problem :-/
Shader code follows:

Shader "GLSL Test" {

	SubShader {
	
		Pass {
		GLSLPROGRAM

		#ifdef VERTEX

		void main()
		{
			gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;		//? ftransform()
		}

		#endif


		#ifdef FRAGMENT

		void main()
                {
        	        gl_FragColor.g = 1.0;
		}

		#endif

		ENDGLSL
		}
	}
}

How are you making sure that the shader is actually included into the game data builds? Normally Unity includes everything that is explicitly “referenced”. But the terrain (before 4.0 anyway) does not explicitly “use” the shader.

You’ll have to put your terrain shaders into a folder called “Resources” (assets in Resources folders are always included into the builds, no matter if anything is using them or not).

Ah yes forgot to say: the test shader is applied directly to a cube in the scene. The test shader is in the Resources folder, and the terrain replacement shader is in a sub-folder of Resources.

Another wild guess: is the standalone player actually running in OpenGL? Since you wrote GLSL shader manually, that will ever work on OpenGL systems.

Running on Windows 7 pro SP1. System32/opengl32.dll exists.
Tried on laptop (NVidia 8600M GT) and desktop (GTX-560), both gfx card drivers quite recent… stumped! :-/
Might be time to learn the shaderlab stuff eh…

Ed: out of interest tried running it on Android Nexus4: bombs out straight away, logcat reports nothing.

Windows builds won’t run in OpenGL by default. You need to use a command line to force it to run in openGL.

-force-opengl

Ooh that’s embarrassing - thought that only applied to the Editor, and the runtime would work it out!
Sorry folks :o

yeah I wish Unity would add an in editor property to select the api. Its already there now for Dx11, whats the harm in another option to force opengl.

If we add it, then we have to actually do QA on it. And our QA is already spread quite thin.

Right now we do zero testing on OpenGL on Windows, so it’s very much in a “it may or might not work, use at your own risk. it compiles!”