tags:

views:

267

answers:

2

Why does scaling (uniformly) object down cause object to be lighter in OpenGL ES 1.x?

It would be more sense to be that it would darker because aren't the normals being scaled down also making the object darker? But for some reason the object becomes lighter. When I scale up, the object becomes darker. In my opinion this should be the other way round.

Please do not suggest using GL_NORMALIZE etc. I am just curious why OpenGL implementation works like that.

A: 

It would seem that the normals are not scaling with the object. This would mean the normals for an object at full size would considerably more coverage of an object at a smaller size. This would lead to the angles between the light sources and the normals being exactly the same but on a surface that's much smaller.

Soviut
Hmm hmm.. that would somehow make sense but I do not understand the math behind hit. Ain't the surface normals just multiplied with inverse modelview matrix which has been affected with the scaling.
That I do not know, my understanding of normals comes from 3d animation, not openGL so much. I based my answer on some quick reading I did where normals are often pre-calculated and must be told to follow their respective poly faces/verts/etc. If the normals don't follow (or scale, in your case) with the geometry you'll get dark and light spots.
Soviut
+4  A: 

Simple question, complex answer. This is the relevant extract from the redbook:

Transforming Normals

Normal vectors don't transform in the same way as vertices, or position vectors. Mathematically, it's better to think of normal vectors not as vectors, but as planes perpendicular to those vectors. Then, the transformation rules for normal vectors are described by the transformation rules for perpendicular planes. A homogeneous plane is denoted by the row vector (a , b, c, d), where at least one of a, b, c, or d is nonzero. If q is a nonzero real number, then (a, b, c, d) and (qa, qb, qc, qd) represent the same plane. A point (x, y, z, w)T is on the plane (a, b, c, d) if ax+by+cz+dw = 0. (If w = 1, this is the standard description of a euclidean plane.) In order for (a, b, c, d) to represent a euclidean plane, at least one of a, b, or c must be nonzero. If they're all zero, then (0, 0, 0, d) represents the "plane at infinity," which contains all the "points at infinity."

If p is a homogeneous plane and v is a homogeneous vertex, then the statement "v lies on plane p" is written mathematically as pv = 0, where pv is normal matrix multiplication. If M is a nonsingular vertex transformation (that is, a 4 × 4 matrix that has an inverse M-1), then pv = 0 is equivalent to pM-1Mv = 0, so Mv lies on the plane pM-1. Thus, pM-1 is the image of the plane under the vertex transformation M.

If you like to think of normal vectors as vectors instead of as the planes perpendicular to them, let v and n be vectors such that v is perpendicular to n. Then, nTv = 0. Thus, for an arbitrary nonsingular transformation M, nTM-1Mv = 0, which means that nTM-1 is the transpose of the transformed normal vector. Thus, the transformed normal vector is (M-1)Tn. In other words, normal vectors are transformed by the inverse transpose of the transformation that transforms points. Whew!

In short, positions and normals do not transform the same way. As explained in the previous text, the normal transformation matrix is (M-1)T. Scaling M to sM would result in (M-1)T/s: the smaller the scale factor, the bigger the transformed normal... Here we go!