GLSL 1.0.0 - The problem of using "Variation" in vertex and fragment shaders

I am developing OpenGL ES 2.0.0 and GLSL ES 1.0.0.

I am currently showing a screen square for the screen, and now I'm trying to apply a texture.

I am having problems using changing "in vertex and fragment shaders, getting an error message:

- Failed to compile vertex shader - 0(3) : error C5060: out can't be used with non-varying tex_varying in vec4 texture_coord ; in vec4 position ; out vec2 tex_varying ; uniform mat4 translate ; void main ( ) { gl_Position = translate * position ; tex_varying = texture_coord . xy ; } 

I have read the documentation and cannot understand what I am doing wrong.

Here is the code.

Vertex:

 attribute vec4 position; attribute vec4 texture_coord; varying vec2 tex_varying; uniform mat4 translate; void main() { gl_Position = translate * position; tex_varying = texture_coord.xy; } 

Fragment:

 varying vec2 tex_varying; uniform sampler2D texture; void main() { gl_FragColor = texture2D(texture, tex_varying); } 

RESOLVED: This is a late answer, but I have long decided to solve this problem - in case someone else encounters a problem. It turns out that "tex_varying" is reserved by Nvidia! Just renaming tex_varying solved the problem.

Greetings.

+4
source share
1 answer

The in and out keywords, as you show them, are for GLSL v3 and later. For v1 (what are you trying to use?) You need to replace in with attribute and out with varying in the vertex shader. In the fragment shader, replace in with varying , and you cannot use out - you need to output to gl_FragColor , as you seem to be doing.

So, your 2/3 shaders look as if you correctly translated the GLSL v3 code in the first shader in GLSL v1 and look as if they should work with ES2 / GLSL v1

+4
source

Source: https://habr.com/ru/post/1398063/


All Articles