I started learning open gl and graphics programming for a while (im using open tk as im working on c#) so i finally came across lighting where you make the ambient diffusion. Im pretty sure that you need to find the dot product between the direction between the light and the fragment position with the normal. But after a while i was puzzled on how to find the fragment position. If you look at the vertex shader here:
out vec3 FragPos;
out vec3 Normal;
void main()
{
gl_Position = projection * view * model * vec4(aPos, 1.0);
FragPos = vec3(model * vec4(aPos, 1.0));
Normal = aNormal;
}
(The code is from learnOpengl) it sets the fragpos to the vec3 of each vertex position and pass it to the fragment shader. I mean fragments are the parts where it shows the objects colour right? how could vertex position could be each fragment position. I don't know if i have misunderstood things completely but after a few words in the opengl website it says
"This in variable will be interpolated from the 3 world position vectors of the triangle to form the FragPos vector that is the per-fragment world position. Now that all the required variables are set we can start the lighting calculations." i dont get this phrase.
Also this is my first time posting here so please point out any mistakes if i did any.
FragPos
from three vertices of a triangle will be interpolated to produce the coords for each fragment. Is there a specific part you don't understand about that quote, or a specific word? Do you understand what's "interpolation"? \$\endgroup\$