icepic1984
05-14-2011, 05:27 AM
Hi!
Im reading the orange book at the moment and i have a
small problem.
To transform incoming vertices to eye-space they suggest
the following method:
in vec4 vertex;
uniform mat4 mvmatrix;
vec4 epos;
vec3 epos3;
void main() {
...
epos = mvmatrix * vertex;
epos3 = (vec3(epos)) / epos.w
}
What does the last line do? My vertices are available in homogeneous
coordinates, but the fourth component is always 1 so i could just
write epos.xyz to get the same result or am i wrong?
Later in the book there are several examples where the author use this
method. But from time to time he divided the transformed vertex by w
and i don't know why.
Can someone help me out?
Im reading the orange book at the moment and i have a
small problem.
To transform incoming vertices to eye-space they suggest
the following method:
in vec4 vertex;
uniform mat4 mvmatrix;
vec4 epos;
vec3 epos3;
void main() {
...
epos = mvmatrix * vertex;
epos3 = (vec3(epos)) / epos.w
}
What does the last line do? My vertices are available in homogeneous
coordinates, but the fourth component is always 1 so i could just
write epos.xyz to get the same result or am i wrong?
Later in the book there are several examples where the author use this
method. But from time to time he divided the transformed vertex by w
and i don't know why.
Can someone help me out?