I am having some problems understanding how lighting works in OpenGL (especially understanding the pre-defined variables. is there a list of them somewhere?). I have been me
ambient = ambient * in_Position ; // HERE IS WHAT I DONT GET!
That makes two of us. I have no idea what it is that you intend to accomplish with this. That will certainly produce a color. But it won't be meaningful in any real way. It certainly doesn't qualify as "lighting".
What does "precision highp float;" does?
Nothing. Not in desktop OpenGL. I really have no idea why someone put that there; the precision highp
stuff is for GL ES compatibility, but version 3.30 shaders are fundamentally incompatible with GL ES 2.0, since ES 2.0 doesn't use in/out
qualifiers and desktop GLSL 3.30 does.
Ok how does interpolation works?
Way too broad to answer here. This is better answered here, which is part of my much larger tutorial series.
How does Opengl know where to stop the interpolation ?
The edge of your triangle.