So I am learning to write shaders in general and also learning the Urho3D way of doing them.
Looking at the shaders that Urho3D already has implemented helps a bit. So I looked at TexturedUnlit.xml and Unlit.glsl and saw that it uses multiple passes in the fragment shader.
During the passes where it is not writing to gl_FragColor it is writing to gl_FragData at a few set positions in the array.
#if defined(PREPASS)
// Fill light pre-pass G-Buffer
gl_FragData[0] = vec4(0.5, 0.5, 0.5, 1.0);
gl_FragData[1] = vec4(EncodeDepth(vWorldPos.w), 0.0);
#elif defined(DEFERRED)
gl_FragData[0] = vec4(GetFog(diffColor.rgb, fogFactor), diffColor.a);
gl_FragData[1] = vec4(0.0, 0.0, 0.0, 0.0);
gl_FragData[2] = vec4(0.5, 0.5, 0.5, 1.0);
gl_FragData[3] = vec4(EncodeDepth(vWorldPos.w), 0.0);
#else
gl_FragColor = vec4(GetFog(diffColor.rgb, fogFactor), diffColor.a);
#endif
So my question is what is gl_FragData being used for? If I take out the other passes the shader seems to work just fine. It does not seem to be read in later passes so I guess it is probably sending data back to urho3d for some purpose. But I am just not sure. Any help would be appreciated. Thanks!