I am trying to implement the Phong shading model and I am unsure of how to pick a light source. More specifically, I do not understand what the light source should look like. Should it be a vec3? Or maybe a matrix, which I have defined in my Java code? Also, if we suppose that I want the camera to be the light source, what should be different to a different light source, like a point somewhere else in the view world? I would really apreciate an explanation or maybe a guidance of how I should go about solving something like this and not just code.
This is what I have in my vertex shader so far:
#version 330
layout(location=0) in vec3 vertex;
layout(location=1) in vec3 normals;
uniform mat4 viewMatrix;
uniform mat4 projMatrix;
out vec3 vertexColor;
out vec3 pixelCoordinates;
out vec3 normalizedNormals;
void main(){
if (gl_VertexID < 6) {
vertexColor = vec3(1.0, 0.0, 0.0);
} else if (gl_VertexID < 12) {
vertexColor = vec3(0.0, 1.0, 0.0);
} else if (gl_VertexID < 18) {
vertexColor = vec3(0.0, 0.0, 1.0);
} else if (gl_VertexID < 24) {
vertexColor = vec3(1.0, 1.0, 0.0);
} else if (gl_VertexID < 30) {
vertexColor = vec3(1.0, 0.0, 1.0);
} else {
vertexColor = vec3(0.0, 1.0, 1.0);
}
pixelCoordinates = vec3(viewMatrix*vec4(vertex,1.0));
normalizedNormals = normalize(mat3(viewMatrix)*normals);
gl_Position = projMatrix*viewMatrix*vec4(vertex, 1.0);
}
and this is how my fragment shader looks like currently:
#version 330
in vec3 vertexColor;
in vec3 pixelCoordinates;
in vec3 normalizedNormals;
out vec3 pixelColor;
void main(){
float il = 1;
float ia = 0.2;
float id ;
vec3 v = normalize(-pixelCoordinates);
}
When I compile I get a black screen, which of course occurs because I am still misssing the ambient light and the final light coming out, for which I need to set a light source.