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\$

1 Answer 1

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\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.