[ad_1]
I began studying open gl and graphics programming for some time (im utilizing open tk as im engaged on c#) so i lastly got here throughout lighting the place you make the ambient diffusion. Im fairly certain that you have to discover the dot product between the course between the sunshine and the fragment place with the conventional. However after some time i used to be puzzled on easy methods to discover the fragment place. In the event you have a look at the vertex shader right here:
out vec3 FragPos;
out vec3 Regular;
void most important()
{
gl_Position = projection * view * mannequin * vec4(aPos, 1.0);
FragPos = vec3(mannequin * vec4(aPos, 1.0));
Regular = aNormal;
}
(The code is from learnOpengl) it units the fragpos to the vec3 of every vertex place and go it to the fragment shader. I imply fragments are the elements the place it exhibits the objects color proper? how may vertex place might be every fragment place. I do not know if i’ve misunderstood issues utterly however after a couple of phrases within the opengl web site it says
“This in variable will probably be interpolated from the three world place vectors of the triangle to kind the FragPos vector that’s the per-fragment world place. Now that each one the required variables are set we are able to begin the lighting calculations.” i dont get this phrase.
Additionally that is my first time posting right here so please level out any errors if i did any.
[ad_2]