opengl - GLSL geometry value changing when it shouldnt -


i'm working simple program passing array of points programable pipline draw cube. i'm trying set can change geometry every frame (based on external input) , such, lighting, need recalculate face normals after have been changed. i'm doing in geometry shader exercise.

my shaders follows:

vertex:

#version 330 core  layout(location = 0) in vec3 vertexposition_modelspace;  uniform mat4 mvp;  void main(){         gl_position =  mvp * vec4(vertexposition_modelspace,1); } 

geometry:

#version 330  precision highp float;  layout (triangles) in; layout (triangle_strip) out; layout (max_vertices = 3) out;  out vec3 normal;  void main(void) {     (int = 0; < gl_in.length(); i++) {         gl_position = gl_in[i].gl_position;         emitvertex();     }      endprimitive();      normal = vec3(0,0,1); } 

fragment:

#version 330  in vec3 normal; out vec4 color;  void main() {     color = vec4(normal,1); } 

i trying calculate normals (but have pulled out code debugging reasons) , normal value freaking out when ran program. set fragment color whatever normal value is. (to see if indeed normal.) whatever reason, value of 'normal' flipping between red,green, white, , black no reason can tell. if specify color vector in fragment shader cube renders fine color everywhere.

why value of normal changing @ all?

thoughts?

the value of normal undefined.

you have write all of geometry shader outputs before each call emitvertex. gs's don't work immediate mode rendering.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -