Closed der-antikeks closed 8 years ago
Thanks for the fix @der-antikeks.
You'll want to do one more step in order to have the change apply to the mgl64
package as well, and that is run:
go generate github.com/go-gl/mathgl/mgl32
You can read https://github.com/go-gl/mathgl#contributing for more details.
I have done this a while ago. Still missing something for a merge?
reviewing right now
I'm pretty sure that's right too, but could you link to some trustable source that explain the division by W ?
As I understand, the division by W was there before, it's just that its result was thrown away instead of being assigned to t
. This PR fixes that unintended error.
LGTM.
I have done this a while ago. Still missing something for a merge?
Sorry, I missed it back then.
The documentation for that func (https://godoc.org/github.com/go-gl/mathgl/mgl32#TransformCoordinate) itself says:
This is effectively equivalent to the GLSL code
vec4 r = (m * vec4(v,1.)); r = r/r.w; vec3 newV = r.xyz;
Yeah, but I can write anything in comments that doesn't mean it's true. I know that the statement before was effectively a noop. It would've been nice to link to like a trusted source that states how this works.
It would've been nice to link to like a trusted source that states how this works.
Sure. It can still be done.
Equally, if there's a trusted source saying this shouldn't be done, then we can revert this.
In brief: To make perspective distortion work. Or to quote wikipedia:
After carrying out the matrix multiplication, the homogeneous component w will, in general, not be equal to 1. Therefore, to map back into the real plane we must perform the homogeneous divide or perspective divide by dividing each component by w.
A slightly longer but much more understandable explanation can be found here.
Correction for a minor error. Should only affect perspective matrices.