1
\$\begingroup\$

I'd like to write multiple values (not just the color and depth value) in one pass to avoid redundancy in vertex shader. Therefore, i attach multiple (let's say two) color buffers (e.g. textures) to a frame buffer object. As i read, GLES 3.0 supports GLSL 3.0 which supports layout( location = # ) qualifiers. However, the shaders do not compile with the error message "Typename expected, found 'layout'\n"

Simple fragment shader example:

uniform sampler2D uTexture;
varying vec3 vNormal;
layout( location = 0 ) out vec4 color;
layout( location = 1 ) out vec3 normal;
void main() {
    color = texture2D( uTexture, vTexture );
    normal = normalize( vNormal );
}

I would expect color going to GL_COLOR_ATTACHMENT0 and normal going to GL_COLOR_ATTACHMENT1. So, is there a way to avoid multiple passes in GLES 3.0?

\$\endgroup\$
0
\$\begingroup\$

OK, the answer is easy: the line

#version 300 es

has to be put on top, otherwise it will be interpreted as GLES 2.0 code. Furthermore, varying is obsolete and has to be exchanged by in and texture2D is covered by texture.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.