Now that ‘varying’ is depreciated, trying to move my code to the new standard of ‘in’ and ‘out’. I can get the new in syntax to work just fine, but any time I touch the ‘out’ qualifier my shader fails to compile.
Lets say I have two shaders, vertex and fragment:
VERTEX SHADER
out float TestVar;
void main() {
TestVar = 1.0f;
// Set the position of the current vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
FRAGMENT SHADER
in float TestVar;
void main() {
// Set the output color of our current pixel
gl_FragColor = Somecolor;
}
Am I missing something here? Do i need to bind out variables like I do ‘In’ variables? Or somehow allocate space for them, I have a feeling that I’m missing something in the OpenGL to GLSL interface.
Hope this is an easy one for someone here. The old depreciated ‘varying’ qualifier still works perfectly fine.
You’ve got to use GLSL 1.3 or greater to get in/out (e.g. “#version 130”). Turns out with 1.3 though you lose the legacy built-in uniforms/attributes. So your vertex shader becomes:
#version 130
uniform mat4 my_ModelViewProjectionMatrix ;
in vec4 my_Vertex;
out float TestVar;
void main() {
TestVar = 1.0f;
// Set the position of the current vertex
gl_Position = my_ModelViewProjectionMatrix * my_Vertex;
}
Just wanted to say thank you for the feedback from this forum, trying my best to contribute as well, but being new here, well, everything is pretty new.
Anyways, here’s an update of the project. Basically it’s OpenGL 3.2 and GLSL version 150, which means defining your own 3d structural paramters (Quaternions in this case) and how they interact with your custom shaders to get stuff on screen.
My implementation pretty much mimics that of the old client side OpenGL only everything has been moved to Server Side with no dependency on any depreciated functions.
Works perfectly well, working on dynamic lights next, have some ideas that are very non standard. Loving GLSL.
Ah, and another thing, perhaps I haven’t gotten to this yet. (Still working my way through the GLSL book, wish it wasn’t based on 140, later chapters to go)
Can you access the current color of the x y coord of your fragments current draw buffer before you draw over whatever is at that x y screen coord? (I realize that you still enable blending ect in OpenGL 3.2)
Can you access the current color of the x y coord of your fragments current draw buffer before you draw over whatever is at that x y screen coord? (I realize that you still enable blending ect in OpenGL 3.2)
In unextended GL the answer is a resounding no. However, there are a few things hanging around that let you do some things:
GL4 hardware: GL_EXT_shader_image_load_store
This does NOT give you access to the previous fragment value, but rather random read and write access to a GL texture.
GL3 NVIDIA hardware: GL_NV_texture_barrier
This extension lets you, with strong limitations, bind a texture for reading and use that texture at the same time as a render target of an FBO. Read the spec to check it out.
In the mobile space, for NVIDIA Tegra, there is the ability to read the previous value of the fragment: GL_NV_shader_framebuffer_fetch, you’ll need to go to developer.tegra.com and download the pdf’s to read up on it.