android - Mulitple Fragment Outputs in GLSL 300 es -
while writing unit tests simple ndk opengl es 3.0 demo, encountered issue in using multiple render targets. consider simple fragment shader 2 outputs, declared in c++11 string literal.
const static std::string multipleoutputsfragment = r"(#version 300 es precision mediump float; layout(location = 0) out vec3 out_color1; layout(location = 1) out vec3 out_color2; void main() { out_color1 = vec3(1.0, 0.0, 0.0); out_color2 = vec3(0.0, 0.0, 1.0); } )";
i have correctly setup fbo 2 color attachments (via glframebuffertexture2d) , glcheckframebufferstatus comes gl_framebuffer_complete. call gldrawbuffers(2, &attachments[0]), attachments vector of gl_color_attachmenti enums. afterwards, compile , link shader, without linking or compile errors (just used simple vertex passthrough irrevelant post).
is there reason why can fragment location out_color1 not out_color2, using following opengles function?
auto location = glgetfragdatalocation(m_programid, name.c_str());
the correct location returned out_color1 of 0, when providing "out_color2" glgetfragdatalocation, function returns -1.
i'm testing on physical device, galaxy s4, android 4.4.4 adreno 320, opengl es 3.0.
if call:
glreadbuffer(color_attachment_1); glreadpixels(*);
can see data write fbo?
Comments
Post a Comment