I know how to use both in/out variables, and varying variables. I am fully aware that using the in/out variables is better because it is not deprecated.
It is a very small thing, but I don't really understand why they changed this. Previously I could have the code in one shader, copy and paste it into the other, and it would be fine. Now I have to paste it into the other and change everything to "out" (instead of "in").
It is not that I mind doing this, I am just very curious about whether there is an advantage to the in/out variables, and if there isn't, why did the Khronos group change it.
varying variables contain data shared from a vertex shader to a fragment shader. The variable must be written in the vertex shader and the read-only value in the fragment shader is then interpolated from the vertices which make up the fragment.
in / out for function parameters Functions in GLSL use a calling convention called "value-return." This means that values passed to functions are copied into parameters when the function is called, and outputs are copied out when the function returns.
Originally introduced as an extension to OpenGL 1.4, GLSL was formally included into the OpenGL 2.0 core in 2004 by the OpenGL ARB. It was the first major revision to OpenGL since the creation of OpenGL 1.0 in 1992.
The short version is: OpenGL is an API for rendering graphics, while GLSL (which stands for GL shading language) is a language that gives programmers the ability to modify pipeline shaders. To put it another way, GLSL is a (small) part of the overall OpenGL framework.
This was changed because there were no longer two shader stages. OpenGL 3.2 introduced Geometry Shaders, which are an optional stage between Vertex and Fragment shaders. It takes input from VS's and provides output to FS's.
So... how would you do that when you only have one keyword? You can't copy-and-paste the interface variables from the VS and FS into the same GS. You need some way to designate that a named variable is input from the VS or an output to the FS. And no, you can't just say that a variable is both.
Also, pay attention to the nature of the input variables in the GS. They are arrayed. So you couldn't just copy the VS varying
definitions into the GS; you have to change them anyway.
It should also be noted that along with geometry shaders, they added input/output interface blocks, which group multiple interface variables under one heading. With these, you don't have to change several in
/out
pairs; you just change one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With