Specular highlights appear flat even though diffuse lighting is smooth

Started by
12 comments, last by Norman Barrows 8 years, 6 months ago

As long as your input vertices' normals are unit vectors, and you limit yourself to certain types of transformation operations in your vertex shader, then you won't notice any difference if you don't normalize in the VS.

Assuming all thevertices on your object are transformed with the exact same matrix, then:

- translation won't have any effect on normals, so you're good there.

- rotation won't change the length of normals, so you're good there.

- (uniform) scaling will change the length of your normals. That should still be ok if you're normalizing in the PS.

Non-uniform scaling (different scale factors in x, y and z), however, will mess things up, as suddenly equal length normals will have different lengths. But non-uniform scaling is going to produce messed up normals anyway, even if you re-normalize in the VS.

Advertisement
That way you can remove a normalization call each time you run the VS. If it's worthwhile depends on how much you have to do to keep them normalized in the vertexbuffer/ source data

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

As long as your input vertices' normals are unit vectors, and you limit yourself to certain types of transformation operations in your vertex shader, then you won't notice any difference if you don't normalize in the VS.

Assuming all thevertices on your object are transformed with the exact same matrix, then:

- translation won't have any effect on normals, so you're good there.

- rotation won't change the length of normals, so you're good there.

- (uniform) scaling will change the length of your normals. That should still be ok if you're normalizing in the PS.

Non-uniform scaling (different scale factors in x, y and z), however, will mess things up, as suddenly equal length normals will have different lengths. But non-uniform scaling is going to produce messed up normals anyway, even if you re-normalize in the VS.

That way you can remove a normalization call each time you run the VS. If it's worthwhile depends on how much you have to do to keep them normalized in the vertexbuffer/ source data

Got it. Thank you.

think of it this way:

a normal is (by definition) a unit vector.

an operation that changes the length causes a normal to become "just a vector in the desired direction with some magnitude that is not 1" (as i recall).

therefore, any operation that changes the length of the normal will require you to re-normalize before you use the normal again.

so when you perform an operation on a normal, ask yourself, "does this change the length?" if so, remember that its now an "un-normalized" normal, and you must "re-normalize" it before using it again.

keeping track of "un-normalized" normals is all part of crossing your i's and dotting your t's when doing 3d graphics.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement