Closed ACalza closed 5 years ago
I also noticed the same issue. However, after messing around with the code, I discovered that if you set the tessellation level to a higher number (eg. 50 instead of 5), the result would be a smooth appearance.
Would the issue be caused by the fact that the stated hard code tessellation level is too low to produce a smooth surface?
Using tesselation level 5 should produce smooth shading. Make sure you are normalizing your vectors if you expect them to be unit length.
The vectors are normizalized. Can we see a screenshot ?
The screenshot(gif) you see in your assignment was made with level 5.
I just noticed that I normalized the normal vector yet I passed in the raw value (d'oh!). Confirmed to have worked at level 5.
I normalized the vector in the tessellation step, but I had to normalize it in the lit.fs file for it to work....Weird....
That's expected. When vectors are normalized in vertex/tesselation shader and then interpolated to generate new vectors in the fragment shader(per-pixel), those new vectors don't necessarily stay unit length. It's one of those gotcha things of shader programming. Rule of thumb is to always normalize vectors in fs if they are suppose to be unit length.
Consider an extreme example: if the normals at your vertices were (1, 0, 0)
, (0, 1, 0)
, and (0, 0, 1)
, what would be the interpolated normal at the centroid?
One might question why OpenGL does not automatically take care of the normalization? And the answer to that question is very simple: OpenGL does not know that your variable is actually a normal vector (or any other direction vector for that matter).
This was asked during office hours (and a few others had a similar issue) and it's in regards to the shading for 'snap to vertices.' The shading as the image depicted below appears to look like Gourand shading, and want to know if this is a common issue, and if it's fine to leave it as is. Gavin had that same issue too lol.