OpenGL engine thingie - specular highlights with fragment position in view space (incorrect)

OpenGL engine thingie - specular highlights with fragment position in view space (incorrect)

Channel:
Subscribers:
22
Published on ● Video Link: https://www.youtube.com/watch?v=7J75BdPOkFo



Duration: 0:39
24 views
0


I'm not quite sure if it's entirely correct now. But what I think was wrong before is I was sending the vertex position for the lighting calculations in model space, i.e., I forgot to transform the vertex position to world and view space. I'm gonna have to go look at the OpenGL tutorials to see if that's how they actually do it correctly, but multiplying the vertex position in model space by viewMatrix * modelMatrix did seem to do the trick. Now the specular highlight seems to come from a static light position as actually hardcoded in the fragment shader lmao.

EDIT: This is incorrect. Apparently I shouldn't use view space. No need to multiply by viewMatrix. But there's another error when I only use modelMatrix...