I've got a shader that I'm using to merge a color texture and depth texture with my MonoGame rendered data. It's working fine in my UWP build, but it is failing in my Android build.
The MonoGame pipeline compiles my HLSL just fine, but it fails at runtime when GL.CompileShader call in Shader.OpenGL.cs with this error:
ERROR: 0:18: 'gl_FragDepth' : undeclared identifier
The compiled shader looks like this:
precision mediump float;
precision mediump int;
uniform sampler2D ps_s0;
uniform sampler2D ps_s2;
varying vec4 vTexCoord0;
#define ps_v0 vTexCoord0
#define ps_oC0 gl_FragColor
#define ps_oDepth gl_FragDepth
ps_oC0 = texture2D(ps_s0, ps_v0.xy);
ps_r0 = texture2D(ps_s2, ps_v0.xy);
ps_oDepth = ps_r0.x;
I've tried on a couple of devices, both of which are using OpenGL ES 3.2 as verified by this output:
V/AndroidGameView(20506): Created GLES 3.2 Context
As far as I can tell, gl_FragDepth should be supported. And this is happening during the fragment shader as I get no error about using the gl_FragColor command.
If I don't modify the depth and just set the color (so the shader does include gl_FragColor) then it compiles and works just fine.
So it seems to specifically be the depth.
Everything I read says this should work. Any ideas?