0

Suppose my vertex shader has a value for each vertex:

in uint v_iFlag;
out uint v_oFlag;

void main{

  ...
  v_oFlag = v_iFlag;
}

My geometry shader get the flag value from the vertex shader:

layout(triangles) in;
in uint v_oFlag[]

void main(){
   ...
}

It seems the v_Flag value in my geometry shader is wrong, but I do not know what the value it has. So, how to get the value of v_oFlag[0], v_oFlag[1], v_oFlag[2] in geometry shader?

lightrek
  • 951
  • 3
  • 14
  • 30
  • It's not clear what you mean by "current value". It's an array; it has several "current values". So what exactly are you trying to do here? – Nicol Bolas Oct 24 '16 at 04:45
  • 1
    Complete, minimal and verifiable example would help seeing what you are doing. You might even solve the problem when you work on the minimal example. – Pauli Nieminen Oct 24 '16 at 08:00
  • 2
    @Spektre: The shaders are executed in the following order: Vertex -> Tessellation Control -> Tessellation Evaluation -> Geometry -> Fragment. – BDL Oct 24 '16 at 09:27
  • @BDL thx ... I did not know that (as I do not use them) but always assumed it was `Tessellation Control -> Tessellation Evaluation -> Geometry -> Vertex -> Fragment` as geometry emits Vertexes ... – Spektre Oct 24 '16 at 10:24
  • https://www.opengl.org/wiki/Rendering_Pipeline_Overview – BDL Oct 24 '16 at 10:28
  • @NicolBolas thx, v_oFlag is set by the v_iFlag for each vertex in the vertex shader. In my program, there are only: vertex, geometry and fragment shaders. I try to get the value of v_oFlag in geometry shader to check if it is right per vertex – lightrek Oct 24 '16 at 12:17
  • @lightrek: You seem to be missing my point. `v_oFlag` in the GS is an array. It has *more than one* value. So which value are you trying to get and what are you trying to do with it? – Nicol Bolas Oct 24 '16 at 12:20
  • @Spektre, I do not have other shaders like Tessellation here. Maybe more general case is: how to debug the variable like `in uint v_oFlag[]` in geometry shader? – lightrek Oct 24 '16 at 12:21
  • @NicolBolas Thanks!, suppose the input is a triangle (3 points) for geometry shader. Then, I would like to check the values of v_oFlag[0], v_oFlag[1] and v_oFlag[2]. – lightrek Oct 24 '16 at 12:25
  • 1
    Random list of ideas: 1) write the values into some buffer, then read the buffer back on the CPU and analyze the data (you can use SSBOs, TF, whatever). 2) use your OpenGL vendor's tools to debug your shader inputs. 3) find some clever mapping of those inputs into colors and draw them in the fragment shader (classical way for debugging normals). – peppe Oct 24 '16 at 13:14

0 Answers0