SetRenderTargets on OpenGL ES devices

Could be possible render to multiple targets for the same pixel shader on ios and android? After set targets with SetRenderTargets and the follow output struct for the pixel shader:

struct DepthNormalPixelShaderOutput
{  
    float4 Depth : COLOR0;
    float4 Normal : COLOR1; 
};

taking a look to the output generated by the compiler tool, it defines (in the xnb):

#define ps_oC0 gl_FragData[0]
#define ps_oC1 gl_FragData[1]

which correspond to the output for the fragment shader, I think… reading the opengl documentation.

On my Mac, it works fine, and I can write to both targets on the same pixel shader (I make this to create a normal map, and a depth map on two separated targets), but on android I get the follow message on runtime: ‘System.InvalidOperationException: Shader Compilation Failed’, and on iOS I don’t get any errors, but the shader does not produces output. Is this a wrong way? Shall I to make two separated shaders for ES devices?

You’d need to set a higher OpenGL ES version and - as far as I remember you’d need to do that in glsl somehow (or add a featureset or something like that) - which is hard to do with MG. I actually gave up on deferred shading, when my targets include android and do such things the traditional way (or separate passes)

I don’t think it’s officially supported on iOS yet, but I added GLES 3 support in this thread and got Multiple Render Targets working on iOS with an HLSL shader. I thought it was supposed to work on Android already, but I haven’t tried.

Yes, I tried some days ago, and it seems to need more work with monogame 3.7 sources. Also it produces an opengl exception before to start to run even the iOS game template by default on visual studio… the opengl errorcode was 26… something, sorry, I can’t rebember the exact error number.

Thank you anyway, finally I made two shaders and does not seems to impact in the performance noticeably :slight_smile:

Should be nice to to find a path to implement OpenGL ES 3.0, stay on ES 2.0 noradays have no sense.