Lee_Jennifer_82

01-23-2016, 11:21 AM

Just a simple question, do we always need to normalize normals? Suppoe, when we calculate normal from triangle, is it mandatory to normalize the normals?

View Full Version : Do we always need to normalize the normals

Lee_Jennifer_82

01-23-2016, 11:21 AM

Just a simple question, do we always need to normalize normals? Suppoe, when we calculate normal from triangle, is it mandatory to normalize the normals?

mhagain

01-23-2016, 01:53 PM

All that normalization does is make a vector be unit length (https://en.wikipedia.org/wiki/Unit_vector). There are certain calculations - such as lighting - that require this for correct results, but other calculations may not. If you know for certain that you're never doing any calculations that require unit length normals, then you don't need to normalize them.

GClements

01-23-2016, 05:48 PM

Just a simple question, do we always need to normalize normals? Suppoe, when we calculate normal from triangle, is it mandatory to normalize the normals?

The fixed-function lighting requires normals to be normals (this can be achieved by enabling GL_RESCALE_NORMAL or GL_NORMALIZE if the normals aren't already normalized).

If you're performing your own lighting calculations, you can choose to divide by the length of the normal rather than actually normalizing:

dot(normalize(v1), v2) = dot(v1/length(v1), v2) = dot(v1,v2)/length(v1)

This may be more efficient (one division rather than three).

The GLSL reflect() and refract() functions require the normal vector to be normalised; refract() requires the incidence vector to be normalized.

If you're calculating normals purely for determining whether a polygon is front- or back-facing with respect to a particular direction vector, the length doesn't matter. Similarly, cube-map lookups aren't affected by the length of the coordinate vector (in fact, normalising via a cube map lookup used to be a common optimisation where accuracy wasn't important, but I'm not sure it's still worthwhile on modern hardware).

The fixed-function lighting requires normals to be normals (this can be achieved by enabling GL_RESCALE_NORMAL or GL_NORMALIZE if the normals aren't already normalized).

If you're performing your own lighting calculations, you can choose to divide by the length of the normal rather than actually normalizing:

dot(normalize(v1), v2) = dot(v1/length(v1), v2) = dot(v1,v2)/length(v1)

This may be more efficient (one division rather than three).

The GLSL reflect() and refract() functions require the normal vector to be normalised; refract() requires the incidence vector to be normalized.

If you're calculating normals purely for determining whether a polygon is front- or back-facing with respect to a particular direction vector, the length doesn't matter. Similarly, cube-map lookups aren't affected by the length of the coordinate vector (in fact, normalising via a cube map lookup used to be a common optimisation where accuracy wasn't important, but I'm not sure it's still worthwhile on modern hardware).

Lee_Jennifer_82

01-24-2016, 01:03 PM

Thanks for the clarification.

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.