How to change the fragcoords relative location. (from the window)

Hi!

I want to change the origin lower left to the origin upper left corner like it’s explained in the documentation :
https://www.opengl.org/sdk/docs/man/html/gl_FragCoord.xhtml

But I have an error when I try to compiler the shader :


"#version 330 core 
"
            "layout(origin_upper_left) in vec4 gl_FragCoord;"
            "layout(pixel_center_integer);"
            "layout(location = 0) in vec3 vertex_position;"
            "layout(location = 1) in vec4 vertex_color;"
            "layout(location = 2) in vec2 vertex_texCoords0;"
            "layout(location = 3) in vec3 vertex_normal;"
            "uniform mat4 mvp;"
            "out vec2 texCoords;"
            "out vec4 color;"
            "void main () {"
                "gl_Position = mvp * vec4(vertex_position.xyz, 1);"
                "texCoords = vertex_texCoords0;"
                "color = vertex_color;"
            "}";

It tells me that there is an unespected ; at then end of line 2.

How can I change gl_FragCoord to upper_left_corner ?

PS : (whithout this two lines : )
“layout(origin_upper_left) in vec4 gl_FragCoord;”
“layout(pixel_center_integer);”
it compiles without any problems.

I’ve found the solution, we have just to separate the layout qualifiers by a , :


 "#version 330 core 
"
            "layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord;"
            "uniform sampler2D texture;"
            "uniform sampler2D normalMap;"
            "uniform vec3 resolution;"
            "in vec2 texCoords;"
            "in vec4 color;"
            "out vec4 fragColor;"
            "void main() {"
                "vec2 position = (gl_FragCoord.xy / resolution.xy);"
                "vec4 oldNormal = texture2D(normalMap, position);"
                "vec4 newNormal = texture2D(texture, texCoords);"
                "if ((newNormal.x == 0 && newNormal.y == 0 && newNormal.z == 0) && (oldNormal.x != 0 || oldNormal.y != 0 || oldNormal.z != 0)) {"
                    "fragColor = oldNormal;"
                "} else {"
                    "fragColor = newNormal;"
                "}"
            "}";

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.