0

I'm trying to send some vectors from vertex shader to fragment shader: ex:

vec3 N = (view*model*vNormal).xyz

and when trying to reach it in fragment shader:

Link errorERROR: Input of fragment shader 'N' not written by vertex shader

any ideas?

mjanisz1
  • 1,478
  • 3
  • 17
  • 43

1 Answers1

3

To pass values between shader stages you must use so called varyings; the keywords are varying or out and in – there was a keyword change between GLSL 1.20 to 1.40 but the basic gist that you need special type qualifiers. See http://www.opengl.org/wiki/GLSL_Type_Qualifiers#Shader_stage_inputs_and_outputs for the details.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • ofc in vector shader I use `out vec3 N` and in fs `in vec3 N` but it doesnt help – mjanisz1 Dec 04 '12 at 23:55
  • @mjanisz1: You said your code was `vec3 N = ...`. In this code, `N` is a *local* variable. You need to declare shader stage inputs/outputs *globally*. – Nicol Bolas Dec 05 '12 at 00:05